[R-sig-ME] nlmer error: ...coercing "labelled" to "CsparseMatrix"
Andrew Beckerman
a.beckerman at sheffield.ac.uk
Wed Jul 15 15:14:05 CEST 2009
Dear list -
R 2.9.1, OSX
I am trying to re-fit an old nlme model of mine using nlmer, but
getting an error about labels and the CsparseMatrix.
The data are in the following form
> head(induct)
clone id trt ind ind.adj
1 barney 0.1a1 0.1 30 21.42858
2 barney 0.1a2 0.1 65 46.42858
3 barney 0.1a3 0.1 30 21.42858
4 barney 0.1a4 0.1 60 42.85715
5 barney 0.1a5 0.1 70 50.00001
6 barney 0.1b1 0.1 60 42.85715
The nlme model was fit via the following, which works well:
#grouped data
gd1<-groupedData(ind.adj~trt|clone,data=induct)
# SS starting values
Asym<-50
xmid<-0.25
scale<-1
induction<-nlsList(ind.adj~SSlogis(trt,Asym,xmid,scale)|clone,gd1)
nlc <- nlmeControl(maxIter = 25)
m1<-nlme(induction,random=pdDiag(Asym+xmid+scale~1),control=nlc)
My attempt at fitting with nlmer, ignoring the groupedData object,
with a single random effect in the Asymptote and with nlme detached, is:
induction.lme4<-nlmer(ind.adj~SSlogis(trt,Asym,xmid,scal)~Asym|clone,
data=induct,
start=c(Asym=50,xmid=0.25,scal=1))
Which is resulting in the following error message and traceback. Any
insight, or requests for more of the data graciously accepted.
> induction.lme4<-nlmer(ind.adj~SSlogis(trt,Asym,xmid,scal)~Asym|
clone,data=induct,start=c(Asym=50,xmid=0.25,scal=1))
Error in as(from, "CsparseMatrix") :
no method or default for coercing "labelled" to "CsparseMatrix"
> traceback()
8: stop(gettextf("no method or default for coercing \"%s\" to \"%s\"",
thisClass, Class), domain = NA)
7: as(from, "CsparseMatrix")
6: asMethod(object)
5: as(ff, "sparseMatrix")
4: FUN(X[[1L]], ...)
3: lapply(bars, function(x) {
ff <- eval(substitute(as.factor(fac)[, drop = TRUE], list(fac
= x[[3]])),
mf)
im <- as(ff, "sparseMatrix")
if (!isTRUE(validObject(im, test = TRUE)))
stop("invalid conditioning factor in random effect: ",
format(x[[3]]))
mm <- model.matrix(eval(substitute(~expr, list(expr = x[[2]]))),
mf)
if (rmInt) {
if (is.na(icol <- match("(Intercept)", colnames(mm))))
break
if (ncol(mm) < 2)
stop("lhs of a random-effects term cannot be an
intercept only")
mm <- mm[, -icol, drop = FALSE]
}
ans <- list(f = ff, A = do.call(rBind, lapply(seq_len(ncol(mm)),
function(j) im)), Zt = do.call(rBind,
lapply(seq_len(ncol(mm)),
function(j) {
im at x <- mm[, j]
im
})), ST = matrix(0, ncol(mm), ncol(mm), dimnames =
list(colnames(mm),
colnames(mm))))
if (drop) {
ans$A at x <- rep(0, length(ans$A at x))
ans$Zt <- drop0(ans$Zt)
}
ans
})
2: lmerFactorList(substitute(foo ~ bar, list(foo = nlform[[2]],
bar = formula[[3]])), fr, TRUE, TRUE)
1: nlmer(ind.adj ~ SSlogis(trt, Asym, xmid, scal) ~ Asym | clone,
data = induct, start = c(Asym = 50, xmid = 0.25, scal = 1))
---------------------------------------------------------------------------------
Dr. Andrew Beckerman
Department of Animal and Plant Sciences, University of Sheffield,
Alfred Denny Building, Western Bank, Sheffield S10 2TN, UK
ph +44 (0)114 222 0026; fx +44 (0)114 222 0002
http://www.beckslab.staff.shef.ac.uk/
http://www.flickr.com/photos/apbeckerman/
http://www.warblefly.co.uk
More information about the R-sig-mixed-models
mailing list