[R] nlme and spatially correlated errors

Spencer Graves spencer.graves at pdf.com
Sun Jul 17 03:22:04 CEST 2005


	  Have you tried "anova(fit1, fit2)", where

	  fit1 <- lme(one model...)
	  fit2 <- lme(a submodel ... )

This "anova" does about the best that anyone knows how to do -- or at 
lest did 7 years ago when it was written.  If the "submodel" changes the 
fixed effects, you should use "method='ML'".  If the "submodel" changes 
the noise model specification, use "method='REML'".  See Pinheiro and 
Bates (2000) Mixed-Effect Models in S and S-Plus (Springer).  If you 
need something more precise than the standard approximations, try 
"simulate.lme".

	  buena suerte!
	  spencer graves


Patricia Balvanera wrote:

> Dear R users,
> 
> I am using lme and nlme to account for spatially correlated errors as 
> random effects. My basic question is about being able to correct F, p, R2 
> and parameters of models that do not take into account the nature of such 
> errors using gls, glm or nlm and replace them for new F, p, R2 and 
> parameters using lme and nlme as random effects.
> 
> I am studying distribution patterns of 50 tree species along a gradient. 
> That gradient
> was sampled through 27 transects, with 10 plots within each transect. For 
> each plot I
> have data on presence/absence, abundance and basal area of the species. I 
> also have data
> for 4 environmental variables related to water availability (soil water 
> retention
> capacity, slope, insolation, altitude) and X and Y coordinates for each 
> plot. I explored
> wether the relationship between any of the response variables 
> (presence/absence,
> abundance, basal area) and the environmental variables was linear, 
> polinomial, or
> non-linear.
> 
> My main interest in this question is that I proceeded to correct for spatial
> autocorrelation (both within transects and overall) following the 
> procedures suggest by
> Crawley 2002 for linear models
> e.g. (GUAMAC = a species, CRAS = soil water retention capacity, TRANSECTO = 
> transect)
>  > model1<-gls(GUAMAC ~ CRAS)
>  > model2<-lme(GUAMAC ~ CRAS, random = ~ 1 | TRANSECTO)
>  > model3<-lme(GUAMAC ~ CRAS, random = GUAMAC ~ CRAS | TRANSECTO)
>  > model4<-lme(GUAMAC ~ CRAS, random = GUAMAC ~ CRAS -1 | TRANSECTO)
>  > AIC(model1,model2,model3,model4)
> df AIC
> model1 3 3730.537
> model2 4 3698.849
> model3 6 3702.408
> model4 4 3704.722
>  > plot(Variogram(model2, form = ~ X + Y))
>  > model5<-update(model2,corr=corSpher(c(30,0.8), form = ~ X + Y, nugget = T))
>  > plot(Variogram(modelo7, resType = "n"))
>  > summary(model5)
> 
> In this case I obtain new F for the independent variable INSOLACION, new R2 
> for the whole model and new parameters for the linear model.
> 
> I have also applied this procedure to polinomial models and to glms with 
> binomial errors
> (presence/absence) with no problem.
> 
> I am nevertheless stuck with non-linear models. I am using the protocols 
> you suggested
> in the 1998 manuals by Pinheiro and Bates, and those suggested by Crawley 
> 2002.
> Please find enclose an example with an
> exponential model (which I chose for being simple). In fact the linear 
> models I am using
> are a bit more complicated.
> (HELLOT is a species, INSOLACION = INSOLATION, basal = basal area of the 
> species, TRANSECTO = transect)
> 
>  > HELLOT ~ exp(A + (B * INSOLACION))
>  > basal.HELLOT <-function(A,B,INSOLACION) exp(A + (B * INSOLACION))
>  > HELLOT ~ basal.HELLOT(A,B,INSOLACION)
>  > basal.HELLOT<- deriv(~ exp(A + (B * INSOLACION))
> + , LETTERS [1:2], function(A, B, INSOLACION){})
>  > model1<- nlme(model = HELLOT ~ exp(A + (B * INSOLACION)), fixed = A + B 
> ~ 1,
> random = A + B ~ 1, groups = ~ TRANSECTO, start = list(fixed = c(5.23, -0.05)))
> 
> It runs perfectly and gives new values for parameters A and B, but would 
> only give me F for fixed effects of A and B, while what I am really looking 
> for is F for fixed effects of INSOLACION and the R2 of the new model.
> 
> Thank you so much in advance for your help
> 
> 
> 
> Dra. Patricia Balvanera
> Centro de Investigaciones en Ecosistemas, UNAM-Campus Morelia
> Apdo. Postal 27-3, Xangari
> 58090 Morelia, Michoacán, Mexico
> Tel. (52-443)3-22-27-07, (52-55) 56-23-27-07
> FAX (52-443) 3-22-27-19, (52-55) 56-23-27-19
> 
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

-- 
Spencer Graves, PhD
Senior Development Engineer
PDF Solutions, Inc.
333 West San Carlos Street Suite 700
San Jose, CA 95110, USA

spencer.graves at pdf.com
www.pdf.com <http://www.pdf.com>
Tel:  408-938-4420
Fax: 408-280-7915




More information about the R-help mailing list