FAQ
Hello all,
I looking at package dse or vars or mAr
I know how to simulate a VAR(p) process, my problem is that most of those
processes are unstable (not weakly stationary).
Do anybody know how to generate a random VAR (or VARMA even better) process
that is weakly stationary?

Thanks

--
View this message in context: http://r.789695.n4.nabble.com/simulating-stable-VAR-process-tp4261177p4261177.html
Sent from the R help mailing list archive at Nabble.com.

## Search Discussions

•  at Jan 4, 2012 at 1:17 pm ⇧
More specifically.
I know that a condition for a VAR(p) process to be stable (weakly
stationary) is that the companion form of the equation (see AWESOME Pfaff
book analysis of integrated and cointegrated time series in R) as
eigenvalues of modulus <1.

My problem is that I want to generate such processes...

When I try to generate random VAR(p) processes they seems to explode
(clearly they are not weakly stationary...)
Is there a way somebody know?

--
View this message in context: http://r.789695.n4.nabble.com/simulating-stable-VAR-process-tp4261177p4261210.html
Sent from the R help mailing list archive at Nabble.com.
•  at Jan 5, 2012 at 4:58 pm ⇧
The simulate function in dse lets you specify the model and the
distribution of the noise term (or even their values so you can get any
distribution you like). So, you should be able to do what you want,
with either a VAR(p) or a vector ARMA process. If you are getting a
process that explodes then your model is probably not stable. If it is a
dse TSmodel you can check it with stability(), see ?stability in dse.

Beware that the condition Modulus <1 depends on whether your lagged
parameters are specified on the left or right side of the equation. This
changes the sign of the lag parameters and inverts the condition. Dse
assumes lagged terms are specified on the left side, which is a bit
unusual compared to introductory text books. However, when you get to
hard problems it has advantages because the AR term is a matrix
polynomial ring and so it is easier to apply some useful mathematics.

Paul

Date: Wed, 4 Jan 2012 05:17:05 -0800 (PST)
From: statquant2<statquant@gmail.com>
To:r-help at r-project.org
Subject: Re: [R] simulating stable VAR process
Message-ID:<1325683025141-4261210.post@n4.nabble.com>
Content-Type: text/plain; charset=us-ascii

More specifically.
I know that a condition for a VAR(p) process to be stable (weakly
stationary) is that the companion form of the equation (see AWESOME Pfaff
book analysis of integrated and cointegrated time series in R) as
eigenvalues of modulus<1.

My problem is that I want to generate such processes...

When I try to generate random VAR(p) processes they seems to explode
(clearly they are not weakly stationary...)
Is there a way somebody know?
•  at Jan 13, 2012 at 10:09 am ⇧
Hello Paul
Thanks for the answer but my point is not how to simulate a VAR(p) process
and check that it is stable.
My question is more how can I generate a VAR(p) such that I already know
that it is stable.

We know a condition that assure that it is stable (see first message) but
this is not a condition on coefficients etc...
What I want is
generate say a 1000 random VAR(3) processes over say 500 time periods that
will be STABLE (meaning If I run stability() all will pass the test)

When I try to do that it seems that none of the VAR I am generating pass
this test, so I assume that the class of stable VAR(p) is very small
compared to the whole VAR(p) process.

--
View this message in context: http://r.789695.n4.nabble.com/simulating-stable-VAR-process-tp4261177p4291835.html
Sent from the R help mailing list archive at Nabble.com.
•  at Jan 14, 2012 at 1:34 am ⇧
I think that you must approach this in a different way.

1 Draw a set of random eigenvalues with modulus < 1
2 Draw a set of random eigenvalues vectors.
3 From these you can, with some matrix manipulations, derive the
corresponding Var coefficients.

If your original coefficients were drawn at random I suspect that the VAR
would not be stable. I am curious about what you are trying to do.

John
On Friday, 13 January 2012, statquant2 wrote:
Hello Paul
Thanks for the answer but my point is not how to simulate a VAR(p) process
and check that it is stable.
My question is more how can I generate a VAR(p) such that I already know
that it is stable.

