Dear R-users, I am trying to create a model using the NLS function, such that: Y = f(X) + q + e Where f is a nonlinear (Weibull: a*(1-exp(-b*X^c)) function of X and q is a covariate (continous variable) and e is an error term. I know that you can create multiple nonlinear regressions where x is polynomial for example, but is it possible to do this kind of thing when x is a function with unknown coefficients (a,b,c)? Ultimately, I am expecting the output to give individual regression models for each coefficient (a,b,c) with q as a covariate. I have tried the following code, and get the resultant error messages:> weib.nls <- nls(Y ~ (a*(1-exp(-b*X^c)))|q, > + data=DATA, > + start=c(a=75,b=0.05,c=0.7)) > Error in nlsModel(formula, mf, start, wts) : > singular gradient matrix at initial parameter estimates > > summary(weib.nls)> > weib.nls2 <- nls(Y~ (a*(1-exp(-b*X^c)))+q, > + data=DATA, > + start=c(a=75,b=0.05,c=0.7)) > Error in numericDeriv(form[[3L]], names(ind), env) : > Missing value or an infinity produced when evaluating the model >Many thanks in advance! Lindsay
I think you need to consult a local statistician, as you appear to be so far out of your depth statistically that even the best-intentioned help from this list may not suffice. For example, if I were that local statistician, I would ask: what is the context? -- what is the underlying scientific issue that led to this model? -- what are the data? -- etc. etc. before I would even hazard advice on the statistical details(Please do not answer these questions either publicly or privately, as they are just fyi's). Bert Gunter Genentech Nonclinical Biostatisics -----Original Message----- From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] On Behalf Of Lindsay Banin Sent: Tuesday, August 25, 2009 9:02 AM To: 'r-help at r-project.org' Subject: [R] Covariates in NLS (Multiple nonlinear regression) Dear R-users, I am trying to create a model using the NLS function, such that: Y = f(X) + q + e Where f is a nonlinear (Weibull: a*(1-exp(-b*X^c)) function of X and q is a covariate (continous variable) and e is an error term. I know that you can create multiple nonlinear regressions where x is polynomial for example, but is it possible to do this kind of thing when x is a function with unknown coefficients (a,b,c)? Ultimately, I am expecting the output to give individual regression models for each coefficient (a,b,c) with q as a covariate. I have tried the following code, and get the resultant error messages:> weib.nls <- nls(Y ~ (a*(1-exp(-b*X^c)))|q, > + data=DATA, > + start=c(a=75,b=0.05,c=0.7)) > Error in nlsModel(formula, mf, start, wts) : > singular gradient matrix at initial parameter estimates > > summary(weib.nls)> > weib.nls2 <- nls(Y~ (a*(1-exp(-b*X^c)))+q, > + data=DATA, > + start=c(a=75,b=0.05,c=0.7)) > Error in numericDeriv(form[[3L]], names(ind), env) : > Missing value or an infinity produced when evaluating the model >Many thanks in advance! Lindsay ______________________________________________ R-help at 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.
Gabor Grothendieck
2009-Aug-25 16:53 UTC
[R] Covariates in NLS (Multiple nonlinear regression)
Try this:
RSiteSearch("Weibull regression")
On Tue, Aug 25, 2009 at 12:02 PM, Lindsay Banin<l.banin05 at leeds.ac.uk>
wrote:> Dear R-users,
>
> I am trying to create a model using the NLS function, such that:
>
> Y = f(X) + q + e
>
> Where f is a nonlinear (Weibull: a*(1-exp(-b*X^c)) function of X and q is a
covariate (continous variable) and e is an error term. I know that you can
create multiple nonlinear regressions where x is polynomial for example, but is
it possible to do this kind of thing when x is a function with unknown
coefficients (a,b,c)? Ultimately, I am expecting the output to give individual
regression models for each coefficient (a,b,c) with q as a covariate.
>
> I have tried the following code, and get the resultant error messages:
>> weib.nls <- nls(Y ~ (a*(1-exp(-b*X^c)))|q,
>> + data=DATA,
>> + start=c(a=75,b=0.05,c=0.7))
>> Error in nlsModel(formula, mf, start, wts) :
>> ? singular gradient matrix at initial parameter estimates
>> > summary(weib.nls)
>
>> > weib.nls2 <- nls(Y~ (a*(1-exp(-b*X^c)))+q,
>> + data=DATA,
>> + start=c(a=75,b=0.05,c=0.7))
>> Error in numericDeriv(form[[3L]], names(ind), env) :
>> ? Missing value or an infinity produced when evaluating the model
>>
>
> Many thanks in advance!
> Lindsay
>
> ______________________________________________
> R-help at 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.
>
Thank you for your suggestion.
Unfortunately, like most texts on the topic of nonlinear regression, examples
tend to be either a) a simple regression with one predictor and one response or
b) a continuous predictor and response with a categorical variable (i.e.
differentiating for example two curves for two groups). I have not managed to
find any examples that replicate my scenario - that I would expect the nature of
the weibull curve to vary in association with a third (fourth, etc) continuous
variable.
I was rather hoping to find somebody that had done the same thing - is it
possible?
Thanks,
Lindsay
-----Original Message-----
From: Gabor Grothendieck [mailto:ggrothendieck at gmail.com]
Sent: 25 August 2009 17:53
To: Lindsay Banin
Cc: r-help at r-project.org
Subject: Re: [R] Covariates in NLS (Multiple nonlinear regression)
Try this:
RSiteSearch("Weibull regression")
On Tue, Aug 25, 2009 at 12:02 PM, Lindsay Banin<l.banin05 at leeds.ac.uk>
wrote:> Dear R-users,
>
> I am trying to create a model using the NLS function, such that:
>
> Y = f(X) + q + e
>
> Where f is a nonlinear (Weibull: a*(1-exp(-b*X^c)) function of X and q is a
covariate (continous variable) and e is an error term. I know that you can
create multiple nonlinear regressions where x is polynomial for example, but is
it possible to do this kind of thing when x is a function with unknown
coefficients (a,b,c)? Ultimately, I am expecting the output to give individual
regression models for each coefficient (a,b,c) with q as a covariate.
>
> I have tried the following code, and get the resultant error messages:
>> weib.nls <- nls(Y ~ (a*(1-exp(-b*X^c)))|q,
>> + data=DATA,
>> + start=c(a=75,b=0.05,c=0.7))
>> Error in nlsModel(formula, mf, start, wts) :
>> ? singular gradient matrix at initial parameter estimates
>> > summary(weib.nls)
>
>> > weib.nls2 <- nls(Y~ (a*(1-exp(-b*X^c)))+q,
>> + data=DATA,
>> + start=c(a=75,b=0.05,c=0.7))
>> Error in numericDeriv(form[[3L]], names(ind), env) :
>> ? Missing value or an infinity produced when evaluating the model
>>
>
> Many thanks in advance!
> Lindsay
>
> ______________________________________________
> R-help at 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.
>
Apparently Analagous Threads
- (no subject)
- MASS fitdistr with plyr or data.table?
- Error in 1:p : NA/NaN argument when running model comparisons
- Need help with self-defined function to perform nonlinear regression and get prediction interval
- Comparing model fits for NLME when models are not nested