predict.MoE_expert {MoEClust} | R Documentation |
Predictions from MoEClust expert networks
Description
Predictions (point estimates) of observation-specific component means from each (non-noise) component's expert network linear regression.
Usage
## S3 method for class 'MoE_expert'
predict(object,
newdata = NULL,
simplify = FALSE,
droplevels = FALSE,
...)
## S3 method for class 'MoE_expert'
fitted(object,
...)
## S3 method for class 'MoE_expert'
residuals(object,
...)
Arguments
object |
An object of class |
newdata |
A matrix or data frame of test examples. If omitted, the fitted values are used. |
simplify |
Logical indicating whether to simplify the output (in the form of a list) to a 3-dimensional array with dimensions given by the number of new observations, the number of variables, and the number of clusters. The first dimension of such an array is of length |
droplevels |
A logical indicating whether unseen factor levels in categorical variables within |
... |
Catches unused arguments or allows the |
Details
This function is effectively just a shortcut to lapply(x$expert, predict.lm, newdata=...)
. It can also be thought of as a wrapper to predict.MoEClust(x, ...)$mean
, although it returns a list (by default) rather than a 3-dimensional array and also always preserves the dimensions of newdata
, even for models without expert network covariates.
Value
For simplify=FALSE
, either a list of vectors or predictions (for univariate data) or a list of matrices of predictions (for multivariate data). These lists are of the same length as number of non-noise components in the fitted model. When simplify=TRUE
, a 3-dimensional array of predictions is returned, with respective dimensions given by the number of observations, variables, and non-noise components.
Author(s)
Keefe Murphy - <keefe.murphy@mu.ie>
See Also
predict.MoEClust
, lm
, predict.MoE_gating
, drop_levels
Examples
data(CO2data)
res <- MoE_clust(CO2data$CO2, G=3, equalPro=TRUE, expert= ~ GNP, network.data=CO2data)
predict(res$expert)
# Try with newdata and simplify=TRUE
predict(res$expert, newdata=CO2data[1:5,"GNP", drop=FALSE], simplify=TRUE)