[R] Error in nlme with factors in R 2.4.1
Christian Ritz
ritz at kvl.dk
Tue Mar 20 14:55:38 CET 2007
Hi,
the following R lines work fine in R 2.4.0, but not in R 2.4.1 or any devel versions of R
2.5.0 (see below for details).
library(drc) # to load the dataset 'PestSci'
library(nlme)
## Setting starting values
sv <- c(0.43355869, 2.49963220, 0.05861799, 1.73290589, 0.38153146, 0.24316978)
## No error
m1 <-
nlme(SLOPE ~ c + (d-c)/(1+exp(b*(log(DOSE)-log(e)))),
fixed = list(b+c+d+e~1),
random = d~1|CURVE,
start = sv[c(2:5)], data = PestSci)
## No error
m2 <- nlme(SLOPE ~ c + (d-c)/(1+exp(b*(log(DOSE)-log(e)))),
fixed = list(b~HERBICIDE, c+d+e~1),
random = d~1|CURVE,
start = sv[c(1:5)], data = PestSci)
## Error in R 2.4.1!
m3 <-
nlme(SLOPE ~ c + (d-c)/(1+exp(b*(log(DOSE)-log(e)))),
fixed = list(b~factor(HERBICIDE)-1, c~1, d~1, e~factor(HERBICIDE)-1),
random = d~1|CURVE,
start = sv, data = PestSci)
Error in dimnames(data) <- dimnames : length of 'dimnames' [1] not equal to array extent
An ensuing call to traceback() yields:
7: array(0, c(n, n), list(levs, levs))
6: contr.treatment(n = 0)
5: do.call(contr[[nm]], list(n = length(levs)))
4: FUN("factor(HERBICIDE)"[[1]], ...)
3: lapply(nms, contrMat, contr = contr, data = dataMix)
2: nlme.formula(SLOPE ~ c + (d - c)/(1 + exp(b * (log(DOSE) - log(e)))),
fixed = list(b ~ factor(HERBICIDE) - 1, c ~ 1, d ~ 1, e ~
factor(HERBICIDE) - 1), random = d ~ 1 | CURVE, start = sv,
data = PestSci)
1: nlme(SLOPE ~ c + (d - c)/(1 + exp(b * (log(DOSE) - log(e)))),
fixed = list(b ~ factor(HERBICIDE) - 1, c ~ 1, d ~ 1, e ~
factor(HERBICIDE) - 1), random = d ~ 1 | CURVE, start = sv,
data = PestSci)
Output from sessionInfo() for R 2.4.0
R version 2.4.0 (2006-10-03)
i386-pc-mingw32
locale:
LC_COLLATE=Danish_Denmark.1252;LC_CTYPE=Danish_Denmark.1252;LC_MONETARY=Danish_Denmark.1252;LC_NUMERIC=C;LC_TIME=Danish_Denmark.1252
attached base packages:
[1] "methods" "stats" "graphics" "grDevices" "utils" "datasets"
[7] "base"
other attached packages:
drc plotrix nlme MASS lattice
"1.0-7" "2.1-1" "3.1-77" "7.2-29" "0.14-9"
Output from sessionInfo() for R 2.4.1
R version 2.4.1 (2006-12-18)
i386-pc-mingw32
locale:
LC_COLLATE=Danish_Denmark.1252;LC_CTYPE=Danish_Denmark.1252;LC_MONETARY=Danish_Denmark.1252;LC_NUMERIC=C;LC_TIME=Danish_Denmark.1252
attached base packages:
[1] "stats" "graphics" "grDevices" "utils"
[5] "datasets" "methods" "base"
other attached packages:
drc plotrix nlme MASS lattice
"1.0-7" "2.1-6" "3.1-78" "7.2-30" "0.14-16"
Christian
More information about the R-help
mailing list