| predict.GPModel {gpboost} | R Documentation | 
Make predictions for a GPModel
Description
Make predictions for a GPModel
Usage
## S3 method for class 'GPModel'
predict(object, y = NULL, group_data_pred = NULL,
  group_rand_coef_data_pred = NULL, gp_coords_pred = NULL,
  gp_rand_coef_data_pred = NULL, cluster_ids_pred = NULL,
  predict_cov_mat = FALSE, predict_var = FALSE, cov_pars = NULL,
  X_pred = NULL, use_saved_data = FALSE, predict_response = TRUE,
  offset = NULL, offset_pred = NULL, fixed_effects = NULL,
  fixed_effects_pred = NULL, vecchia_pred_type = NULL,
  num_neighbors_pred = NULL, ...)
Arguments
| object | a  | 
| y | Observed data (can be NULL, e.g. when the model has been estimated already and the same data is used for making predictions) | 
| group_data_pred | A  | 
| group_rand_coef_data_pred | A  | 
| gp_coords_pred | A  | 
| gp_rand_coef_data_pred | A  | 
| cluster_ids_pred | A  | 
| predict_cov_mat | A  | 
| predict_var | A  | 
| cov_pars | A  | 
| X_pred | A  | 
| use_saved_data | A  | 
| predict_response | A  | 
| offset | A  | 
| offset_pred | A  | 
| fixed_effects | This is discontinued. Use the renamed equivalent argument  | 
| fixed_effects_pred | This is discontinued. Use the renamed equivalent argument  | 
| vecchia_pred_type | A  | 
| num_neighbors_pred | an  | 
| ... | (not used, ignore this, simply here that there is no CRAN warning) | 
Value
Predictions from a GPModel. A list with three entries is returned:
- "mu" (first entry): predictive (=posterior) mean. For (generalized) linear mixed effects models, i.e., models with a linear regression term, this consists of the sum of fixed effects and random effects predictions 
- "cov" (second entry): predictive (=posterior) covariance matrix. This is NULL if 'predict_cov_mat=FALSE' 
- "var" (third entry) : predictive (=posterior) variances. This is NULL if 'predict_var=FALSE' 
Author(s)
Fabio Sigrist
Examples
# See https://github.com/fabsig/GPBoost/tree/master/R-package for more examples
data(GPBoost_data, package = "gpboost")
# Add intercept column
X1 <- cbind(rep(1,dim(X)[1]),X)
X_test1 <- cbind(rep(1,dim(X_test)[1]),X_test)
#--------------------Grouped random effects model: single-level random effect----------------
gp_model <- fitGPModel(group_data = group_data[,1], y = y, X = X1,
                       likelihood="gaussian", params = list(std_dev = TRUE))
summary(gp_model)
# Make predictions
pred <- predict(gp_model, group_data_pred = group_data_test[,1], 
                X_pred = X_test1, predict_var = TRUE)
pred$mu # Predicted mean
pred$var # Predicted variances
# Also predict covariance matrix
pred <- predict(gp_model, group_data_pred = group_data_test[,1], 
                X_pred = X_test1, predict_cov_mat = TRUE)
pred$mu # Predicted mean
pred$cov # Predicted covariance
#--------------------Gaussian process model----------------
gp_model <- fitGPModel(gp_coords = coords, cov_function = "exponential",
                       likelihood="gaussian", y = y, X = X1, params = list(std_dev = TRUE))
summary(gp_model)
# Make predictions
pred <- predict(gp_model, gp_coords_pred = coords_test, 
                X_pred = X_test1, predict_cov_mat = TRUE)
pred$mu # Predicted (posterior) mean of GP
pred$cov # Predicted (posterior) covariance matrix of GP