Learn R Programming

opera (version 1.2.0)

predict.mixture: Predict method for Mixture models

Description

Performs sequential predictions and updates of a mixture object based on new observations and expert advice.

Usage

# S3 method for mixture
predict(
  object,
  newexperts = NULL,
  newY = NULL,
  awake = NULL,
  online = TRUE,
  type = c("model", "response", "weights", "all"),
  use_cpp = getOption("opera_use_cpp", default = FALSE),
  quiet = TRUE,
  ...
)

Arguments

object

Object of class inheriting from 'mixture'

newexperts

An optional matrix in which to look for expert advice with which predict. If omitted, the past predictions of the object are returned and the object is not updated.

newY

An optional matrix with d columns (or vector if \(d=1\)) of observations to be predicted. If provided, it should have the same number of rows as the number of rows of newexperts. If omitted, the object (i.e, the aggregation rule) is not updated.

awake

An optional array specifying the activation coefficients of the experts. It must have the same dimension as experts. Its entries lie in [0,1]. Possible if some experts are specialists and do not always form and suggest prediction. If the expert number k at instance t does not form any prediction of observation Y_t, we can put awake[t,k]=0 so that the mixture does not consider expert k in the mixture to predict Y_t.

online

A boolean determining if the observations in newY are predicted sequentially (by updating the object step by step) or not. If FALSE, the observations are predicting using the object (without using any past information in newY). If TRUE, newY and newexperts should not be null.

type

Type of prediction. It can be

model

return the updated version of object (using newY and newexperts).

response

return the forecasts. If type is 'model', forecasts can also be obtained from the last values of object$prediction.

weights

return the weights assigned to the expert advice to produce the forecasts. If type is 'model', forecasts can also be obtained from the last rows of object$weights.

all

return a list containing 'model', 'response', and 'weights'.

use_cpp

boolean. Whether or not to use cpp optimization to fasten the computations. This option is not yet compatible with the use of custom loss function.

quiet

boolean. Whether or not to display progress bars.

...

further arguments are ignored

Value

predict.mixture produces a matrix of predictions (type = 'response'), an updated object (type = 'model'), or a matrix of weights (type = 'weights').