[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: generate AR(1) data
From: |
Mike Miller |
Subject: |
Re: generate AR(1) data |
Date: |
Thu, 17 Jul 2003 01:23:28 -0500 (CDT) |
Heber--
Do you mean that you know the desired variance-covariance matrix for the
normal vectors? If so, use the Cholesky factorization method.
If V is your symmetric toeplitz matrix and it is k-by-k, say, and you want
to make n normal vectors of length k, then do this:
randn(n,k)*chol(V)
That produces n multivariate normal vectors of length k having the
variance-covariance structure V. You can also do this sort of thing:
randn(100,4)*chol(toeplitz([1 .5 .25 .125]'))
Check like so:
corrcoef(randn(10000,4)*chol(toeplitz([1 .5 .25 .125]')))
Mike
On Wed, 16 Jul 2003, Heber Farnsworth wrote:
> This is probably a simple question but I'm stumped and if someone knows
> the answer off the top of their head it would greatly speed up my code.
>
> I need to generate a large number of random (Gaussian) vectors that
> have an AR(1) correlation structure. Obviously I could do this in a
> loop but this is slow. I would rather rotate a vector of IID normal
> draws so that the result will have the right covariance matrix. So
> what I need is the matrix square root of a symmetric toeplitz matrix
>
> 1 .5 .25 .125 ...
> .5 1 .5 .25 ...
> .25 .5 1 .5 ...
>
> etc (here the correlation is .5). It seems inefficient to try to
> compute this square root numerically. Isn't it known in closed form?
>
> Heber Farnsworth
>
>
>
> -------------------------------------------------------------
> Octave is freely available under the terms of the GNU GPL.
>
> Octave's home on the web: http://www.octave.org
> How to fund new projects: http://www.octave.org/funding.html
> Subscription information: http://www.octave.org/archive.html
> -------------------------------------------------------------
>
-------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.
Octave's home on the web: http://www.octave.org
How to fund new projects: http://www.octave.org/funding.html
Subscription information: http://www.octave.org/archive.html
-------------------------------------------------------------