View source: R/scoreopt_functions.R
inscoreopt | R Documentation |
Function to find a reconciliation matrix that optimises total score
using training data. Stochastic gradient descent is used for optimisation
with gradients found using automatic differentiation. This function differs
from scoreopt
in two main ways. First,
formulation of base probabilistic forecasts is carried out from one of four
options depending on whether dependence and/or Gaussianity is assumed. Second,
the optimistation is based on in-sample predictions rather than a rolling window
of out-of sample forecasts. For more flexibility
use scoreopt
.
inscoreopt(
y,
yhat,
S,
Ginit = c(rep(0, ncol(S)), as.vector(solve(t(S) %*% S, t(S)))),
control = list(),
basedep = "joint",
basedist = "gaussian",
Q = 500,
score = list(score = "energy", alpha = 1),
trace = FALSE
)
y |
Matrix of data, each column responds to an observation, each row corresponds to a variable. |
yhat |
Matrix of predicted values, each column responds to an observation, each row corresponds to a variable. |
S |
Matrix encoding linear constraints. |
Ginit |
Initial values of reconciliation parameters |
control |
Tuning parameters for SGD. See |
basedep |
Should base distributions be assumed to be dependent (joint) or independent? Default is "joint", set to "independent" for independence. |
basedist |
Should base distributions be assumed to be Gaussian or bootstrapped? Default is "gaussian" set to "bootstrap" for bootstrapping. |
Q |
Number of Monte Carlo iterations used to estimate score |
score |
Score to be used. This must be a list with two elements: score for the scoring rule (currently only energy supported) and alpha, an additional parameter used in the score (e.g. power in energy score, default is 1). |
trace |
Flag to keep details of SGD. Default is FALSE |
Optimised reconciliation parameters.
d |
Translation vector for reconciliation. |
G |
Reconciliation matrix (G). |
val |
The estimated optimal total score. |
Gvec_store |
A matrix of Gvec (d and G vectorised) where each column corresponds to an iterate of SGD (only produced when trace=TRUE). |
val_store |
A vector where each element gives the value of the objective function for each iterate of SGD (only produced when trace=TRUE). |
Other ProbReco functions:
scoreopt.control()
,
scoreopt()
,
total_score()
#Define S matrix
S<-matrix(c(1,1,1,0,0,1),3,2, byrow = TRUE)
#Set data (only 10 training observations used for speed)
y<-S%*%(matrix(rnorm(20),2,10)+1)
#Set point forecasts (chosen randomly from (0,1))
yhat<-matrix(runif(nrow(y)*ncol(y)),nrow(y),ncol(y))
#Find weights by SGD (Q set to 20 so that example runs quickly)
out<-inscoreopt(y,yhat,S,Q=20)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.