[R-SIG-Finance] Simulating VAR model (re-post)

Matthieu Stigler matthieu.stigler at gmail.com
Wed Mar 31 09:20:25 CEST 2010


I don't think this will solve the problem but it looks like you are once 
specifying mu as a constant (your model) once as a trend (dse), right?

Mat

Ron_M a écrit :
> Dear all,
>
> I have posted a query on simulating a VAR (Vector Auto-regression) model on
> R-help, however still unable to get some satisfactory reply. That post can
> be found here
> "http://n4.nabble.com/Simulation-of-VAR-td1693295.html#a1693295". Therefore
> I am re-posting the same here as well. Hopefully this query will be able to
> fetch some educated attention from the experts here, who are presumably more
> into time series analysis/finance.
>
> This is my post :
>
> I want to simulate a VAR model on some estimated coefficients. And employed
> two approaches, one is my native approach completely based on the my
> understanding on VAR and second based "simulate" function from "dse"
> package. Surprisingly those two are giving quite different results, although
> they are based on same set of random numbers. Here is that :
>
> library(dse) 
> A1 <- matrix(rnorm(16),4) 
> A2 <- matrix(rnorm(16),4) 
> mu <- rnorm(4) 
> sigma <- matrix(c(0.006594712, 
> 0.006467731, 
> -0.000254914, 
> 0.005939934, 
> 0.006467731, 
> 0.006654184, 
> -0.000384097, 
> 0.005658247, 
> -0.000254914, 
> -0.000384097, 
> 0.000310294, 
> 4.34141E-05, 
> 0.005939934, 
> 0.005658247, 
> 4.34141E-05, 
> 0.00574024), 4) 
> initial.val <- matrix(c(-0.2347096, 
> -0.1803612, 
> -0.2780356, 
> -0.2154427 , 
> 3.740364, 
> 3.757908, 
> 3.50216 , 
> 3.57783), 2) 
>
> ##### My approach
> res <- matrix(NA, 4,4); res[c(1,2),] <- initial.val 
> library(mnormt); shocks <- rmnorm(2, rep(0,4), sigma) 
> for (i in 1:2) { 
>       res[i+2,] <- mu + A1%*%res[i+2-1,] + A2%*%res[i+2-2,] + shocks[i,] } 
> res 
> ##### dse approach
> temp1 <- matrix(t(cbind(diag(4), A1, A2)), ncol = 4, byrow = TRUE) 
> model <- ARMA(A=array(temp1, c(3,4,4)), B=diag(4), TREND=mu) 
> simulate(model, y0=initial.val, sampleT=2, noise=shocks) 
>
>
> So I guess something terribly going wrong in any of the approaches in terms
> of my understanding. Can someone here point out what is that, if any? Your
> help will be highly appreciated.
>
> Thanks,
>



More information about the R-SIG-Finance mailing list