[英]fit a scatter plot with Weibull curve with ggplot2
我不确定这是否是重复的问题。 但我真的希望能从这里得到帮助。
我想绘制如下图所示的图表,拟合 2 参数 Weibull 曲线。 x 轴是days
,y 轴是biomaker level
,截止值为 0.5。
这是一个示例数据。
`biomaker level` days result
1.5515 81 Positive
0.712 5 Positive
1.831 15 Positive
1.738 30 Positive
1.519 9 Positive
1.2145 21 Positive
2.2085 19 Positive
2.15 18 Positive
2.1845 20 Positive
2.248 18 Positive
2.098 14 Positive
2.2645 36 Positive
2.273 55 Positive
2.213 9 Positive
2.2515 15 Positive
2.245 14 Positive
1.894 68 Positive
2.265 25 Positive
2.2305 25 Positive
1.7955 84 Positive
1.649 85 Positive
1.4635 16 Positive
1.3775 98 Positive
1.008 114 Positive
1.44 35 Positive
0.1845 2 Negative
我已经尝试过这个解决方案,但我不知道初始值是什么。 似乎这是可能的,但是“127”在以下nls(y~127*dweibull(x,shape,scale), start=c(shape=3,scale=100))
是什么意思: nls(y~127*dweibull(x,shape,scale), start=c(shape=3,scale=100))
? 我怎样才能从我的数据中得到这个常数?
在那个问题中, 127
是y
总和。 但在一些回复中,它说这种方法存在一些问题,并提供了一种权宜之计。 存在两种方式, SSweibull
和dweibull
。
SSweibull
df1 <- df1 %>% arrange(days)
x <- df1$days
y <- df1$biomaker.level
yy <- cumsum(y) #max(yy) = 46.0095 ~ 46
nls(yy ~ SSweibull(x, Asym, Drop, lrc, pwr))
Nonlinear regression model
model: yy ~ SSweibull(x, Asym, Drop, lrc, pwr)
data: parent.frame()
Asym Drop lrc pwr
41.698 44.194 -5.675 1.783
residual sum-of-squares: 154.5
Number of iterations to convergence: 10
Achieved convergence tolerance: 8.941e-06
plot(yy ~ x)
curve(SSweibull(x, 41.698, 44.194, -5.675, 1.783), add = TRUE)
dweibull
nls(y ~ 46 * dweibull(x, shape, scale), start = c(shape = 3, scale = 20))
Nonlinear regression model
model: y ~ 46 * dweibull(x, shape, scale)
data: parent.frame()
shape scale
2.375 23.378
residual sum-of-squares: 27.93
Number of iterations to convergence: 9
Achieved convergence tolerance: 4.33e-06
plot(y ~ x)
curve(46 * dweibull(x, 2.375, 23.378), add = TRUE)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.