Dear Jian-Feng,

It's true that Jarrod's MCMCglmm package can fit spatial autoregressive models. But its functionality in that regard is limited. (Which is not a criticism, since he didn't write the package with the intention of using it for autoregressive models.) From the sounds of it, you would have better luck with the older nlme package, and its spatial corStruct classes. Another older thread addresses something similar: https://stat.ethz.ch/pipermail/r-help/2006-June/106994.html. Maybe the original poster for that thread will share the solution he found.

Hope that helps,
Malcolm


> Message: 4
> Date: Sun, 05 Jun 2011 09:37:33 +0100
> From: Jarrod Hadfield <j.hadfield@ed.ac.uk>
> To: Mao Jianfeng <jianfeng.mao@gmail.com>
> Cc: r-sig-mixed-models@r-project.org
> Subject: Re: [R-sig-ME] account for spatial autocorrelation in
> 	MCMCglmm modeling
> Message-ID: <20110605093733.17765czc1n9mxx8g@www.staffmail.ed.ac.uk>
> Content-Type: text/plain; charset=ISO-8859-1; DelSp="Yes";
> 	format="flowed"
> 
> Hi,
> 
> Fitting lon*lat in the random argument will not deal with  
> autocorrelation per se. A set of factors will be created for each  
> unique combination of lon/lat and any similarity of plants in these  
> 'grid squares' will be accounted for. Similarity of plants in  
> neighbouring 'grid squares' will not be modelled. If the lat/long  
> combinations are unique to plants then the effects are confounded with
> 
> MCMCglmm has no functionality for spatial autocorrelation structures,  
> although it seems the sir function can be used to fit some types of  
> spatial models, as indicated in the thread you cite. I implemented   
> sir models for an entirely different purpose so I am not very familiar  
> with their application in  spatial modelling. Malcolm may have better  
> advice, and also recommended Bivand (2009) "Fitting and interpreting  
> spatial regression models: an applied survey", which can be found  
> on-line and is an accessible read.
> 
> Cheers,
> 
> Jarrod
> 
> 
> 
> 
> 
> 
> Quoting Mao Jianfeng <jianfeng.mao@gmail.com> on Sun, 5 Jun 2011  
> 09:51:53 +0200:
> 
>> Dear all,
>> 
>> I would like to hear your advice/directions on how to account to spatial
>> autocorrelation in MCMCglmm modeling.
>> 
>> I have found a really good reference on that in a former R-sig-mixed thread:
>> (Another MCMCglmm question - fixing correlations)
>> https://stat.ethz.ch/pipermail/r-sig-mixed-models/2010q4/004940.html
>> But, I still can not implement it in my real study.
>> 
>> I am now asking a question of how additive genetic effect, population
>> structure, and environment can affect the phenotypic variations, by the data
>> measured/observed in >50 wild pine populations. You know, pine is plant, not
>> animal, they can not move by themselves. There should be some variance come
>> from geological autocorrelation (individuals are more near in geological
>> scale, they expressed more similar phenotype).
>> 
>> In the first run, I just expect the autocorrelation defined by longitude and
>> latitude. And, it may extent to be defined by longitude, latitude and
>> altitude. I do not know how to fix a MCMCglmm model accounting for such a
>> autocorrelation. Can it just be fixed as random effect of interaction
>> between longitude and latitude. Or is it necessary to use sir() function?
>> 
>> Could you please give any directions? I think this question may have general
>> interests for those who want to asking ecological/genetic question using
>> data from field.
>> 
>> Thanks in advance.
>> 
>> Best regards,
>> Jian-Feng,
>> 
>> 
>> Please see my problem in more detail as followings:
>> 
>> ########################
>> # my data (in dataframe, nypd.data),
>> response - conlen (cone length)
>> predictor - popcode (population code)
>>                 tree (tree code, there are 5 replicates for each tree)
>>                 Ped (pedigree, now I have not prepared it)
>> 
>> ########################
>> # the model without autocorrelation
>> prior1.1 <- list(G = list(G1 = list(V = 1,n=0.002),
>>                         G2=list(V=1, n=0.002)
>>                         #G3=list(V= matrix(con.var/4),n= 1)
>>                         #G4 = list(V = 1, n=0.002)
>>                         ),
>>                         R=list(V=1,n= 0.002))
>> cone.model1.1<-MCMCglmm(fix=conlen ~ 1,
>>                       random = ~ popcode + tree,
>>                       #pedigree = Ped,
>>                       data = nypd.data,
>>                       nitt=53000000,
>>                       thin=50000,
>>                       burnin=13000000,
>>                       prior = prior1.1, verbose = FALSE
>>                       )
>> 
>> ########################
>> # the model with autocorrelation be defined as random effect
>> prior1.2 <- (I am not clear how to specific this prior)
>> 
>> cone.model1.2<-MCMCglmm(fix=conlen ~ 1,
>>                       random = ~ popcode + tree + lon*lat,
>>                       #pedigree = Ped,
>>                       data = nypd.data,
>>                       nitt=53000000,
>>                       thin=50000,
>>                       burnin=13000000,
>>                       prior = prior1.4, verbose = FALSE
>>                       )
>> 
>> ########################
>> # the model with autocorrelation be defined by sir()
>> 
>> # I got error for this model:
>> 
>> Error in sir(~W, ~units) :
>>  sir formulae invalid: factor levels of intersecting variables have
>> to be the same
>> 
>> ### the model
>> W <- as.matrix(cbind(nypd.data$lon, nypd.data$lat))
>> 
>> prior1.9 <- list(G = list(G1 = list(V = 1,n=0.002),
>>                         G2=list(V=1, n=0.002)
>>                         #G3=list(V= matrix(con.var/4),n= 1)
>>                         #G4 = list(V = 1, n=0.002)
>>                         ),
>>                         R=list(V=1,n= 0.002))
>> cone.model1.9<-MCMCglmm(fix=conlen ~ 1 + sir(~W, ~units),
>>                       random = ~ popcode + tree,
>>                       #pedigree = Ped,
>>                       data = nypd.data,
>>                       nitt=53000000,
>>                       thin=50000,
>>                       burnin=13000000,
>>                       prior = prior1.9, verbose = FALSE
>>                       )
>> 
>> 	[[alternative HTML version deleted]]


	[[alternative HTML version deleted]]


