Dear Katharine,
that for loop solved all my problems, I just added subset=group==i to
the nls statement.
thank you, Aleksi
Katharine Mullen wrote:
> It is not clear from your post what changes per-group. If only the
> starting values change (but the data and the model structure are the
> same)
Dear Aleksi,
there are other approaches you could consider: using nls or gnls (in the
package nlme):
m1 <- nls(y ~ a[group]*x^b[group], start=list(a=c(1, ..., 1), b=c(1, ..., 1)))
or
m2 <- gnls(rate ~ a*x^b, params=list(a~group-1, b~group-1),
start=list(a=c(1, ..., 1), b=c(1, ..., 1)))
In
Aleksi Lehtonen gmail.com> writes:
> I am trying to estimate several non-linear models simultaneously. I don't
> want to use non-linear mixed model, but non-linear model with same form, but
> it should be estimated separately according to variable group (I have lots
> of groups that have lots of
Check out the subset= argument to nls, e.g. to regress Sepal.Length
on Sepal.Width separately for each Species using the built in iris data set:
f <- function(s) nls(Sepal.Length ~ a*Sepal.Width, data = iris,
start = c(a = 1), subset = iris$Species == s)
sapply(levels(iris$Species), f, simplify
It is not clear from your post what changes per-group. If only the
starting values change (but the data and the model structure are the
same), then you can just store the starting values you want to use for
each group in a list, and then index into this list in your call to nls.
e.g., modifying a
Dear Colleagues,
I am trying to estimate several non-linear models simultaneously. I don't
want to use non-linear mixed model, but non-linear model with same form, but
it should be estimated separately according to variable group (I have lots
of groups that have lots of observations). I would
6 matches
Mail list logo