Title: | A Pairwise Likelihood Augmented Cox Estimator for Left-Truncated Data |
---|---|
Description: | A semi-parametric estimation method for the Cox model with left-truncated data using augmented information from the marginal of truncation times. |
Authors: | Fan Wu [aut, cre] |
Maintainer: | Fan Wu <[email protected]> |
License: | GPL (>= 3) |
Version: | 0.1.3 |
Built: | 2025-02-05 04:40:37 UTC |
Source: | https://github.com/942kid/plac |
This package provides both lower-level C++
functions (PLAC_TI()
, PLAC_TV()
and PLAC_TvR()
) and an R wrapper function PLAC()
to calculate the pairwise likelihood augmented Cox estimator for left-truncated survival data as proposed by Wu et al. (2018).
PLAC()
This R
wrapper function calls different C++
function depending on the covariate types data
has.
The three C++
functions PLAC_TI()
, PLAC_TV()
and PLAC_TvR()
provide a direct interface to the algorithm in case that users need to supply more flexible time-dependent coavriates other than indicator functions.
Wu, F., Kim, S., Qin, J., Saran, R., & Li, Y. (2018). A pairwise likelihood augmented Cox estimator for left‐truncated data. Biometrics, 74(1), 100-108.
Calulate the Values of the cumulative Hazard at Fixed Times
cum.haz(est, t.eval = c(0.25, 0.75))
cum.haz(est, t.eval = c(0.25, 0.75))
est |
an object of the class |
t.eval |
time points at which the Lambda(t) is evaluated (for both conditional apporach and the PLAC estimator). |
a list containing the estiamtes and SEs of Lambda(t) for both conditional apporach and the PLAC estimator.
dat1 = sim.ltrc(n = 50)$dat est = PLAC(ltrc.formula = Surv(As, Ys, Ds) ~ Z1 + Z2, ltrc.data = dat1, td.type = "none") H = cum.haz(est, t.eval = seq(0.1, 0.9, 0.1)) H$L H$se.L
dat1 = sim.ltrc(n = 50)$dat est = PLAC(ltrc.formula = Surv(As, Ys, Ds) ~ Z1 + Z2, ltrc.data = dat1, td.type = "none") H = cum.haz(est, t.eval = seq(0.1, 0.9, 0.1)) H$L H$se.L
Both a conditional approach Cox model and a pairwise likelihood augmented estimator are fitted and the corresponding results are returned in a list.
PLAC( ltrc.formula, ltrc.data, id.var = "ID", td.type = "none", td.var = NULL, t.jump = NULL, init.val = NULL, max.iter = 100, print.result = TRUE, ... )
PLAC( ltrc.formula, ltrc.data, id.var = "ID", td.type = "none", td.var = NULL, t.jump = NULL, init.val = NULL, max.iter = 100, print.result = TRUE, ... )
ltrc.formula |
a formula of of the form |
ltrc.data |
a data.frame of the LTRC dataset including the responses, time-invariate covariates and the jump times for the time-depnencent covariate. |
id.var |
the name of the subject id in |
td.type |
the type of the time-dependent covariate. Either one of
|
td.var |
the name of the time-dependent covariate in the output. |
t.jump |
the name of the jump time variable in |
init.val |
a list of the initial values of the coefficients and the baseline hazard function for the PLAC estimator. |
max.iter |
the maximal number of iteration for the PLAC estimator |
print.result |
logical, if a brief summary of the regression coefficient estiamtes should be printed out. |
... |
other arguments |
ltrc.formula
should have the same form as used in
coxph()
; e.g., Surv(A, Y, D) ~ Z1 + Z2
. where (A, Y,
D)
are the truncation time, the survival time and the status indicator
((tstart, tstop, event)
as in coxph
).
td.type
is used to determine which C++
function will be
invoked: either PLAC_TI
(if td.type = "none"
), PLAC_TD
(if td.type = "independent"
) or PLAC_TDR
) (if td.type
%in% c("post-trunc", "pre-post-trunc")
). For td.type =
"post-trunc"
, the pre-truncation values for the time-dependent covariate
will be set to be zero for all subjects.
a list of model fitting results for both conditional approach and the PLAC estimators.
Event.Time
Ordered distinct observed event times
b
Regression coefficients estiamtes
se.b
Model-based SEs of the regression coefficients estiamtes
H0
Estimated cumulative baseline hazard function
se.H0
Model-based SEs of the estimated cumulative baseline hazard function
sandwich
The sandwich estimator for (beta, lambda)
k
The number of iteration for used for the PLAC estimator
summ
A brief summary of the covariates effects
Wu, F., Kim, S., Qin, J., Saran, R., & Li, Y. (2018). A pairwise likelihood augmented Cox estimator for left‐truncated data. Biometrics, 74(1), 100-108.
# When only time-invariant covariates are involved dat1 = sim.ltrc(n = 40)$dat PLAC(ltrc.formula = Surv(As, Ys, Ds) ~ Z1 + Z2, ltrc.data = dat1, td.type = "none") # When there is a time-dependent covariate that is independent of the truncation time dat2 = sim.ltrc(n = 40, time.dep = TRUE, distr.A = "binomial", p.A = 0.8, Cmax = 5)$dat PLAC(ltrc.formula = Surv(As, Ys, Ds) ~ Z, ltrc.data = dat2, td.type = "independent", td.var = "Zv", t.jump = "zeta") # When there is a time-dependent covariate that depends on the truncation time dat3 = sim.ltrc(n = 40, time.dep = TRUE, Zv.depA = TRUE, Cmax = 5)$dat PLAC(ltrc.formula = Surv(As, Ys, Ds) ~ Z, ltrc.data = dat3, td.type = "post-trunc", td.var = "Zv", t.jump = "zeta")
# When only time-invariant covariates are involved dat1 = sim.ltrc(n = 40)$dat PLAC(ltrc.formula = Surv(As, Ys, Ds) ~ Z1 + Z2, ltrc.data = dat1, td.type = "none") # When there is a time-dependent covariate that is independent of the truncation time dat2 = sim.ltrc(n = 40, time.dep = TRUE, distr.A = "binomial", p.A = 0.8, Cmax = 5)$dat PLAC(ltrc.formula = Surv(As, Ys, Ds) ~ Z, ltrc.data = dat2, td.type = "independent", td.var = "Zv", t.jump = "zeta") # When there is a time-dependent covariate that depends on the truncation time dat3 = sim.ltrc(n = 40, time.dep = TRUE, Zv.depA = TRUE, Cmax = 5)$dat PLAC(ltrc.formula = Surv(As, Ys, Ds) ~ Z, ltrc.data = dat3, td.type = "post-trunc", td.var = "Zv", t.jump = "zeta")
C++ Function for Solving the PLAC Estimator. (with time-dependent convariates independent of A^*)
PLAC_TD(Z, ZFV_, X, W, Ind1, Ind2, Dn, b, h, K = 100L)
PLAC_TD(Z, ZFV_, X, W, Ind1, Ind2, Dn, b, h, K = 100L)
Z |
matrix for all the covariates history. |
ZFV_ |
matrix for all covariates at the each individual's observed survival time. |
X |
the response matrix (As, Xs, Ds). |
W |
the ordered observed event times. |
Ind1 |
risk-set indicators. |
Ind2 |
truncation pair indicators. |
Dn |
number of ties at each observed event time. |
b |
initial values of the regression coefficients. |
h |
initial values of the baseline hazard function. |
K |
maximal iteration number, the default is |
list of model fitting results for both conditional approach and the PLAC estimator.
C++ Function for Solving the PLAC Estimator. (with time-dependent convariates depending on A^*)
PLAC_TDR(ZF, ZFV_, Z, X, W, Ind1, Ind2, Dn, b, h, K = 100L)
PLAC_TDR(ZF, ZFV_, Z, X, W, Ind1, Ind2, Dn, b, h, K = 100L)
ZF |
matrix for all the time-invariant covariates. |
ZFV_ |
matrix for all covariates at the each individual's observed survival time. |
Z |
matrix for all the covariates history. |
X |
the response matrix (As, Xs, Ds). |
W |
the ordered observed event times. |
Ind1 |
risk-set indicators. |
Ind2 |
truncation pair indicators. |
Dn |
number of ties at each observed event time. |
b |
initial values of the regression coefficients. |
h |
initial values of the baseline hazard function. |
K |
maximal iteration number, the default is |
list of model fitting results for both conditional approach and the PLAC estimator.
C++ Function for Solving the PLAC Estimator. (with time-invariant convariates only)
PLAC_TI(Z, X, W, Ind1, Ind2, Dn, b, h, K = 100L)
PLAC_TI(Z, X, W, Ind1, Ind2, Dn, b, h, K = 100L)
Z |
matrix for all the covariates history. |
X |
the response matrix (As, Xs, Ds). |
W |
the ordered observed event times. |
Ind1 |
risk-set indicators. |
Ind2 |
truncation pair indicators. |
Dn |
number of ties at each observed event time. |
b |
initial values of the regression coefficients. |
h |
initial values of the baseline hazard function. |
K |
maximal iteration number, the default is |
list of model fitting results for both conditional approach and the PLAC estimator.
Perform the paired log-rank test on the truncation times and the residual survival times to check the stationarity assumption (uniform truncation assumption) of the left-truncated right-censored data.
plr(dat, A.name = "As", Y.name = "Ys", D.name = "Ds")
plr(dat, A.name = "As", Y.name = "Ys", D.name = "Ds")
dat |
a data.frame of left-truncated right-censored data. |
A.name |
the name of the truncation time variable in |
Y.name |
the name of the survival time variable in |
D.name |
the name of the event indicator in |
a list containing the test statistic and the p-value of the paired log-rant test.
Jung, S.H. (1999). Rank tests for matched survival data. Lifetime Data Analysis, 5(1):67-79.
dat = sim.ltrc(n = 50, distr.A = "weibull")$dat plr(dat)
dat = sim.ltrc(n = 50, distr.A = "weibull")$dat plr(dat)
Generate truncation-pair indicators
PwInd(X, W)
PwInd(X, W)
X |
the response matrix (As, Xs, Ds). |
W |
the ordered observed event times. |
the truncation-pair indicators of the form I(w_k <= A_i)
I(w_k <= XA_j).
Generate risk-set indicators
SgInd(X, W)
SgInd(X, W)
X |
the response matrix (As, Xs, Ds). |
W |
the ordered observed event times. |
risk-set indicators Y_i(w_k) of the form I(A_i <= w_k <= X_i).
Various baseline survival functions and truncation distribution are
available. Censoring rate can be designated through tuning the parameter
Cmax
; Cmas = Inf
means no censoring.
sim.ltrc( n = 200, b = c(1, 1), Z.type = c("C", "B"), time.dep = FALSE, Zv.depA = FALSE, A.depZ = FALSE, distr.T = "weibull", shape.T = 2, scale.T = 1, meanlog.T = 0, sdlog.T = 1, distr.A = "weibull", shape.A = 1, scale.A = 5, p.A = 0.3, b.A = c(0, 0), Cmax = Inf, fix.seed = NULL )
sim.ltrc( n = 200, b = c(1, 1), Z.type = c("C", "B"), time.dep = FALSE, Zv.depA = FALSE, A.depZ = FALSE, distr.T = "weibull", shape.T = 2, scale.T = 1, meanlog.T = 0, sdlog.T = 1, distr.A = "weibull", shape.A = 1, scale.A = 5, p.A = 0.3, b.A = c(0, 0), Cmax = Inf, fix.seed = NULL )
n |
the sample size. |
b |
a numeric vector for true regression coefficients. |
Z.type |
a vector indicating the type of the time-invariant covariates;
|
time.dep |
logical, whether there is the time-dependent covariate (only one indicator function Zv = I(t >= zeta) is supported); the default is FALSE. |
Zv.depA |
logical, whether the time-dependent covariate |
A.depZ |
logical, whether the truncation times depends on the covariate Z. |
distr.T |
the baseline survival time (T*) distribution ("exp" or "weibull"). |
shape.T |
the shape parameter for the Weibull distribution of T*. |
scale.T |
the scale parameter for the Weibull distributiof of T*. |
meanlog.T |
the mean for the log-normal distribution of T*. |
sdlog.T |
the sd for the log-normal distribution of T*. |
distr.A |
the baseline truncation time (A*) distribution: either of
|
shape.A |
the shape parameter for the Weibull distribution of A*. |
scale.A |
the scale parameter for the Weibull distribution of A*. |
p.A |
the success probability for the binomial distribution of A*. |
b.A |
the vector of coefficients for the model of A on the covariates. |
Cmax |
the upper bound of the uniform distribution of the censoring time (C). |
fix.seed |
an optional random seed for simulation. |
a list with a data.frame containing the biased sample of
survival times (Ys
) and truncation times (As
),
the event indicator (Ds
) and the covariates (Zs
);
a vector of certain quantiles of Ys (taus
);
the censoring proportion (PC
) and the truncation proportion
(PT
).
# With time-invariant covariates only sim1 = sim.ltrc(n = 40) head(sim1$dat) # With one time-dependent covariate sim2 = sim.ltrc(n = 40, time.dep = TRUE, distr.A = "binomial", p.A = 0.8, Cmax = 5) head(sim2$dat) # With one time-dependent covariate with dependence on the truncation time sim3 = sim.ltrc(n = 40, time.dep = TRUE, Zv.depA = TRUE, Cmax = 5) head(sim3$dat)
# With time-invariant covariates only sim1 = sim.ltrc(n = 40) head(sim1$dat) # With one time-dependent covariate sim2 = sim.ltrc(n = 40, time.dep = TRUE, distr.A = "binomial", p.A = 0.8, Cmax = 5) head(sim2$dat) # With one time-dependent covariate with dependence on the truncation time sim3 = sim.ltrc(n = 40, time.dep = TRUE, Zv.depA = TRUE, Cmax = 5) head(sim3$dat)
Generate time-depependent covariate indicators
TvInd(zeta, W)
TvInd(zeta, W)
zeta |
the change point (jump time) of Z_v(t). |
W |
the ordered observed event times. |
the time-depependent covariate of the form Z_v(t) = I(w_k > zeta).
Generate time-depependent covariate indicators
TvInd2(eta, zeta, W)
TvInd2(eta, zeta, W)
eta |
a random variable of the Z_v(t) value before the change point. |
zeta |
the change point (jump time). |
W |
the ordered observed event times. |
the time-depependent covariate indicators of the form Z_v(t) = eta * I(w_k <= zeta).