Grokbase Groups R r-sig-geo June 2011
FAQ
Dear Luca,

Are you looking for something like this?

N <- 300 # set the number of units
W <- matrix(rbinom(N^2, 1, 0.25), N, N)*upper.tri(matrix(1, N, N)) # build a connectivity matrix, randomly
W <- W + t(W) # make the connectivity matrix symmetrical
W <- W/apply(W, 1, sum) # row-standardise the connectivity matrix (make rows sum to 1)
rho <- 0.2 # set the level of autocorrelation
y <- solve(diag(N) - rho*W) %*% rnorm(N, 1, 1) # generate y data with mean 1, sd 1 (prior to "spatialisation")
library(spdep) # for lagarlm below
lagsarlm(y ~ 1, listw=mat2listw(W)) # check that parameters can be recovered (subject to random simulation error)

Cheers,
Malcolm


Date: Thu, 09 Jun 2011 12:28:52 +0200
From: Luca Morandini <luca.morandini1@gmail.com>
To: R-sig-geo <r-sig-geo@r-project.org>
Subject: [R-sig-Geo] Generating geo-statistical data
Message-ID: <4df0a064.8070505@gmail.com>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed

Folks,

I would like to generate, for educational purpose, data with a set level of
auto-correlation; that is, I would like to generate Zs that exhibit an higher
correlation with points that are closer to their locations.

One method I've found out in "Statistical methods for spatial data analysis" is
the use of convolutions (in the sense of "smoothers"), that is, to generate random
Zs and then compute Z2s as Z + (some weight based on neighbouring points).

Of curse this would work, but, ideally, I would like to set a level of
autocorrelation and then have a function generating data with (about) that
level... any suggestion ?

Regards,

Luca Morandini
http://www.lucamorandini.it

Search Discussions

Discussion Posts

Previous

Follow ups

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 2 of 3 | next ›
Discussion Overview
groupr-sig-geo @
categoriesr
postedJun 9, '11 at 10:28a
activeJun 13, '11 at 1:33p
posts3
users3
websiter-project.org
irc#r

People

Translate

site design / logo © 2022 Grokbase