Re: [R] nls fits by groups

2007-09-24 Thread Aleksi Lehtonen
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)

Re: [R] nls fits by groups

2007-09-23 Thread Christian Ritz
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

Re: [R] nls fits by groups

2007-09-23 Thread Ken Knoblauch
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

Re: [R] nls fits by groups

2007-09-23 Thread Gabor Grothendieck
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

Re: [R] nls fits by groups

2007-09-23 Thread Katharine Mullen
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

[R] nls fits by groups

2007-09-23 Thread Aleksi Lehtonen
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