differing number of rows when running nls regression

Luigi Marongiu <[email protected]>
Newsgroups gmane.comp.lang.r.general
Message-ID <CAMk+s2RvZ40Vzni1Tvjy7FDrh6PsB8=+79COQPPOTVQtXh=iUA@mail.gmail.com>
I have some data (y=Response, x=Dose) that is distributed roughly as a
curve. I am trying to fit a non-linear regression model on the data
using negative logistic function (even if the data show a rise in the
final part of the curve that the logistic won't accommodate for).
I used a rough graphical approach to guess the starting values then
the package `nlstools` for a better overview of the data. However, I
get the error "differing number of rows".
If I run `nls` directly, I get the error" "Error in 1 + exp :
non-numeric argument to binary operator"
Why is that happening?
How can I set the model?
Is there a better curve function to fit the data?
Thank you

```
df = data.frame(Response =    c(890.72,    895.46,    895.63,
894.72,    895.49,    893.59,
                892.53,    895.06,    897.21,    889.27,    876.05,
857.96,    862.02,    858.36,
                890.94,    890.8,    887.22,    888.91,    890.83,
889.92,    891.76,    890.32,
                886.35,    878.11,    866.57,    859.04,    863.64,
880.16,    884.15,    879.57,
                878.89,    882.27,    881.59,    880.98,    881.45,
876.19,    868.32,    859.16,
                850.53,    853.21,    859.34,    859.73,    861.19),
                Dose =    c(0.0000000015,    0.000000003,
0.000000006,    0.000000012,
                       0.000000024,    0.000000048,    0.000000095,
0.00000018,
                       0.00000038,    0.00000078,    0.0000015,
0.000013,    0.000025,
                       0.00005,    0.0000000015,    0.000000003,
0.000000006,
                       0.000000012,    0.000000024,    0.000000048,
0.000000095,
                       0.00000018,    0.00000038,    0.00000078,
0.0000015,    0.000025,
                       0.00005,    0.0000000015,    0.000000003,
0.000000006,
                       0.000000012,    0.000000024,    0.000000048,
0.000000095,
                       0.00000018,    0.00000038,    0.00000078,
0.0000015,    0.000003,
                       0.000006,    0.000013,    0.000025,    0.00005)
)
plot(Response~log10(Dose), df)
abline(a=500, b=-60)
abline(v=log10(0.3e-6))
A = 0.3e-6     # plateau
B = -60        # slope
library(nlstools)   # NL regression
form = as.formula(Response ~ ( (exp(a+b*Dose)) / (1+exp-(a+b*Dose)) ) )
preview(form, data = x_25_2024, start=list(a=A, b=B))
nls(Response ~ ( (exp(a+b*Dose)) / (1+exp-(a+b*Dose)) ),
    data=df, start=list(a=A, b=B))
```
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.