##The parameter function
theta.h0 <- function(p, dk, ...) {
i <- (1:dk-1)/100
pol <- p[3]*i + p[4]*i^2
(p[1] + p[2]*i)*exp(pol)
}
##Generate coefficients
theta0 <- theta.h0(c(-0.1,10,-10,-10),4*12)
##Plot the coefficients
plot(theta0)
##Generate the predictor variable
x <- simplearma.sim(list(ar=0.6),1500*12,1,12)
##Simulate the response variable
y <- midas.sim(500,theta0,x,1)
##Remove unnecessary history of x
x <- window(x,start=start(y))
##Fit restricted model
mr <- midas_r(y~fmls(x,4*12-1,12,theta.h0)-1,
list(y=y,x=x),
start=list(x=c(-0.1,10,-10,-10)))
##Include intercept and trend in regression
mr.it <- midas_r(y~fmls(x,4*12-1,12,theta.h0)+trend,
list(data.frame(y=y,trend=1:500),x=x),
start=list(x=c(-0.1,10,-10,-10)))
data("USrealgdp")
data("USunempr")
y.ar <- diff(log(USrealgdp))
xx <- window(diff(USunempr), start = 1949)
trend <- 1:length(y.ar)
##Fit AR(1) model
mr.ar <- midas_r(y.ar ~ trend + mls(y.ar, 1, 1) +
fmls(xx, 11, 12, nealmon),
start = list(xx = rep(0, 3)))
##First order MIDAS-AR* restricted model
mr.arstar <- midas_r(y.ar ~ trend + mls(y.ar, 1, 1, "*")
+ fmls(xx, 11, 12, nealmon),
start = list(xx = rep(0, 3)))
Run the code above in your browser using DataLab