Gompertz Aging analysis in R

后端 未结 1 1015
执笔经年
执笔经年 2021-01-03 02:09

I have survival data from an experiment in flies which examines rates of aging in various genotypes. The data is available to me in several layouts so the choice of which is

相关标签:
1条回答
  • 2021-01-03 02:48

    This should get you started...

    Firstly, for the flexsurvreg function to work, you need to specify your input data as a Surv object (from package:survival). This means one row per observation.

    The first thing is to re-create the 'raw' data from the summary tables you provide. (I know rbind is not efficient, but you can always switch to data.table for large sets).

    ### get rows with >1 death
    df3 <- df2[df2$Deaths>1, 2:3]
    ### expand to give one row per death per time
    df3 <- sapply(df3, FUN=function(x) rep(df3[, 2], df3[, 1]))
    ### each death is 1 (occurs once)
    df3[, 1] <- 1
    ### add this to the rows with <=1 death
    df3 <- rbind(df3, df2[!df2$Deaths>1, 2:3])
    ### convert to Surv object
    library(survival)
    s1 <- with(df3, Surv(Day, Deaths))
    ### get parameters for Gompertz distribution
    library(flexsurv) 
    f1 <- flexsurvreg(s1 ~ 1, dist="gompertz")
    

    giving

    > f1$res
                  est         L95%        U95%
    shape 0.165351912 0.1281016481 0.202602176
    rate  0.001767956 0.0006902161 0.004528537
    

    Note that this is an intercept-only model as all your genotypes are A. You can loop this over multiple survival objects once you have re-created the per-observation data as above.

    From the flexsurv docs:

    Gompertz distribution with shape parameter a and rate parameter b has hazard function

    H(x: a, b) = b.e^{ax}

    So it appears your alpha is b, the rate, and beta is a, the shape.

    0 讨论(0)
提交回复
热议问题