Fitting logistic curve to data with SSlogis: error NA/NaN/Inf

Viewed 110

I am trying to fit a logistic curve to my data for two separate years. The data are very similar for each year, with exactly the same format and I removed all observations with NA's or NaN's and made sure they are numeric. However for some reason the script works perfectly for the first year, and does not work for the second year.

Here is a bit of what my 2013 data looks like (101 observations total):

        x       y
1    0.070  95.392
2    0.079 100.000
3    0.109 100.000
4    0.072 100.000
5   -0.005 100.000
6    0.014 100.000
7   -0.008 100.000
8    0.307  52.523
9    0.696   0.000
10  -0.045 100.000

And the 2018 data(116 observations total):

         x       y
1    0.133 100.000
2    0.139 100.000
3    0.152 100.000
4    0.124 100.000
5    0.051 100.000
6    0.062 100.000
7   -0.050 100.000
8    0.356  80.282
9    0.545   0.000
10  -0.029  62.857

Here is my script:

##2013 data
x <- veg13$`Elevation`
y <- veg13$`pclowspecies`

##predict parameters for the logistic curve
fit <- nls(y ~ SSlogis(x, Asym, xmid, scal), data=data.frame(x, y))
summary(fit)

It works fine for 2013, but when I repeat with 2018 data I get the following error:

Error in qr.default(.swts * gr) : 
  NA/NaN/Inf in foreign function call (arg 1)

I have read some other people who had the same issue but their solutions do not work for me, since I don't have any NA's or NaN's in my data.

Thank you for your help!

0 Answers
Related