On 08.02.2012 19:32, Journals wrote:
I run into a slight syntax proble while using nls that seems to require
some advice from the R community

I have a nonlinear regression problem where I observe the sum of the
responses (y) of many individuals (X1 .... Xn). The properties (x1..xn)
of these individuals have been measured but since the response is
nonlinear I cannot use a mean individual to estimate the mean response
of a population. But I have reasonable reasons to assume that all
individuals are responding in the same way.

In other words I want to estimate a function as in the last row of the
example below. (Note, this is an artificial example and it does not
converge (appart from having to few observations).

data<-as.data.frame(matrix(c(1,2,3,4,5,6,7,7,9,0,1,2,3,4,6, 9), nrow=4,
ncol=4))
colnames(data)<-c("y","x1","x2","x3")

nonlin<-nls(y~a*(exp(b*x1)+exp(b*x2)+exp(b*x3))+c, start=list(a=1, b=2,
c=3),
data=data)

Now my problem is that I have 500 different x variables (x1 .... x500)
for each y variable (and a few thousand of y observations) and I am
stuck with the syntax problem of how to pass this as a formula to nls.
Is there any way to define a formula that is passed to nls that would
take an array of x values.

You can construct a formula programmatically (as.formula on a string generated by paste, for example), but I doubt you will manage to estimate a nonlinear model with 500 variables easily (!) ....

Uwe Ligges



Cheers Frank

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to