# [R] Covariates in NLS (Multiple nonlinear regression)

Gabor Grothendieck ggrothendieck at gmail.com
Tue Aug 25 18:53:17 CEST 2009

```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
>>
>
> Lindsay
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help