Thanks for your suggestion, Henrique

Here I attach a link to some notes by Robert Bivand, with a SAR model, see
page 30

www.bias-project.org.uk/ASDARcourse/unit6_slides.pdf

The difference with CAR is in the covariance structure, I run and example:

# ===============================================
library(spdep)
set.seed(987654)

# Columbus example in spdep library
example(columbus)
n <- length(col.gal.nb)
coords <- coordinates(columbus)
cards <- card(col.gal.nb)
col.w <- nb2listw(col.gal.nb)

uncorr_x <- rnorm(n)    # uncorrelated random variable

cor(uncorr_x, lag(col.w,uncorr_x)) # correlation

# ==============================
 rho <- .5     # spatial autocorrelation

# Case1: SAR

 IrW <- diag(n) - rho*listw2mat(col.w)         # I - rho * W

 SARcov <- solve(t(IrW) %*% IrW)
 SARcovL <- chol((SARcov + t(SARcov))/2)

autocorr_x <- t(SARcovL)%*%uncorr_x

cor(autocorr_x, lag(col.w,autocorr_x))       #
       [,1]
[1,] 0.3876456
# ==================================================

I've did the same but with CAR structure

   CARcov = solve(IrW) #  from  (I-rhoW)^ -1
   CARcovL = chol(CARcov)   # Cholesky Decomposition

a_x = t(CARcovL)%*%uncorr_x     #

cor(a_x,lag(col.W,a_x))

           [,1]
[1,] 0.06929324
# ==================================================

I don't know if I'm simulating correctly the CAR,

any help?

Thanks in advance



2008/2/15, Henrique Dallazuanna <wwwhsd@gmail.com>:
>
> See spautolm function in spdep package
>
> On 15/02/2008, Dae-Jin Lee <dae-jin.lee@uc3m.es> wrote:
> > Hi all !
> >
> >  I would like to simulate spatial lattice/areal data with a conditional
> >  autoregressive (CAR) structure, for a given neighbouring matrix and for
> a
> >  autocorrelation "rho".
> >
> >  Is there any package or function in R to perform it ?
> >
> >  I found the function "CARsimu" in the hdeco library, but this is not
> what
> >  I'm looking for
> >
> >  Thanks in advance
> >
> >  Dae-Jin
> >
> >  --
> >  __________________________________
> >
> >  Dae-Jin Lee
> >
> >  Office/Despacho: 7.3.J04
> >  Phone/Tlfno:+34 91 624 9175
> >  Fax: +34 91 624 9430
> >
> >  Departamento de Estadística
> >  Av. Universidad 30, Ed. Juan Benet
> >  28911 Leganés (Madrid), SPAIN
> >  Universidad Carlos III de Madrid
> >
> >  e-mail: dae-jin.lee@uc3m.es
> >    web: http://www.est.uc3m.es/daejin
> >  __________________________________
> >
> >         [[alternative HTML version deleted]]
> >
> >
> > ______________________________________________
> >  R-help@r-project.org mailing list
> >  https://stat.ethz.ch/mailman/listinfo/r-help
> >  PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> >  and provide commented, minimal, self-contained, reproducible code.
> >
> >
>
>
> --
> Henrique Dallazuanna
> Curitiba-Paraná-Brasil
> 25° 25' 40" S 49° 16' 22" O
>



-- 
__________________________________

Dae-Jin Lee

Office/Despacho: 7.3.J04
Phone/Tlfno:+34 91 624 9175
Fax: +34 91 624 9430

Departamento de Estadística
Av. Universidad 30, Ed. Juan Benet
28911 Leganés (Madrid), SPAIN
Universidad Carlos III de Madrid

e-mail: dae-jin.lee@uc3m.es
   web: http://www.est.uc3m.es/daejin
__________________________________

	[[alternative HTML version deleted]]

