Running ‘doExtras.R’ [0s/0s]
  Comparing ‘doExtras.Rout’ to ‘doExtras.Rout.save’ ... OK
  Running ‘getArray-swap.R’ [1s/1s]
  Running ‘tst-wrongs.R’ [18s/42s]
  Running ‘tstTGforecasts.R’ [0s/1s]
  Running ‘tstVaRsuperadd.R’ [3s/10s]
  Running ‘varlist.R’ [1s/1s]
Running the tests in ‘tests/tstTGforecasts.R’ failed.
Complete output:
  > #### A "fast" and simplified version of demo(TGforecasts)
  > #### see ../demo/TGforecasts.R
  > ####     ~~~~~~~~~~~~~~~~~~~~~
  > 
  > require(simsalapar)
  Loading required package: simsalapar
  > ## also  require(fGarch)
  > 
  > 
  > ### Variable list ##############################################################
  > 
  > ## Create varlist (default type is 'frozen'; default expressions are generated)
  > ## note: no n.sim here
  > vList <-
  +     varlist(forecaster = list(type="grid", expr = quote(italic(forecaster)),
  +                               value = c("statistician", "optimist", "pessimist")),
  + 	    scoringfun = list(type="inner", expr = quote(S),
  + 			      value = list(SE = function(x, y) mean((x-y)^2),
  + 					   AE = function(x, y) mean(abs(x-y)))),
  +             ## GARCH(1,1): X_t = sigma_t * eps_t,
  +             ## sigma_t^2 = alpha_0 + alpha_1*X_{t-1}^2 + beta_1*sigma_{t-1}^2
  +             alpha0     = list(expr = quote(alpha[0]), value = 0.05),
  +             alpha1     = list(expr = quote(alpha[1]), value = 0.2),
  +             beta1      = list(expr = quote(beta[1]), value = 0.75),
  +             ## constant prediction of optimist:
  +             pred.optimist  = list(expr = "Optimist", value = 5),
  +             ## constant prediction of pessimist:
  +             pred.pessimist = list(expr = "Pessimist", value = 0.05),
  +             ## n
  +             n = list(value = 64),
  +             ## simulation method
  +             method = list(value = "fGarch"))
  > 
  > ### doOne() including ingredient functions #####################################
  > ##  -------
  > ##  instead of 'local', use a construction like
  > ##  doOne <- function(x, <nonGrids>, simGARCH11, predictTG)
  > 
  > doOne <- local({
  + 
  +     ## function for simulating a squared GARCH(1,1)
  +     simGARCH11 <- function(n, a0, a1, b1, method=c("fGarch", "Gneiting"))
  +     {
  +         method <- match.arg(method)
  +         switch(method,
  +                "fGarch" = {
  +                    ## specify the GARCH(1,1) process
  + 		   spec <- fGarch::garchSpec(model =
  + 					     list(omega = a0, alpha = a1, beta = b1))
  + 		   ## simulate; extended=TRUE => data.frame
  + 		   ##		with columns garch, sigma, eps  time series
  +                    fGarch::garchSim(spec, n=n, extended=TRUE)
  +                },
  +                "Gneiting" = { # Gneiting's code (with minor adjustments)
  +                    alpha <- a1
  +                    beta <- b1
  +                    gamma <- a0
  +                    z <- rep(0, n+1)
  +                    y <- rep(0, n+1)
  +                    sigmasq <- rep(1, n+1)
  +                    z[1] <- rnorm(1)
  +                    for (t in 2:(n+1)) {
  +                        sigmasq[t] <- alpha*z[t-1]^2 + beta*sigmasq[t-1] + gamma
  +                        z[t] <- rnorm(1, sd=sqrt(sigmasq[t]))
  +                    }
  +                    ts(cbind(garch=z[-1], sigma=sqrt(sigmasq[-1])))
  +                },
  +                stop("wrong 'method'"))
  +     }
  + 
  +     ## prediction function
  +     predictTG <- function(x, n, forecaster, pred.opt, pred.pes) {
  +         stopifnot(is.character(forecaster))
  +         switch(forecaster,
  +                "optimist"  = rep(pred.opt, n),
  +                "pessimist" = rep(pred.pes, n),
  +                ## statistician predicts hat{X}_t = E[Y_t | sigma_t^2] = sigma_t^2
  +                "statistician" = x[,"sigma"]^2,
  +                stop("forecaster not supported"))
  +     }
  + 
  +     ##' Statistic (use it like this to include simulation in time measurement)
  + 
  +     ##' @title Function to Compute the Simulation Results for One Grid Line
  +     ##' @param x one-line data.frame containing a combination of grid variables
  +     ##' @param nonGrids values of non-"grid"-variables
  +     ##' @return return value of doCallWE()
  +     ##' @author Marius Hofert
  +     function(n, alpha0, alpha1, beta1, forecaster,
  +              pred.optimist, pred.pessimist, method, scoringfun)
  +     {
  +         ## simulate squared GARCH(1,1)
  +         X <- simGARCH11(n, a0=alpha0, a1=alpha1, b1=beta1, method=method)
  +         Y <- X[,"garch"]^2              # see (2) in Gneiting (2011)
  +         ## predict
  +         pred <- predictTG(X, n=n, forecaster=forecaster,
  +                           pred.opt=pred.optimist, pred.pes=pred.pessimist)
  + 
  +         ## basic check
  +         stopifnot(length(pred)==length(Y))
  + 
  +         ## compute scoring functions (for all 'inner' variables simultaneously)
  +         c(SE = scoringfun[["SE"]](pred, y=Y),
  +           AE = scoringfun[["AE"]](pred, y=Y))
  +     }
  + })
  > 
  > ## build grid and non-grid variables
  > stopifnot(dim(pGrid <- mkGrid(vList)) == c(3,1), # only the forecaster here
  + 	  get.nonGrids(vList)$n.sim == 1) # the "automatic n.sim" if there is none
  > 
  > tex.vl <- toLatex(vList)
  > 
  > ### Computation ################################################################
  > 
  > S.T <- system.time
  > 
  > ## 'reproducing' Table 4 in Gneiting (2011)
  > 
  > ## sequentially
  > S.T(res <- doLapply(vList, doOne=doOne, monitor=TRUE))
  Error in doCheck(doOne, vList, nChks = 1, verbose = FALSE) : 
    is.numeric(r) is not TRUE
  Calls: S.T -> doLapply -> doCheck -> stopifnot
  Timing stopped at: 0.004 0 0.004
  Execution halted