Description Usage Arguments Value See Also Examples

View source: R/scoreopt_functions.R

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.

1 2 3 4 5 6 7 8 9 10 |

`data` |
Past data realisations as vectors in a list. Each list element corresponds to a period of training data. |

`prob` |
List of functions to simulate from probabilistic forecasts. Each list element corresponds to a period of training data. The output of each function should be a matrix. |

`S` |
Matrix encoding linear constraints. |

`Ginit` |
Initial values of reconciliation parameters |

`control` |
Tuning parameters for SGD. See |

`score` |
Score to be used. This must be a list with two elements: score for the scoring rule (currently only energy score and variogram score 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 |

`matches` |
A flag that checks for exact matches between samples from reconciled distribution. This causes NaNs in the automatic differentiation. For approaches that rely on bootstrapping set to TRUE. Otherwise set to FALSE (the default) to speed up code. |

Optimised reconciliation parameters.

`d` |
Translation vector for reconciliation. |

`G` |
Reconciliation matrix. |

`val` |
The estimated optimal total score. |

`Gvec_store` |
A matrix of Gvec ( |

`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:
`inscoreopt()`

,
`scoreopt.control()`

,
`total_score()`

1 2 3 4 5 6 7 8 9 10 | ```
#Use purr library to setup
library(purrr)
#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)
data<-map(1:10,function(i){S%*%(c(1,1)+rnorm(2))})
#Set list of functions to generate 50 iterates from probabilistic forecast
prob<-map(1:10,function(i){f<-function(){matrix(rnorm(3*50),3,50)}})
#Find weights by SGD (will take a few seconds)
out<-scoreopt(data,prob,S)
``` |

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.