# Fwd: Fwd: Fwd: st: Monte Carlo with preset spatial autocorrelation

 From "Susan Olivia" To statalist@hsphsun2.harvard.edu Subject Fwd: Fwd: Fwd: st: Monte Carlo with preset spatial autocorrelation Date Tue, 12 May 2009 10:07:29 -0700

```Dear Austin,

Thanks for the programming advice. Sorry I should have been
more explicit earlier. I am newbie to programming.

I would like to run a simulation, in which the only variable
that changes in each experiment is the dependent variable
(Y). I would like Y to be distributed as a normal random
variable with mean X*beta and variance of say 25.

Y is then calculated as Y = X*beta + u where u =
inverse[(I-lambda*W)]*eps. Eps is drawn from a normal
distribution with mean zero and variance say 25, I is the
identity matrix and lambda is the spatial autocorrelation
parameter which has been estimated earlier and W is the
weighting matrix.

For illustration, here's 5x5 binary weighting matrix:

matrix input W =
(0,1,0,0,0\1,0,1,0,0\0,1,0,1,0\0,0,1,0,1\0,0,0,1,0)

Susan
---------- Forwarded message ----------
From: Austin Nichols <austinnichols@gmail.com>
Date: Mon, May 11, 2009 at 2:05 PM
Subject: Re: Fwd: st: Monte Carlo with preset spatial
autocorrelation To: statalist@hsphsun2.harvard.edu

Susan Olivia <olivia@primal.ucdavis.edu>:
Yes, I gathered you had a weight matrix, but what is it?
Here's an example with an identity matrix which trivially
of the 200 obs created are neighbors):

mat c=I(200)
drawnorm v1-v200, corr(c) n(1) seed(1) clear
g i=_n
qui reshape long v, i(i)
keep v

Obviously, this is a silly example, since -drawnorm v,
n(200)- would get there in one; but a different matrix c
will produce data with very different properties. You also
don't specify if the simulated data are supposed to be
normal, or exhibit any particular properties.  You won't get
much programming advice unless you can specify a particular
problem, with details...

On Mon, May 11, 2009 at 4:30 PM, Susan Olivia
<olivia@primal.ucdavis.edu> wrote:
> Thanks Austin.
>
> Glad to know that it's feasible to do this.
>
> My pre-determined weighting matrix will be an nxn positive
> symmetric matrix in which for non-neighbors, w[i,j]= 0
while > w[i,j]=1 or a function of inverse distance w[i,j] =
1/d[i,j] > for neighbors, where d[i,j] is the distance
between > observation i and j.
>
>
> Susan
>
>
>
>
>> ---------- Forwarded message ----------
>> From: Austin Nichols <austinnichols@gmail.com>
>> Date: Mon, May 11, 2009 at 12:49 PM
>> Subject: Re: st: Monte Carlo with preset spatial
>> autocorrelation To: statalist@hsphsun2.harvard.edu
>>
>>
>> Susan Olivia <olivia@primal.ucdavis.edu>:
>> Note that the top of that page says the "FAQ is for users
>> of Stata 6, an older version of Stata. It is not relevant
>> modern equivalent.  If you can give the relevant matrix
of >> correlations or covariances, the rest is easy.  What
does >> your "pre-determined weighting matrix" look like?
>>
>> On Mon, May 11, 2009 at 3:39 PM, Susan Olivia
>> <olivia@primal.ucdavis.edu> wrote:
>> > Dear Stata list,
>> >
>> > I am wondering whether it is possible to generate
>> > artificial data with a given strength of spatial
>> > autocorrelation (for a pre-determined weighting
matrix)? >> >
>> > I found on the STATA archive that Bill Gould wrote some
>> > code about generating a random variable with a given
>> > correlation structure. Here's the url:
>> >
>> > http://www.stata.com/support/faqs/stat/mvnorm.html
>> >
>> > But to do this in a spatial context would seem to be
>> > more complicated given that the spatial autocorrelation
>> > will depend not not only on the own and neighboring
>> > values, but also how far apart they are place.
>> >
>> > If I can get any programming tips on this, much
>> appreciated. >
>> > Thanks,
>> >
>> > Susan
>> *

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/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/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/
```