We know a condition that assure that it is stable (see first message) but
this is not a condition on coefficients etc...
What I want is
generate say a 1000 random VAR(3) processes over say 500 time periods that
will be STABLE (meaning If I run stability() all will pass the test)

When I try to do that it seems that none of the VAR I am generating pass
this test, so I assume that the class of stable VAR(p) is very small
compared to the whole VAR(p) process.

--
View this message in context:
http://r.789695.n4.nabble.com/simulating-stable-VAR-process-tp4261177p4291835.html
Sent from the R help mailing list archive at Nabble.com.

______________________________________________
r-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
--
John C Frain
Economics Department
Trinity College Dublin
Dublin 2
Ireland
www.tcd.ie/Economics/staff/frainj/home.html
mailto:frainj@tcd.ie
mailto:frainj@gmail.com
•  at Jan 14, 2012 at 10:31 pm ⇧
Mark, statquant2

As I understand the question it is not to test if a VAR is stable but how
to construct a VAR that is stable and automatically satisfies the condition
Mark has taken from Lutkohl. The algorithm that I have set out will
automatically satisfy that condition.The matrix that should be "estimated
by the algorithm is A on the last line of page 15 of Lutkepohl.
Incidentally the corresponding matrix for the example on page 15 is
singular. The algorithm that I have set out will only lead to systems with
a non-singular matrix.

I still don't see how a matrix generated in this way corresponds to a real
economic system. Of course you may have some other constraints in mind
that would make the generated system correspond to something more real.

John
On Saturday, 14 January 2012, Mark Leeds wrote:
Hi statquant2 and john: In the first chapter of Lutkepohl, it is shown
that stability f
a VAR(p) is the same as

det(I_k - A1z - .... Ap Z^p ) does not equal zero for z < 1.

where I_k - A1z - ... Ap z^p is referred to as the reverse characteristic
polynomial.
So, statquant2, given your A's, one way to do it but be would be to
check the roots of the
polynomial implied by taking the determinant of the your polynomial.

There's an example on pg 17 of lutkepohl if you have it. If you don't, I
can fax it to you
over the weekend if you want it.

On Fri, Jan 13, 2012 at 8:34 PM, John C Frain wrote:

I think that you must approach this in a different way.

1 Draw a set of random eigenvalues with modulus < 1
2 Draw a set of random eigenvalues vectors.
3 From these you can, with some matrix manipulations, derive the
corresponding Var coefficients.

If your original coefficients were drawn at random I suspect that the VAR
would not be stable. I am curious about what you are trying to do.

John
On Friday, 13 January 2012, statquant2 wrote:
Hello Paul
Thanks for the answer but my point is not how to simulate a VAR(p)
process
and check that it is stable.
My question is more how can I generate a VAR(p) such that I already
know
that it is stable.

We know a condition that assure that it is stable (see first message)
but
this is not a condition on coefficients etc...
What I want is
generate say a 1000 random VAR(3) processes over say 500 time periods
that
will be STABLE (meaning If I run stability() all will pass the test)

When I try to do that it seems that none of the VAR I am generating
pass
this test, so I assume that the class of stable VAR(p) is very small
compared to the whole VAR(p) process.

--
View this message in context:
http://r.789695.n4.nabble.com/simulating-stable-VAR-process-tp4261177p4291835.html
Sent from the R help mailing list archive at Nabble.com.

______________________________________________
r-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
--
John C Frain
Economics Department
Trinity College Dublin
Dublin 2
Ireland
www.tcd.ie/Economics/staff/frainj/home.html
mailto:frainj@tcd.ie
mailto:frainj@gmail.com

[[alternative HTML version deleted]]

______________________________________________
r-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
--
John C Frain
Economics Department
Trinity College Dublin
Dublin 2
Ireland
www.tcd.ie/Economics/staff/frainj/home.html
mailto:frainj@tcd.ie
mailto:frainj@gmail.com
•  at Jan 15, 2012 at 2:28 am ⇧
Mark

