oracle: Compute oracle predictions

Description Usage Arguments Value Methods (by class) Author(s)

View source: R/oracle.R


The function oracle performs a strategie that cannot be defined online (in contrast to mixture). It requires in advance the knowledge of the whole data set Y and the expert advice to be well defined. Examples of oracles are the best fixed expert, the best fixed convex combination rule, the best linear combination rule, or the best expert that can shift a few times.

Plot an aggregation procedure


oracle(Y, experts, model = "convex", loss.type = "square", awake = NULL,
  lambda = NULL, niter = NULL, ...)

## S3 method for class 'oracle'
plot(x, sort = TRUE, col = NULL, ...)



A vector containing the observations to be predicted.


A matrix containing the experts forecasts. Each column corresponds to the predictions proposed by an expert to predict Y. It has as many columns as there are experts.


A character string specifying the oracle to use or a list with a component name specifying the oracle and any additional parameter needed. Currently available oracles are:


The best fixed (constant over time) expert oracle.


The best fixed convex combination (vector of non-negative weights that sum to 1)


The best fixed linear combination of expert


It computes for all number $m$ of stwitches the sequence of experts with at most $m$ shifts that would have performed the best to predict the sequence of observations in Y.


A string or a list with a component 'name' specifying the loss function considered to evaluate the performance. It can be 'square', 'absolute', 'percentage', or 'pinball'. In the case of the pinball loss, the quantile can be provided by assigning to loss.type a list of two elements:


A string defining the name of the loss function (i.e., 'pinball')


A number in [0,1] defining the quantile to be predicted. The default value is 0.5 to predict the median.


A matrix specifying the activation coefficients of the 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.


A positive number used by the 'linear' oracle only. A possible $L_2$ regularization parameter for computing the linear oracle (if the design matrix is not identifiable)


A positive integer for 'convex' and 'linear' oracles if direct computation of the oracle is not implemented. It defines the number of optimization steps to perform in order to approximate the oracle (default value is 3).


Additional parameters that are passed to optim function is order to perform convex optimization (see parameter niter).


An object of class oracle.


if set to TRUE (default), it sorts the experts by performance before the plots.




An object of class 'oracle' that contains:


The average loss suffered by the oracle. For the 'shifting' oracle, it is a vector of length T where T is the number of instance to be predicted (i.e., the length of the sequence Y). The value of $loss(m)$ is the loss (determined by the parameter loss.type) suffered by the best sequence of expert with at most $m-1$ shifts.


Not for the 'shifting' oracle. A vector containing the best weight vector corresponding to the oracle.


Not for the 'shifting' oracle. A vector containing the predictions of the oracle.


If loss.type is the square loss (default) only. The root mean square error (i.e., it is the square root of loss.

Methods (by class)


Pierre Gaillard <>

opera documentation built on May 29, 2017, 10:32 p.m.

Search within the opera package
Search all R packages, documentation and source code