View source: R/basic_complementary_functions.R
predict.pep | R Documentation |
Computes predicted or fitted values under the PEP approach. Predictions can be based on Bayesian model averaging, maximum a posteriori model or median probability model. For the Bayesian model averaging, a subset of the top models (either based on explicit number or on their cumulative probability) can be used for prediction.
## S3 method for class 'pep'
predict(
object,
xnew,
estimator = "BMA",
n.models = NULL,
cumul.prob = 0.99,
...
)
object |
An object of class pep (e.g., output of |
xnew |
An optional data frame of numeric, the new data on the explanatory variables to be used for prediction. The data frame needs to contain information about all explanatory variables available in the full model; if not an error message is output. If omitted, fitted values are computed. |
estimator |
A character, the type of prediction. One of
“BMA” (Bayesian model averaging, default),
“MAP” (maximum a posteriori model) or “MPM” (median probability model).
Default value= |
n.models |
Positive integer, the number of (top) models that
prediction is based on or |
cumul.prob |
Numeric between zero and one, cumulative probability of
top models to be used for prediction. Relevant for |
... |
Additional parameters to be passed, currently none. |
When xnew
is missing or xnew
is equal to the initial
data frame used for fitting, then fitted
values are computed (and returned).
For prediction, Equation 9 of Fouskakis and Ntzoufras (2020) is used.
The case of missing data (i.e., presence of NA’s)
and non–quantitative data in the new data frame
xnew
is not currently supported.
Let k
be the number of models with cumulative posterior probability up
to the given value of cumul.prob
. Then, for Bayesian model averaging
the prediction is based on the top (k+1)
models if they exist, otherwise
on the top k
models.
When both n.models
and cumul.prob
are provided — once
specifying the number of models for the given cumulative probability as
described above — the minimum between the two numbers is used for prediction.
predict
returns a vector with the predicted (or fitted)
values for the different observations.
Fouskakis, D. and Ntzoufras, I. (2022) Power–Expected–Posterior Priors as Mixtures of g–Priors in Normal Linear Models. Bayesian Analysis, 17(4): 1073-1099. \Sexpr[results=rd]{tools:::Rd_expr_doi("10.1214/21-BA1288")}
Fouskakis, D. and Ntzoufras, I. (2020) Bayesian Model Averaging Using Power–Expected–Posterior Priors. Econometrics, 8(2): 17. \Sexpr[results=rd]{tools:::Rd_expr_doi("10.3390/econometrics8020017")}
data(UScrime_data)
X <- UScrime_data[,-15]
set.seed(123)
res <- pep.lm(y~.,data=UScrime_data[1:45,],intrinsic=TRUE,
algorithmic.choice="MC3",itermc3=4000)
resf <- predict(res)
resf2 <- predict(res,estimator="MPM")
resp <- predict(res,xnew=X[46:47,])
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.