How to simulate bivariate VAR(2) model ?

Hello, hopefully someone can help!

I want to estimate a bivariate VAR(2) model in R using the package containing var.sim (this package is called tsDYN)

It is quite obvious how this is done with just one variable and a single matrix but when it comes to two I can't seem to work out the code?

var1<-VAR.sim(B=A,n=100,lag= 2,include="none")
ts.plot(var1, type="l", col=c(1,2))

but I want to simulate data for the following model.

Would anyone be able to offer a hand or is familiar with this package !

Thank you

Hi @ArnoldHenry,

You have to construct a 2x4 matrix, which is basically you A1 and A2 together (or B1 and B2 depending on the notation). So you have to start with the first row 0.2, 0, -0.1, 0.1 and then the second row -0.3, 0.4, 0.2, -0.3 and fill byrow. There are other ways to fill a matrix but this is just an example. So the first 2x2 block is A1 and the second 2x2 block is your A2.

A <- matrix(c(0.2, 0, -0.1, 0.1, -0.3, 0.4, 0.2, -0.3), byrow = TRUE, nrow = 2, ncol = 4)
#>      [,1] [,2] [,3] [,4]
#> [1,]  0.2  0.0 -0.1  0.1
#> [2,] -0.3  0.4  0.2 -0.3

var2 <- VAR.sim(B = A, lag = 2, include = "none", n = 100)
ts.plot(var2, type="l", col=c(1,2))

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.