-----Oorspronkelijk bericht-----
Van: r-sig-mixed-models-bounces at r-project.org
[mailto:r-sig-mixed-models-bounces at r-project.org] Namens Helen Sofaer
Verzonden: dinsdag 19 oktober 2010 4:07
Aan: r-sig-mixed-models at r-project.org
Onderwerp: [R-sig-ME] deriv example for nlmer
Hello modelers,
I am working on a growth rate analysis in lme4, where my goal
is to test for differences in growth rates between two
populations of birds while incorporating random effects for
nests (to deal with the lack of independence between
siblings) and for each nestling (to deal with repeated
measures of individuals).
I'd like to build a model that is parameterized slightly
differently than the SSlogis self-starting model, where K =
1/scal (this is simply due to convention in the bird world).
I can tweak the SSlogis code (given in the help file for
selfStart) and the model runs, but cannot test for
differences between populations. Since determining reasonable
starting values is not a problem, and I'd like to be able to
easily adjust the formula to incorporate additional
covariates, I would like to avoid using a self-starting function.
It is my understanding that nlmer requires a function, but
not necessarily a self-starting one. However, I can't find an
example of any code that does this.
I can build a very simple function that allows for
differences between populations (referred to as site, which
is a 0 1 dummy variable) in both the inflection point (xmid)
and the growth rate (K). I'm trying to start with the
simplest reasonable model, so I didn't allow for differences
in the asymptote. This function works in nls:
logisKsite = function(Age, site, Asym, xmid, K, Kdiff, middiff){
Asym/(1 + exp((xmid+middiff*site - Age)*(K+Kdiff*site)))
}
startsite = c(Asym = 9, xmid = 3, K = .5, Kdiff=0, middiff=0)
nls_logisKsite = nls(weight ~ logisKsite(Age, site, Asym,
xmid, K, Kdiff, middiff), growth, start = startsite)
The nlmer model I am trying to run is (for simplicity, this
model includes only a random effect of nest, only on the K parameter):
nlmer_logisKsite = nlmer(weight ~ logisKsite(Age, site, Asym,
xmid, K, Kdiff, middiff) ~ (K | Nest_ID), growth, start =
startsite, verbose = TRUE)
Running this model in nlmer produces the error: gradient
attribute of evaluated model must be a numeric matrix Dr.
Bates' posted lectures note that the model must provide
derivatives, via the deriv function. I haven't been
successful getting this to work, even in the model without
site effects.
If there is an example of how to run nlmer without a
self-start function, could someone please point me to it?
Advise on how to implement the deriv function would also be
very helpful.
Thank you very much,
Helen
Helen Sofaer, PhD Candidate in Ecology, Colorado State University