# NOT RUN {
library("timereg")
library("survival")
data("prt",package="mets")
margp <- coxph(Surv(time,status==1)~factor(country),data=prt)
fitco <- survival.twostage(margp,data=prt,clusters=prt$id)
summary(fitco)
des <- model.matrix(~-1+factor(zyg),data=prt);
fitco <- survival.twostage(margp,data=prt,theta.des=des,clusters=prt$id)
summary(fitco)
dfam <- simSurvFam(1000)
dfam <- fast.reshape(dfam,var=c("x","time","status"))
desfs <- function(x,num1="num1",num2="num2")
{
pp <- (x[num1]=="m")*(x[num2]=="f")*1 ## mother-father
pc <- (x[num1]=="m" | x[num1]=="f")*(x[num2]=="b1" | x[num2]=="b2")*1 ## mother-child
cc <- (x[num1]=="b1")*(x[num2]=="b1" | x[num2]=="b2")*1 ## child-child
c(pp,pc,cc)
}
marg <- coxph(Surv(time,status)~factor(num),data=dfam)
out3 <- easy.survival.twostage(marg,data=dfam,time="time",status="status",id="id",deshelp=0,
score.method="fisher.scoring",theta.formula=desfs,
desnames=c("parent-parent","parent-child","child-cild"))
summary(out3)
# }
Run the code above in your browser using DataLab