#Use purr library to setup
library(purrr)
#Define S matrix
S<-matrix(c(1,1,1,0,0,1),3,2, byrow = TRUE)
#Randomly set a value of reconciliation parameters
Gvec<-as.matrix(runif(8))
#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 generating from probabilistic forecast
prob<-map(1:10,function(i){f<-function(){matrix(rnorm(3*50),3,50)}})
#Compute total score
out<-total_score(data,prob,S,Gvec)
Run the code above in your browser using DataLab