predict.mgm | R Documentation |
Computes predictions and prediction errors from a mgm model-object (mgm
, mvar
, tvmgm
or tvmvar
).
## S3 method for class 'mgm'
predict(object, data, errorCon, errorCat,
tvMethod, consec, beepvar, dayvar, ...)
object |
An mgm model object (the output of one of the functions |
data |
A n x p data matrix with the same structure (number of variables p and types of variables) as the data used to fit the model. |
errorCon |
Either a character vector specifying the types of nodewise errors that should be computed, where the two provided error functions for continuous varaibles are Alternatively, |
errorCat |
Either a character vector specifying the types of nodewise errors that should be computed, where the two provided error functions for categorical variables are Alternatively, |
tvMethod |
Specifies how predictions and errors are computed for time-varying models: |
consec |
Only relevant for (time-varying) mVAR models. An integer vector of length |
beepvar |
Together with the argument |
dayvar |
See |
... |
Additional arguments. |
Nodewise errors in time-varying models can be computed in two different ways: first, one computes the predicted value for each of the N cases in the time series for all models (estimated at different estimation points, see ?tvmgm
or ?tvmvar
). Then the error of each of the N cases for each of the models is weighted by the weight that has been used to estimate a given model at its estimation point. This means that the error of a data point close to the end of a time-series gets a high weight for models estimated in the end of the time-series and a low weight for models estimated in the beginning of the time series.
Second, we determine for each case in the time-series the closest estmation point, and use the model estimated at that estimation point to make predictions for that case.
Note that the error function normalized accuracy (nCC) is negative if the full model performs worse than the intercept model. This can happen if the model overfits the data.
A list with the following entries:
call |
Contains all provided input arguments. |
predicted |
A n x p matrix with predicted values, matching the dimension of the true values in |
probabilities |
A list with p entries corresponding to p nodes in the data. If a variable is categorical, the corresponding entry contains a n x k matrix with predicted probabilities, where k is the number of categories of the categorical variable. If a variable is continuous, the corresponding entry is empty. |
true |
Contains the true values. For |
errors |
A matrix containing the all types of errors specified via |
tverrors |
If |
Jonas Haslbeck <jonashaslbeck@gmail.com>
Haslbeck, J. M. B., & Waldorp, L. J. (2020). mgm: Estimating time-varying Mixed Graphical Models in high-dimensional Data. Journal of Statistical Software, 93(8), pp. 1-46. DOI: 10.18637/jss.v093.i08
## Not run:
# See examples in ?mgm, ?tvmgm, ?mvar and ?tvmvar.
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.