Analyzing twin survival data with 'mets'
- Load the menarche data.
library(mets) data("mena")
- Estimate the mean age at menarche in each cohort treating the censored observations as uncensored. Are there seemingly any significant effect of cohort?
- Estimate parameters from the Tobit regression model (linear normal
regression with right censoring):
s <- survreg(Surv(agemena,status) ~ 1+factor(cohort)+cluster(id), dist="gaussian", data=mena)
Interpret the output from the model.
- Calculate the Kaplan-Meier estimator for each cohort. Plot and
interpret the results. What is the approximate age at median survival time?
km1 <- survfit(Surv(agemena,status) ~ factor(cohort), data=mena) palette(c("darkblue","darkred","orange","olivedrab")) plot(km1,mark.time=FALSE,col=1:4)
- Add the survival curve from the Tobit regression to the plot (for
the youngest cohort). Use the
pnormfunction and extract the mean and standard deviation (scale) from the survreg model.tt <- seq(0,16,length.out=100) ss <- 1-pnorm(tt,mean=coef(s)[1],sd=s$scale) lines(tt,ss,lty=2)
- Estimate a Cox regression model using the cox.aalen function from
the
timeregpackage.ca <- cox.aalen(Surv(agemena,status)~+1+prop(cohort)+cluster(id), data=mena,max.clust=NULL,n.sim=0,robust=0)
- Calculate the two-stage Clayton-Oakes-Glidden estimate
vardesign <- model.matrix(~-1+factor(zyg),mena) e <- two.stage(ca,data=mena,theta.des=vardesign)
Interpret the results. Refit the model with a new variance regression design, vardesign, that makes it possible to assess the statistical significance of zygosity.
- Plot paired menarche times
library(lava.tobit) menaw <- fast.reshape(mena,id="id") status <- menaw$status1+menaw$status2+1 plot(agemena2~agemena1,data=menaw,pch=c(2,6,16)[status],col=Col(c(4,2,1)[status],0.6))
- Estimate parameters from ACE model
s0 <- twinlm(agemena~1,zyg="zyg",DZ="DZ",id="id",data=mena) s0 mena$S <- with(mena, Surv(agemena,status)) s <- twinlm(S~1,zyg="zyg",DZ="DZ",id="id",data=mena,control=list(trace=1,start=coef(s0))) s