forecast calculates the forecast for objects with class attribute tvlm, tvar, tvvar, tvirf, tvsure and tvplm. If the smoothing variable (z) in the model is non-NULL and it is a random variable then use function predict with parameter newz.

forecast(object, ...)

# S3 method for tvlm
forecast(object, newdata, n.ahead = 1, winsize = 0, ...)

# S3 method for tvar
forecast(object, n.ahead = 1, newz = NULL, newexogen = NULL, winsize = 0, ...)

# S3 method for tvvar
forecast(object, n.ahead = 1, newz = NULL, newexogen = NULL, winsize = 0, ...)

# S3 method for tvsure
forecast(object, newdata, n.ahead = 1, winsize = 0, ...)

# S3 method for tvplm
forecast(object, newdata, n.ahead = 1, winsize = 0, ...)

Arguments

object

An object used to select a method.

...

Other parameters passed to specific methods.

newdata

A matrix or data.frame with the values of the regressors to use for forecasting.

n.ahead

A scalar with the forecast horizon, value 1 by default.

winsize

A scalar. If 0 then an 'increase window' forecasting is performed. Otherwise a 'rolling window' forecasting is performed with window size given by 'winsize'.

newz

A vector with the new values of the smoothing variable.

newexogen

A matrix or vector with the new values of the exogenous variables. Only for predictions of *tvar* and *tvvar* objects.

Value

An object of class matrix or vector with the same dimensions than the dependent variable of object.

See also

Examples

data("RV") RV2 <- head(RV, 2001) TVHAR <- tvLM (RV ~ RV_lag + RV_week + RV_month, data = RV2, bw = 20) newdata <- cbind(RV$RV_lag[2002:2004], RV$RV_week[2002:2004], RV$RV_month[2002:2004]) forecast(TVHAR, newdata, n.ahead = 3)
#> [1] 1.820324e-05 1.930130e-05 2.573088e-05
data("RV") exogen = RV[1:2001, c("RV_week", "RV_month")] TVHAR2 <- tvAR(RV$RV_lag[1:2001], p = 1, exogen = exogen, bw = 20) newexogen <- RV[2002:2004, c("RV_week", "RV_month")] forecast(TVHAR2, n.ahead = 3, newexogen = newexogen)
#> [1] 1.663144e-05 1.630848e-05 2.174843e-05
data(usmacro, package = "bvarsv") model.tvVAR <- tvVAR(usmacro, p = 6, type = "const", bw = c(1.8, 20, 20)) forecast(model.tvVAR, n.ahead = 10)
#> inf une tbi #> [1,] 2.296376 5.130155 2.985502 #> [2,] 2.288106 5.191209 2.873162 #> [3,] 2.249695 5.112356 2.524628 #> [4,] 2.161933 4.939517 2.307814 #> [5,] 2.167527 4.787522 2.584394 #> [6,] 2.245035 4.685216 2.833504 #> [7,] 2.374512 4.631450 2.895080 #> [8,] 2.570610 4.592054 2.980562 #> [9,] 2.769433 4.556460 3.120611 #> [10,] 2.962495 4.537426 3.385132
data("Kmenta", package = "systemfit") eqDemand <- consump ~ price + income eqSupply <- consump ~ price + farmPrice system <- list(demand = eqDemand, supply = eqSupply) tvOLS.fit <- tvSURE(system, data = Kmenta, est = "ll", bw = c(1.5, 1.5)) newdata <- data.frame(price = c(90, 100, 103), farmPrice = c(70, 95, 103), income = c(82, 94, 115)) forecast(tvOLS.fit, newdata = newdata, n.ahead = 3)
#> demand supply #> [1,] 94.93297 97.52587 #> [2,] 96.91250 103.34207 #> [3,] 104.93360 105.27857
data(OECD) tvpols <- tvPLM(lhe~lgdp+pop65+pop14+public, index = c("country", "year"), data = OECD, method = "pooling", bw = 8.9) newdata <- OECD[c(7, 9), 4:7] forecast(tvpols, newdata = newdata, n.ahead = 2)
#> [1] 7.824744 7.924548