# NOT RUN {
## Example of TVLM prediction with coefficients as
## functions of the realized quarticity
data("RV")
RV2 <- head(RV, 2001)
z <- RV2$RQ_lag_sqrt
TVHARQ <- tvLM (RV ~ RV_lag + RV_week + RV_month,
z = z, data = RV2, bw = 0.0062)
newdata <- cbind(RV$RV_lag[2002:2004], RV$RV_week[2002:2004],
RV$RV_month[2002:2004])
newz <- RV$RQ_lag_sqrt[2002:2004]
predict(TVHARQ, newdata, newz)
## Example of TVAR prediction with coefficients as
## functions of the realized quarticity
data("RV")
RV2 <- head(RV, 2001)
exogen = RV2[, c("RV_week", "RV_month")]
TVHARQ2 <- tvAR (RV2$RV, p = 1, exogen = exogen,
z = RV2[, "RQ_lag_sqrt"], bw = 0.0062)
newylag <- RV$RV[2002:2004]
newz <- RV$RQ_lag_sqrt[2002:2004]
newexogen <- RV[2002:2004, c("RV_week", "RV_month")]
predict(TVHARQ2, newylag, newz, newexogen = newexogen)
## Example of TVVAR prediction with coefficients as
## functions of a random ARMA (2,2) process
data(usmacro, package = "bvarsv")
smoothing <- arima.sim(n = NROW(usmacro) + 3,
list(ar = c(0.8897, -0.4858), ma = c(-0.2279, 0.2488)),
sd = sqrt(0.1796))
smoothing <- as.numeric(smoothing)
TVVAR.z <- tvVAR(usmacro, p = 6, type = "const",
z = smoothing[1:NROW(usmacro)], bw = c(16.3, 16.3, 16.3))
newdata <- data.frame(inf = c(2, 1, 6), une = c(5, 4, 9), tbi = c(1, 2.5, 3))
newz <- c(0, 1.2, -0.2)
predict(TVVAR.z, newdata = newdata, newz = newz)
## Example of TVSURE prediction with coefficients as
## functions of an ARMA(2,2) process
data("Kmenta", package = "systemfit")
nobs <- NROW (Kmenta)
eqDemand <- consump ~ price + income
eqSupply <- consump ~ price + farmPrice
system <- list(demand = eqDemand, supply = eqSupply)
smoothing <- arima.sim(n = nobs + 3,
list(ar = c(0.8897, -0.4858), ma = c(-0.2279, 0.2488)),
sd = sqrt(0.1796))
smoothing <- as.numeric(smoothing)
TVOLS.z <- tvSURE(system, data = Kmenta,
z = smoothing[1:nobs], bw = c(7, 1.8),
est = "ll")
newdata <- data.frame(consump = c(95, 100, 102), price = c(90, 100, 103),
farmPrice = c(70, 95, 103), income = c(82, 94, 115))
newz <- tail(smoothing, 3)
predict(TVOLS.z, newdata = newdata, newz = newz)
data(OECD)
z <- runif(length(levels(OECD$year)), 10, 15)
TVPOLS <- tvPLM(lhe~lgdp+pop65+pop14+public, z = z,
index = c("country", "year"), data = OECD, method ="pooling", bw = 2)
newdata <- cbind(lgdp = c(10, 13), pop65 = c(9, 12),
pop14 = c(17, 30), public = c(13, 20))
newz <- runif(2, 10, 15)
predict(TVPOLS, newdata = newdata, newz = newz)
# }
Run the code above in your browser using DataLab