Learn R Programming

tvReg (version 0.5.6)

forecast: Forecast Methods for Objects in tvReg.

Description

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.

Usage

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

predict.

Examples

Run this code
# NOT RUN {
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)


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)

data(usmacro, package = "bvarsv")
model.tvVAR <- tvVAR(usmacro, p = 6, type = "const", bw = c(1.8, 20, 20))
forecast(model.tvVAR, n.ahead = 10)

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)
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)
# }

Run the code above in your browser using DataLab