Re: differing number of rows when running nls regression

Luigi Marongiu <[email protected]>
Newsgroups gmane.comp.lang.r.general
Message-ID <CAMk+s2Sgn4tzHMtzJEGZmED7g4U2up2pSO22y_0g1mONAbfnbg@mail.gmail.com>
@Krylov
Thank you! now the preview works, but the actual nls still gives an error:

```
> form = as.formula(Response ~ ( (exp((a+b*Dose))) / (1+exp(-(a+b*Dose)) )))
> preview(form, data = df, start=list(a=A, b=B))

RSS:  33200000

> nls(Response ~ ( (exp((a+b*Dose))) / (1+exp(-(a+b*Dose)) )),
+     data=df, start=list(a=A, b=B))
Error in numericDeriv(form[[3L]], names(ind), env, central = nDcentral) :
  Missing value or an infinity produced when evaluating the model
```
@Berger
Thank you and sorry for the typo: `x_25_2024` was the original data;
it is `df` in the example. nls(form, data=df) worked for me too.

On Sat, Sep 20, 2025 at 9:39 AM Ivan Krylov <[email protected]> wrote:
>
> В Sat, 20 Sep 2025 08:02:16 +0200
> Luigi Marongiu <[email protected]> пишет:
>
> > nls(Response ~ ( (exp(a+b*Dose)) / (1+exp-(a+b*Dose)) ),
> >     data=df, start=list(a=A, b=B))
>
> Thank you for providing a reproducible example!
>
> 1+exp-(a+b*Dose) is parsed as 1 + `exp` - (a+b*Dose), treating `exp` as
> a summand, and summing a function doesn't make sense in base R.
>
> In order to pass -(a+b*Dose) as the argument to exp(), this needs to be
> written as 1+exp(-(a+b*Dose)) instead.
>
> --
> Best regards,
> Ivan



-- 
Best regards,
Luigi
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.