我有来自苍蝇实验的生存数据,该实验检查了各种基因型的衰老率。这些数据以多种布局提供给我,因此您可以选择哪种布局,以最适合答案的为准。
一个数据框(wide.df)看起来像这样,其中每个基因型(Exp,其中有 ~640 个)都有一行,并且从第 4 天到第 98 天按顺序水平排列,每两天有新的死亡人数。
Exp Day4 Day6 Day8 Day10 Day12 Day14 ...
A 0 0 0 2 3 1 ...
我用这个做例子:
wide.df2<-data.frame("A",0,0,0,2,3,1,3,4,5,3,4,7,8,2,10,1,2)
colnames(wide.df2)<-c("Exp","Day4","Day6","Day8","Day10","Day12","Day14","Day16","Day18","Day20","Day22","Day24","Day26","Day28","Day30","Day32","Day34","Day36")
另一个版本是这样的,每天每个“Exp”都有一行,并记录当天的死亡人数。
Exp Deaths Day
A 0 4
A 0 6
A 0 8
A 2 10
A 3 12
.. .. ..
做这个例子:
df2<-data.frame(c("A","A","A","A","A","A","A","A","A","A","A","A","A","A","A","A","A"),c(0,0,0,2,3,1,3,4,5,3,4,7,8,2,10,1,2),c(4,6,8,10,12,14,16,18,20,22,24,26,28,30,32,34,36))
colnames(df2)<-c("Exp","Deaths","Day")
我想做的是执行Gompertz 分析(请参阅此处“生命表”的第二段)。方程是:
μx = α*e β*x
其中μx是给定时间的死亡概率,α是初始死亡率,β是衰老率。
我希望能够获得一个数据框,其中包含我的约 640 个基因型中的每一个的α和β估计值,以便以后进一步分析。
我需要从上述数据框到 R 中每个基因型的这些值的输出的帮助。
我已经查看了flexsurv
可能包含答案的软件包,但我未能尝试找到并实施它。