[R] Re: creating new varFunc classes in nlme .. error: "Don't know how to get coefficients for .. object"
J
josh8912 at yahoo.com
Sun Oct 3 14:42:11 CEST 2004
Ah!! After way too many hours of work Ive answered my
own question. To get varExp2, a copy of varExp, to
work as a new varFunc, one needs to use this sort of
syntax:
update.varExp2 <- function (object, data, ...)
{
print ("enter update")
val <- NextMethod()
if (length(val) == 0) {
aux <- coef(val, allCoef = TRUE)
if (!is.null(grps <- getGroups(val))) {
aux <- aux[grps]
}
attr(val, "logLik") <- sum(log(attr(val,
"weights") <- exp(-aux *
getCovariate(val))))
}
val
}
setMethod("update", "varExp2", update.varExp2)
And then do the same for all methods used by varExp
(see methods(class="varExp")). When writing the
setMethod for coef<-.varExp2, use
cat("coef<-.varExp2") in the statement. Or at least
that worked for me.
But I still have an unanswered question from the other
day (see [R] two questions on nlme: error messages and
nested variance). What is the best way in nlme to
model the variance when the variance of the variance
is not constant but is dependent on a covariate?
Thanks. John
More information about the R-help
mailing list