Notice: On March 31, it was **announced** that Statalist is moving from an email list to a **forum**. The old list will shut down on April 23, and its replacement, **statalist.org** is already up and running.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

From |
"Lachenbruch, Peter" <Peter.Lachenbruch@oregonstate.edu> |

To |
"statalist@hsphsun2.harvard.edu" <statalist@hsphsun2.harvard.edu> |

Subject |
RE: st: RE: RE: creating AR(1) correlation matrix |

Date |
Thu, 16 May 2013 16:47:44 +0000 |

works beautifully. Thanks. Peter A. Lachenbruch, Professor (retired) ________________________________________ From: owner-statalist@hsphsun2.harvard.edu [owner-statalist@hsphsun2.harvard.edu] on behalf of Federico Belotti [f.belotti@gmail.com] Sent: Thursday, May 16, 2013 9:17 AM To: statalist@hsphsun2.harvard.edu Subject: Re: st: RE: RE: creating AR(1) correlation matrix You can easily include the mata code into a do file, convert the mata matrix to Stata and use it as an argument of -drawnorm- local n 1000 local rho 0.9 local dim 10 mata: rho = `rho' mata: dim = `dim' mata: Lambda = I(dim) mata: Lambda = rho:^abs(J(1,dim,(1::dim))-J(dim,1,(1..dim))) mata: st_matrix("Lambda", Lambda) local xs forvalues i=1/`dim' { local xs "`xs' x`i'" } clear set obs `n' drawnorm `xs', corr(Lambda) n(`n') corr x* sum x* HTH Federico On May 16, 2013, at 6:01 PM, Lachenbruch, Peter wrote: > I need to generate the correlation matrix for input to drawnorm, so this isn't quite what i need. Thanks for the help > > Peter A. Lachenbruch, > Professor (retired) > ________________________________________ > From: owner-statalist@hsphsun2.harvard.edu [owner-statalist@hsphsun2.harvard.edu] on behalf of Jacobs, David [jacobs.184@sociology.osu.edu] > Sent: Thursday, May 16, 2013 8:13 AM > To: 'statalist@hsphsun2.harvard.edu' > Subject: st: RE: creating AR(1) correlation matrix > > A quick and maybe dirty way to do this is to run a population averaged, panel regression model with an AR1 term if that's appropriate. > > Then type -xtcorr- (there's a newer command but xtcorr still works at least in version 11). You'll probably get the correlation matrix used to compute the AR1 correction. I say probably because the matrix you want may be too large for this option. > > Dave Jacobs > > -----Original Message----- > From: owner-statalist@hsphsun2.harvard.edu [mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of Lachenbruch, Peter > Sent: Thursday, May 16, 2013 10:59 AM > To: statalist@hsphsun2.harvard.edu > Subject: st: creating AR(1) correlation matrix > > I need to create a correlatoin matrix of rho^(i-j) where i and j are row and column indexes. Is there a simple command in Stata that will do htis? I can do it in a foreach loop (although i've been messing it up so far). This is for a simulation and the dimension of the correlation is 50 or 100 so i don't want to do it manually. > > > Peter A. Lachenbruch, > Professor (retired) > * > * For searches and help try: > * http://www.stata.com/help.cgi?search > * http://www.stata.com/support/faqs/resources/statalist-faq/ > * http://www.ats.ucla.edu/stat/stata/ > > * > * For searches and help try: > * http://www.stata.com/help.cgi?search > * http://www.stata.com/support/faqs/resources/statalist-faq/ > * http://www.ats.ucla.edu/stat/stata/ > * > * For searches and help try: > * http://www.stata.com/help.cgi?search > * http://www.stata.com/support/faqs/resources/statalist-faq/ > * http://www.ats.ucla.edu/stat/stata/ -- Federico Belotti, PhD Research Fellow Centre for Economics and International Studies University of Rome Tor Vergata tel/fax: +39 06 7259 5627 e-mail: federico.belotti@uniroma2.it web: http://www.econometrics.it * * For searches and help try: * http://www.stata.com/help.cgi?search * http://www.stata.com/support/faqs/resources/statalist-faq/ * http://www.ats.ucla.edu/stat/stata/ * * For searches and help try: * http://www.stata.com/help.cgi?search * http://www.stata.com/support/faqs/resources/statalist-faq/ * http://www.ats.ucla.edu/stat/stata/

**References**:**st: creating AR(1) correlation matrix***From:*"Lachenbruch, Peter" <Peter.Lachenbruch@oregonstate.edu>

**st: RE: creating AR(1) correlation matrix***From:*"Jacobs, David" <jacobs.184@sociology.osu.edu>

**st: RE: RE: creating AR(1) correlation matrix***From:*"Lachenbruch, Peter" <Peter.Lachenbruch@oregonstate.edu>

**Re: st: RE: RE: creating AR(1) correlation matrix***From:*Federico Belotti <f.belotti@gmail.com>

- Prev by Date:
**st: suest after svy:clogit** - Next by Date:
**st: adding names of instruments with esttab/estout** - Previous by thread:
**Re: st: RE: RE: creating AR(1) correlation matrix** - Next by thread:
**Re: st: creating AR(1) correlation matrix** - Index(es):