predict.MoE_expert function

Predictions from MoEClust expert networks

Predictions from MoEClust expert networks

Predictions (point estimates) of observation-specific component means from each (non-noise) component's expert network linear regression.

## 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 "MoE_expert" (typically x$expert, where x is of class "MoEClust").
  • 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 1 when there are no expert network covariates, in which case the entries correspond to object$parameters$mean. Defaults to FALSE.
  • droplevels: A logical indicating whether unseen factor levels in categorical variables within newdata should be dropped (with NA predicted in their place). Defaults to FALSE. See drop_levels.
  • ...: Catches unused arguments or allows the simplify argument to be passed through fitted and residuals.

Returns

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.

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.

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)

See Also

predict.MoEClust, lm, predict.MoE_gating, drop_levels

Author(s)

Keefe Murphy - <keefe.murphy@mu.ie >

  • Maintainer: Keefe Murphy
  • License: GPL (>= 3)
  • Last published: 2025-03-05