##-----------------------------------------------------------------## ## R code for obtaining the maximum composite partial likelihood ## ## estimator for the CSHA data. See the paper " Composite Partial ## ## Likelihood Estimation Under Length-Biased Sampling, With ## ## Application to a Prevalent Cohort Study of Dementia" ## ## by Huang and Qin. ## ##-----------------------------------------------------------------## # A: time from onset to study enrollment # Y: time from onset to death or loss to follow-up # D: event indicator (= 1 if died; = 0 if censored) # X1: indocator for probable Alzheimer # X2: indocator for vascular dementia # Cox regression with partial likelihood method fit <- coxph( Surv( time = A, time2 = Y, event = D) ~ X1 + X2, method = "breslow") # Cox regression with composite partial likelihood method cpdata <- data.frame( cbind( A = c(A, (Y-A)[D == 1]), Y = c(Y, Y[D == 1]), D = c(D, D[D == 1]), X1 = c(X1, X1[D == 1]), X2 = c(X2, X2[D == 1]) )) cpfit <- coxph( Surv( time = A, time2 = Y, event = D ) ~ X1 + X2, data = cpdata, method = "breslow" )