[Rd] bug in nlme package function predict.lmList (PR#13788)
zemlys at gmail.com
zemlys at gmail.com
Tue Jun 30 09:20:09 CEST 2009
Full_Name: Vaidotas Zemlys
Version: 2.9.0
OS: Ubuntu 8.10
Submission from: (NULL) (213.197.173.50)
Steps to reproduce the bug:
library(nlme)
data(Oxboys)
qm=lmList(height~age|Subject,data=Oxboys)
grid=with(Oxboys,expand.grid(age=seq(min(age),max(age),length=50),Subject=levels(Subject)))
res <- predict(qm,grid,se=TRUE)
Erreur dans if (pool) { : l'argument est de longueur nulle
res <- predict(qm,grid,se=TRUE,pool=TRUE)
Erreur dans sprintf(gettext(fmt, domain = domain), ...) :
objet 'form' introuvable
The result: predicting does not work, when new data is supplied.
The problem is in the function predict.lmList. When argument newdata is not
NULL, argument subset is set to TRUE, and following code gets executed:
####Start of the relevant code snippet
if (!is.null(subset)) {
if (any(is.na(match(subset, names(object))))) {
stop("Non-existent group requested in \"subset\".")
}
oclass <- class(object)
oatt <- attr(object, "call")
object <- object[subset]
attr(object, "call") <- oatt
class(object) <- oclass
if (is.null(newdata)) {
myData <- myData[subset]
}
}
#####End of relevant code snippet
Only attribute call is saved from original object, but the following code
assumes that attributes groupsForm and pool are present, and when they are not
found, error is produced. The problem with missing pool attribute can be worked
arround by supplying it directly. But it is not possible to do that with
attribute groupsForm.
The patch which fixes this problem :
--- lmList.R 2008-02-11 16:05:14.000000000 +0200
+++ lmListnew.R 2009-06-30 09:49:21.000000000 +0300
@@ -853,9 +853,10 @@ predict.lmList <-
stop("Non-existent group requested in \"subset\".")
}
oclass <- class(object)
- oatt <- attr(object, "call")
+ oatt <- attributes(object)[c("call","groupsForm","pool")]
object <- object[subset]
- attr(object, "call") <- oatt
+ oatt <- c(attributes(object),oatt)
+ attributes(object) <- oatt
class(object) <- oclass
if(is.null(newdata)) {
myData <- myData[subset]
I did not do extensive tests, but it works with previous example and my own
datasets.
Here is the relevant information about R and nlme on my system:
> R.version
_
platform i486-pc-linux-gnu
arch i486
os linux-gnu
system i486, linux-gnu
status
major 2
minor 9.0
year 2009
month 04
day 17
svn rev 48333
language R
version.string R version 2.9.0 (2009-04-17)
> packageDescription("nlme")
Package: nlme
Version: 3.1-92
Date: 2009-05-22
Priority: recommended
Title: Linear and Nonlinear Mixed Effects Models
Author: Jose Pinheiro <Jose.Pinheiro at pharma.novartis.com>, Douglas
Bates <bates at stat.wisc.edu>, Saikat DebRoy
<saikat at stat.wisc.edu>, Deepayan Sarkar
<Deepayan.Sarkar at R-project.org>, the R Core team.
Maintainer: R-core <R-core at R-project.org>
Description: Fit and compare Gaussian linear and nonlinear
mixed-effects models.
Depends: graphics, stats, R (>= 2.4.0)
Imports: lattice
LazyLoad: yes
LazyData: yes
License: GPL (>= 2)
Packaged: 2009-05-23 16:39:47 UTC; ripley
Repository: CRAN
Date/Publication: 2009-05-24 08:46:01
Built: R 2.9.0; i486-pc-linux-gnu; 2009-06-30 06:00:47 UTC; unix
I did update.packages() before testing and reporting the bug.
I hope that this is correct place to report bug on package of R.
Vaidotas Zemlys
More information about the R-devel
mailing list