# Fit a VAR model with R [closed]

I have a bivariate time series z_t where z_1t is the change in monthly US treasury bills (maturity 3 months) and z_2t the inflation rate, in percentage, of the U.S. monthly consumer price index (CPI). CPI used is the consumer price index for all urban consumers: all items (CPIAUCSL). The original data are downloaded from the Federal Reserve Bank of St.Louis. The CPI rate is 100 times the first difference of the log CPI index. I want to fit the specified VAR model and simplify the fit by a command R (refVar from package MTS or restrict from package vars) with threshold 1.65.

I found this exercise (pdf) on R. Tsay's website at the University of Chicago. The data are here.

What I did until now is the following:

y <- diff(zt[,3])
lot(y, type="l", ylab="tb3m")

# difference
x <- diff(log(zt[,4]))
plot(x, type="l", ylab="CPI rate")

new <- cbind(x, y)
# order selection gives VAR(6)
VARselect(new, lag.max=9, type="const")

data1 <- data[,c("tb3m","cpiaucsl")]
fit   <- VAR(data1,p=6)
fit

restrict(fit, method="ser", thresh=1.65, resmat=T)


restrict and VAR don't give me the right results or the same coefficients of the Var model in the answers in the pdf.

## closed as off-topic by mkt, kjetil b halvorsen, mdewey, Peter Flom♦Dec 3 '18 at 10:30

This question appears to be off-topic. The users who voted to close gave this specific reason:

• "This question appears to be off-topic because EITHER it is not about statistics, machine learning, data analysis, data mining, or data visualization, OR it focuses on programming, debugging, or performing routine operations within a statistical computing platform. If the latter, you could try the support links we maintain." – mkt, kjetil b halvorsen, Peter Flom
If this question can be reworded to fit the rules in the help center, please edit the question.

fit <- VAR(data1,p=6)

You can refine it with refVAR:
fit2 <- refVAR(fit,thres=1.65)

• Could you expand on your answer a little, such as explaining what refVAR does? – Glen_b Mar 1 '15 at 2:29