[R-sig-ME] error when update() a LME-with correlated errors object
Christian Salas
christian.salas at yale.edu
Wed Apr 8 16:56:46 CEST 2009
Hi there
I cannot update a fitted LME-with spatially correlated errors object,
please check the example. Data from an R book, only 281 rows, the
provided code download the data from my website.
I use R 2.8.1 under linux-ubuntu, For this session i was using the
following packages
Package Version
1 nlme 3.1-90
2 datasets 2.8.1
3 MASS 7.2-46
4 utils 2.8.1
5 stats 2.8.1
6 graphics 2.8.1
7 grDevices 2.8.1
8 methods 2.8.1
9 base 2.8.1
The code!!
# Fitting a LME with correlated errors
# Example and data from Book: Bivand et al 2008 "Applied spatial
# data analysis with R"
###################################################
#example--------------------------------
#1. read data
#data from the book, i built the .csv file
dbase <-
read.csv(url("http://environment.yale.edu/salas/data/spatDataBivandetal08.csv"),
header = TRUE)
head(dbase)
dim(dbase)
#fit a linear model (just for fun)
nylm <- lm(Z~PEXPOSURE+PCTAGE65P+PCTOWNHOME, data=dbase)
summary(nylm)
#fit a mixed-effect model [p.288 of Bivand et al] with correlated
# errros depending on the distance between the centroids of the areas
library(nlme)
#specify correlation structure [also explained in Pinheiro&Bates, p.238]
sp1 <- corSpatial(1, form = ~ x + y, type = "gaussian")
scor<-Initialize(sp1, dbase[,c("x", "y")], nugget=FALSE)
#fit the LME with correlated errors
spmodel<-lme(Z~PEXPOSURE+PCTAGE65P+PCTOWNHOME,
random=~1|AREAKEY,
data=dbase, correlation=scor, method="ML")
summary(spmodel)
#the problem------------
#I want to fit the same mixed-effect model with correlated structure
# for a different havin n-i observations and of course the same columns
dbnew=dbase[-1,]
nrow(dbnew) #one less observation than before
#here is the error, or bug?
update(spmodel, data=dbnew) #here is the error!!!!!, why?
#after running this, appear a large message, summarized here
#
#*** glibc detected *** /usr/lib/R/bin/exec/R: free(): invalid next size
(normal): 0x0950f090 ***
#======= Backtrace: =========
#/lib/tls/i686/cmov/libc.so.6[0xb7b6e454]
#/lib/tls/i686/cmov/libc.so.6(cfree+0x96)[0xb7b704b6]
#b6ddb000-b6ddc000 r--p 00633000 08:05 1574
#Process R aborted at Mon Apr 6 09:12:41 2009
#I did also check this in a Windows OS, and I obtained the same problem.
#I did also check with an older version of nlme, and I obtained the same
#problem.
any suggestion?
thanks in advance
--
-------------------------------------------------------------------------------
Christian Salas E-mail:christian.salas at yale.edu
PhD candidate http://environment.yale.edu/salas
School of Forestry and Environmental Studies
Yale University Tel: +1-(203)-432 5126
360 Prospect St Fax:+1-(203)-432 3809
New Haven, CT 06511-2189 Office: Room 35, Marsh Hall
USA
Yale Biometrics Lab http://environment.yale.edu/biometrics
More information about the R-sig-mixed-models
mailing list