Last chance! 50% off unlimited learning
Sale ends in
Fits two-stage model for describing depdendence in survival data using marginals that are on cox or aalen form using the twostage funcion, but call is different and easier and the data manipulation build into the function. Useful in particular for family design data.
easy.survival.twostage(margsurv = NULL, data = sys.parent(),
score.method = "nlminb", status = "status", time = "time",
entry = NULL, id = "id", Nit = 60, detail = 0, silent = 1,
weights = NULL, control = list(), theta = NULL, theta.formula = NULL,
desnames = NULL, deshelp = 0, var.link = 1, iid = 1, step = 0.5,
model = "plackett", marginal.surv = NULL, strata = NULL,
max.clust = NULL, se.clusters = NULL)
model
data frame
Scoring method
Status at exit time
Exit time
Entry time
name of cluster variable in data frame
Number of iterations
Detail for more output for iterations
Debug information
Weights for log-likelihood, can be used for each type of outcome in 2x2 tables.
Optimization arguments
Starting values for variance components
design for depedence, either formula or design function
names for dependence parameters
if 1 then prints out some data sets that are used, on on which the design function operates
Link function for variance (exp link)
Calculate i.i.d. decomposition
Step size for newton-raphson
plackett or clayton-oakes model
vector of marginal survival probabilities
strata for fitting
max clusters
clusters for iid decomposition for roubst standard errors
If clusters contain more than two times, the algoritm uses a composite likelihood based on the pairwise bivariate models.
The reported standard errors are based on the estimated information from the likelihood assuming that the marginals are known.
# 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