[R] indexing a parameter in nls
john_hendrickx at yahoo.com
Thu Jul 15 14:02:31 CEST 2004
I'm trying to estimate a "diagonal reference model" in nls. In its
basic form, the model consists of two factors with equal categories
and a dependent variable. The model fits the main effects of the two
factors such that they are proportional to each other. So the model I
want to fit is:
The m-parameters indicate the "average" main effect of factors f1 and
f2 (with no intercept). The p-parameter indicates the relative impact
of the two factors on Y. If p=.5, f1 and f2 have equal impact, for
p>.5, f1 has greater impact, for p<.5 f2 has greater impact.
I can estimate the model as follows for f1="row", f2="col",
What I want however, is a more compact specification, where "row" and
"col" are used to index which m-parameter should be used, something
This specification produces an error: "Error in nlsModel(formula, mf,
start) : singular gradient matrix at initial parameter estimates". I
suspect the problem is that "strt[row]" evaluates to a list of
starting values rather than the object names m1, m2, etc. I've tried
But this produces an error as well: "Error in qr.qty(QR, resid) : qr
and y must have the same number of rows"
Can anyone point me in the right direction? How can I use "row" and
"col" to index the appropriate "m" parameter in this model?
More information about the R-help