This should be reasonably straightforward. In the simplest case you wih to
draw a random complex number in the unit circle. This is best done in polar
coordinates.

If r is a random mumber on (0,1) and theta a random number on (0, 2 Pi)
then if x=r cos(theta) and y= r sin(theta), x + i y is inside the unit
circle. As such roots come in conjugate pairs a second is x-iy. If you
then need an odd number of roots the final can simply be a random number on
(0,1). You do not need to use a uniform distribution but can use any
distribution on the required intervals or restrain more or the eigenvalues
to be real.

John
On Sunday, 15 January 2012, Mark Leeds wrote:
hi john. I think I follow you. but , in your algorithm, it is
straightforward to
generate a set of eigenvalues with modulus less than 1 ? thanks.

On Sat, Jan 14, 2012 at 5:31 PM, John C Frain wrote:

Mark, statquant2

As I understand the question it is not to test if a VAR is stable but how
to construct a VAR that is stable and automatically satisfies the condition
Mark has taken from Lutkohl. The algorithm that I have set out will
automatically satisfy that condition.The matrix that should be "estimated
by the algorithm is A on the last line of page 15 of Lutkepohl.
Incidentally the corresponding matrix for the example on page 15 is
singular. The algorithm that I have set out will only lead to systems with
a non-singular matrix.
I still don't see how a matrix generated in this way corresponds to a
real economic system. Of course you may have some other constraints in
mind that would make the generated system correspond to something more real.
John
On Saturday, 14 January 2012, Mark Leeds wrote:
Hi statquant2 and john: In the first chapter of Lutkepohl, it is shown
that stability f
a VAR(p) is the same as

det(I_k - A1z - .... Ap Z^p ) does not equal zero for z < 1.

where I_k - A1z - ... Ap z^p is referred to as the reverse
characteristic polynomial.
So, statquant2, given your A's, one way to do it but be would be to
check the roots of the
polynomial implied by taking the determinant of the your polynomial.

There's an example on pg 17 of lutkepohl if you have it. If you don't, I
can fax it to you
over the weekend if you want it.

On Fri, Jan 13, 2012 at 8:34 PM, John C Frain wrote:

I think that you must approach this in a different way.

1 Draw a set of random eigenvalues with modulus < 1
2 Draw a set of random eigenvalues vectors.
3 From these you can, with some matrix manipulations, derive the
corresponding Var coefficients.

If your original coefficients were drawn at random I suspect that the
VAR
would not be stable. I am curious about what you are trying to do.

John
On Friday, 13 January 2012, statquant2 wrote:
Hello Paul
Thanks for the answer but my point is not how to simulate a VAR(p)
process
and check that it is stable.
My question is more how can I generate a VAR(p) such that I already
know
that it is stable.

We know a condition that assure that it is stable (see first message)
but
this is not a condition on coefficients etc...
What I want is
generate say a 1000 random VAR(3) processes over say 500 time periods
that
will be STABLE (meaning If I run stability() all will pass the test)

When I try to do that it seems that none of the VAR I am generating
pass
this test, so I assume that the class of stable VAR(p) is very small
compared to the whole VAR(p) process.

--
View this message in context:
http://r.789695.n4.nabble.com/simulating-stable-VAR-process-tp4261177p4291835.html
Sent from the R help mailing list archive at Nabble.com.

______________________________________________
r-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
--
John C Frain
Economics Department
Trinity College Dublin
Dublin 2
Ireland
--
John C Frain
Economics Department
Trinity College Dublin
Dublin 2
Ireland
www.tcd.ie/Economics/staff/frainj/home.html
mailto:frainj@tcd.ie
mailto:frainj@gmail.com
•  at Jan 15, 2012 at 2:55 am ⇧
gotcha john. thanks.

On Sat, Jan 14, 2012 at 9:28 PM, John C Frain wrote:

