|
Hola!
plot( augPred(papas2.nlme.5), layout=c(5,5,6) ) Error in
predict.nlme(object, value[1:(nrow(value)/nL), , drop = FALSE], :
Levels 1,2,3,4,5 not
allowed for medio
plot( augPred(papas2.nlme.2), layout=c(5,5,6)
) ... succeeds
plot( augPred(papas2.nlme.2,level=0:1), layout=c(5,5,6)
) ... succeeds
> plot( augPred(papas2.nlme.3), layout=c(5,5,6) ) Error in
predict.nlme(object, value[1:(nrow(value)/nL), , drop = FALSE], :
Levels 1,2,3,4,5 not
allowed for medio > plot( augPred(papas2.nlme.4), layout=c(5,5,6)
) Error in predict.nlme(object, value[1:(nrow(value)/nL), , drop =
FALSE], : Levels
1,2,3,4,5 not allowed for medio
The difference between the object papas2.nlme.2 where it succeeds
and papas2.nlme.3, papas2.nlme.4, papas2.nlme.5 where it not, is that
in the last objects the argument fixed to nlme models the parameters
as regressions on covariables (factors), while in the first object the
parametrs have only an intercept. The covariables are constant in each
group (plant), so the augPred plot seems to make sense, no averaging
should be necessary.
An excerpt from debug(predict.nlme) follows:
> plot( augPred(papas2.nlme.5), layout=c(5,5,6) ) debugging in:
predict.nlme(object, value[1:(nrow(value)/nL), , drop = FALSE],
. . .
debug: revOrder <- match(origOrder,
row.names(dataMix)) Browse[1]> n debug: contr <-
object$contrasts Browse[1]> n debug: for (i in names(dataMix))
{ if (inherits(dataMix[, i], "factor") &&
!is.null(contr[[i]])) { levs
<- levels(dataMix[, i])
levsC <-
dimnames(contr[[i]])[[1]] if
(any(wch <- is.na(match(levs, levsC))))
{
stop(paste("Levels", paste(levs[wch], collapse = ","),
"not allowed for", i))
} attr(dataMix[, i],
"contrasts") <- contr[[i]][levs, ,
drop = FALSE] } } Browse[1]>
contr $medio [1] "contr.treatment"
$variedad [1] "contr.treatment"
# contr have names of functions supposed to construct contrast
matrices.
Browse[1]> dimnames(contr[["medio"]]) NULL Browse[1]>
n debug: i Browse[1]> n debug: if (inherits(dataMix[, i],
"factor") && !is.null(contr[[i]])) { levs
<- levels(dataMix[, i]) levsC <-
dimnames(contr[[i]])[[1]] if (any(wch <-
is.na(match(levs, levsC)))) {
# the code seems to assume that contr has the actual contrast
matrix!
stop(paste("Levels",
paste(levs[wch], collapse = ","),
"not allowed for", i)) }
attr(dataMix[, i], "contrasts") <- contr[[i]][levs, , drop =
FALSE] } . . . .
debug: levs <- levels(dataMix[, i]) Browse[1]> n debug:
levsC <- dimnames(contr[[i]])[[1]] Browse[1]> levs [1] "1" "2"
"3" "4" "5" Browse[1]> n debug: if (any(wch <-
is.na(match(levs, levsC)))) { stop(paste("Levels",
paste(levs[wch], collapse = ","), "not allowed for",
i)) } Browse[1]>
n debug: stop(paste("Levels", paste(levs[wch], collapse = ","), "not
allowed for", i)) Browse[1]> n Error in
predict.nlme(object, value[1:(nrow(value)/nL), , drop = FALSE], :
Levels 1,2,3,4,5 not
allowed for medio
# because dimnames of "contr.treatment" is NULL!
Kjetil Halvorsen
|