问题
I am currently trying to model and plot a sigmoidal curve with a low amount of points.
>myExperiment
V1 N mean
0.1 9 0.9
1 9 0.8
10 9 0.1
5 9 0.2
I am using the nlsLM
function from the minpack.lm
package.
> nlsLM(mean2 ~ -a/(1 + exp(-b * (v1-o))))
Nonlinear regression model
model: mean2 ~ -a/(1 + exp(-b * (v1 - o)))
data: parent.frame()
a b o
-1.452 -0.451 1.292
residual sum-of-squares: 0.007017
Number of iterations to convergence: 27
Achieved convergence tolerance: 1.49e-08
Warning message:
In nlsLM(mean2 ~ -a/(1 + exp(-b * (v1 - o)))) :
No starting values specified for some parameters.
Initializing ‘a’, ‘b’, ‘o’ to '1.'.
Consider specifying 'start' or using a selfStart model
Using those starting values I receive this error.
> nls(mean~-a/(1 + exp(-b * (v1-o))), start=list(a=-1.452, b=-0.451, o=1.292))
Error in nls(mean ~ -a/(1 + exp(-b * (v1 - o))), start = list(a = -1.452, :
step factor 0.000488281 reduced below 'minFactor' of 0.000976562
I am not well studied in stats to know if this is a syntax R error or a stats failure. What am I doing poorly?
-Thanks
回答1:
This looks like binomial dose-response data. In any case, I would propose a simpler model, like the two parameter log-logistic model, with asymptotes at 0 and 1. A lot of sigmoidal models have been coded up in the drc package.
myExperiment = read.table(header = TRUE, text =
" V1 N mean
0.1 9 0.9
1 9 0.8
10 9 0.1
5 9 0.2")
library(drc)
m.ll2 <- drm(mean ~ V1,
data = myExperiment,
type = "binomial",
fct = LL.2(),
weights = N)
plot(m.ll2, ylim = c(0, 1))
来源:https://stackoverflow.com/questions/39515799/sigmoidal-modeling-in-r