Mark

This should be reasonably straightforward. In the simplest case you wih to
draw a random complex number in the unit circle. This is best done in polar
coordinates.

If r is a random mumber on (0,1) and theta a random number on (0, 2 Pi)
then if x=r cos(theta) and y= r sin(theta), x + i y is inside the unit
circle. As such roots come in conjugate pairs a second is x-iy. If you
then need an odd number of roots the final can simply be a random number on
(0,1). You do not need to use a uniform distribution but can use any
distribution on the required intervals or restrain more or the eigenvalues
to be real.

John
On Sunday, 15 January 2012, Mark Leeds wrote:
hi john. I think I follow you. but , in your algorithm, it is
straightforward to
generate a set of eigenvalues with modulus less than 1 ? thanks.

On Sat, Jan 14, 2012 at 5:31 PM, John C Frain wrote:

Mark, statquant2

As I understand the question it is not to test if a VAR is stable but
how to construct a VAR that is stable and automatically satisfies the
condition Mark has taken from Lutkohl. The algorithm that I have set out
will automatically satisfy that condition.The matrix that should be
"estimated by the algorithm is A on the last line of page 15 of Lutkepohl.
Incidentally the corresponding matrix for the example on page 15 is
singular. The algorithm that I have set out will only lead to systems with
a non-singular matrix.
I still don't see how a matrix generated in this way corresponds to a
real economic system. Of course you may have some other constraints in
mind that would make the generated system correspond to something more real.
John
On Saturday, 14 January 2012, Mark Leeds wrote:
Hi statquant2 and john: In the first chapter of Lutkepohl, it is shown
that stability f
a VAR(p) is the same as

det(I_k - A1z - .... Ap Z^p ) does not equal zero for z < 1.

where I_k - A1z - ... Ap z^p is referred to as the reverse
characteristic polynomial.
So, statquant2, given your A's, one way to do it but be would be to
check the roots of the
polynomial implied by taking the determinant of the your polynomial.

There's an example on pg 17 of lutkepohl if you have it. If you don't,
I can fax it to you
over the weekend if you want it.

On Fri, Jan 13, 2012 at 8:34 PM, John C Frain wrote:

I think that you must approach this in a different way.

1 Draw a set of random eigenvalues with modulus < 1
2 Draw a set of random eigenvalues vectors.
3 From these you can, with some matrix manipulations, derive the
corresponding Var coefficients.

If your original coefficients were drawn at random I suspect that the
VAR
would not be stable. I am curious about what you are trying to do.

John
On Friday, 13 January 2012, statquant2 wrote:
Hello Paul
Thanks for the answer but my point is not how to simulate a VAR(p)
process
and check that it is stable.
My question is more how can I generate a VAR(p) such that I already
know
that it is stable.

We know a condition that assure that it is stable (see first
message) but
this is not a condition on coefficients etc...
What I want is
generate say a 1000 random VAR(3) processes over say 500 time
periods that
will be STABLE (meaning If I run stability() all will pass the test)

When I try to do that it seems that none of the VAR I am generating
pass
this test, so I assume that the class of stable VAR(p) is very small
compared to the whole VAR(p) process.

--
View this message in context:
http://r.789695.n4.nabble.com/simulating-stable-VAR-process-tp4261177p4291835.html
Sent from the R help mailing list archive at Nabble.com.

______________________________________________
r-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
--
John C Frain
Economics Department
Trinity College Dublin
Dublin 2
Ireland
--
John C Frain
Economics Department
Trinity College Dublin
Dublin 2
Ireland
www.tcd.ie/Economics/staff/frainj/home.html
mailto:frainj@tcd.ie
mailto:frainj@gmail.com

## Related Discussions

Discussion Overview
 group r-help categories r posted Jan 4, '12 at 1:08p active Jan 15, '12 at 2:55a posts 8 users 4 website r-project.org irc #r

### 4 users in discussion

Content

People

Support

Translate

site design / logo © 2022 Grokbase