我的数据如下
# A tibble: 24 x 3
time OD600 strain
<dbl> <dbl> <chr>
1 0.0001 0.0001 M12-611020
2 1.0000 0.0880 M12-611020
3 3.0000 0.2110 M12-611020
4 4.0000 0.2780 M12-611020
5 4.5000 0.4040 M12-611020
6 5.0000 0.6060 M12-611020
7 5.5000 0.7780 M12-611020
8 6.0000 0.9020 M12-611020
9 6.5000 1.0240 M12-611020
10 8.0000 1.1000 M12-611020
11 0.0001 0.0001 M12-611025
12 1.0000 0.0770 M12-611025
13 3.0000 0.0880 M12-611025
14 4.0000 0.1250 M12-611025
15 5.0000 0.3040 M12-611025
16 5.5000 0.4210 M12-611025
17 6.0000 0.5180 M12-611025
18 6.5000 0.6160 M12-611025
19 7.0000 0.7180 M12-611025
20 7.5000 0.8520 M12-611025
21 8.0000 0.9400 M12-611025
22 8.5000 0.9500 M12-611025
23 9.0000 0.9680 M12-611025我在data.frame中有两个“毒株”,每一个都有各自的“时间”和"OD600“值集。
到目前为止,我一直在用ggplot绘图,如下所示(为了简单起见,去掉美学),使用“黄土”来拟合曲线:
growth_curve_SE <- growth_curve +
stat_smooth(aes(group=strain,fill=strain, colour = strain) ,method = "loess", se = T, alpha=0.2 , span = 0.8) +
geom_point(aes(fill=factor(strain)),alpha=0.5 , size=3,shape = 21,colour = "black", stroke = 1)我最终想要达到的是拟合一个5参数的逻辑回归,而不是“黄土”的方法,因为它是一个更好的数据模型和拟合更准确的曲线。
我使用包"nplr“来拟合多个菌株的回归,使用的是按菌株划分的列表:
strain_list <- split(multi_strain, multi_strain$strain)
np2 <- lapply(strain_list, function(tmp) {nplr(tmp$time, tmp$OD600, useLog = F)})这符合回归:
$`M12-611020`
Instance of class nplr
Call:
nplr(x = tmp$time, y = tmp$OD600, useLog = F)
weights method: residuals
5-P logistic model
Bottom asymptote: 0.03026607
Top asymptote: 1.104278
Inflexion point at (x, y): 5.297454 0.6920488
Goodness of fit: 0.9946967
Weighted Goodness of fit: 0.9998141
Standard error: 0.0308006 0.01631115
$`M12-611025`
Instance of class nplr
Call:
nplr(x = tmp$time, y = tmp$OD600, useLog = F)
weights method: residuals
5-P logistic model
Bottom asymptote: -0.0009875526
Top asymptote: 0.9902298
Inflexion point at (x, y): 6.329304 0.5919818
Goodness of fit: 0.9956551
Weighted Goodness of fit: 0.9998606
Standard error: 0.02541948 0.01577407 有什么想法吗?我怎样才能用"stat_smooth“命令来使用5个参数的logistic回归来达到同样的目的,不管是否使用"nplr”包?
发布于 2017-12-01 02:18:12
对任何感兴趣的人来说,我都找到了一份工作。
nplr包允许您将曲线输出为一系列的x和y坐标,如下所示:
x <- getXcurve(data)
y <-getYcurve(data)由此,我使用了使用这些x和y参数的"geom_line“函数,这给出了(N)参数logistic回归,这是以logn的形式出现的。第一层"geom_point“作为and,你会得到一个好看的图表
https://stackoverflow.com/questions/47519572
复制相似问题