Skip to content

khnhan/spyce

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Package spyce

How to install

install.packages("gitcreds")
gitcreds::gitcreds_delete()  # clears a bad cached token
remotes::install_github("khnhan/spyce")

Description

This package analyzes right-censored covariate under outcome-dependent censoring. The semiparametric estimator SPYCE is implemented via get_SPYCE_... functions. This package provides other estimators for analyzing the same data: complete case estimator (CC), imputation estimator, inverse probability weighting estimator (IPW), and the maximum likelihood estimator (MLE). The estimated asymptotic variance for the estimators can be computed with corresponding variance_... functions. Conditional Kaplan-Meier estimator as an auxiliary tool for nonparametric estimators can also be implemented with this package.

The full data is $(Y,X,C,Z)$, where

  • $Y$: outcome
  • $X$: time-to-event covariate
  • $C$: censoring time
  • $Z$: baseline covariates

Due to right-censoring, the observed data is $(Y,W,\Delta,Z)$, where $W=\min(X,C)$ and $\Delta = 1(X\le C)$. Outcome-dependent censoring $X\bot C\mid Y,Z$ is assumed. SPYCE is the estimator for the parameter of outcome model $Y\mid X,Z$. $\eta_1 = f_{X|Z}$ and $\eta_2 = f_{C|Y,Z}$ are considered nuisance distributions.

Usage

The functions get_... find an estimator of $\beta$ and $\sigma$, and the functions variance_... compute the estimated asymptotic variance of the estimators.

  • With z_data present, then $Y\mid X,Z \sim N\big(\beta_0+\beta_1 X+\beta_2 Z+\beta_3 ZX,\ \sigma^2\big)$.
  • Without z_data, then $Y\mid X \sim N\big(\beta_0+\beta_1 X,\ \sigma^2\big)$.

Possible choices of estimators are

  • ...SPYCE_param12: SPYCE with parametrically estimated $\eta_1$ and $\eta_2$
  • ...SPYCE_nonparam12: SPYCE with nonparametrically estimated $\eta_1$ and $\eta_2$
  • ...CC: complete case (CC) estimator
  • ...imputation_param1: imputation estimator with parametrically estimated $\eta_1$
  • ...imputation_nonparam1: imputation estimator with nonparametrically estimated $\eta_1$
  • ...IPW_param2: inverse probability weighting (IPW) estimator with parametrically estimated $\eta_2$
  • ...IPW_nonparam2: inverse probability weighting (IPW) estimator with nonparametrically estimated $\eta_2$
  • ...MLE_param1: maximum likelihood estimator (MLE) with parametrically estimated $\eta_1$
  • ...MLE_nonparam1: maximum likelihood estimator (MLE) with nonparametrically estimated $\eta_1$

Each of the estimators supports four modes:

  • CASE A: estimate $(\beta,\sigma)$ with z_data
  • CASE B: estimate $(\beta,\sigma)$ without z_data
  • CASE C: estimate $\beta$ with z_data and fixed $\sigma$
  • CASE D: estimate $\beta$ without z_data and fixed $\sigma$

For SPYCE, imputation, IPW, and MLE, there are two choices for nuisance model estimation: parametric estimation and nonparametric estimation. Each estimation method provides a different workflow.

The parametric estimation of nuisance models uses maximum likelihood estimation with truncated normal distribution. The workflow is:

  1. Make y_data, w_data, delta_data as the same-length vectors. For CASE A and CASE C, make z_data as the same-length binary vector.
  2. Assign sigma_fixed for CASE C and CASE D.
  3. Supply proper initial values init for optimization. If undetermined, use linear regression estimators with complete case data using lm(y_data[delta_data == 1] ~ w_data[delta_data == 1]) (CASE B and CASE D) or lm(y_data[delta_data == 1] ~ w_data[delta_data == 1] + z_data[delta_data == 1]) (CASE A and CASE C).
  4. Provide proper w_min and w_max, the range for $X$ and $C$. This will be used in a truncated normal distribution for maximum likelihood estimation.
  5. If needed, put extra options nleqslv_args that will be used in optimizer nleqslv::nleqslv function.
  6. Compute the estimator using get_... function. Save the final estimates.
  7. To find asymptotic variance of the estimator, use variance_... function with the saved final estimates.

The nonparametric estimation of nuisance models uses inverse probability weighting with kernel estimation, where conditional survival function values are used for inverse probability weighting. Conditional survival function values can be computed using conditional_Kaplan_Meier function. The workflow is:

  1. Make y_data, w_data, delta_data as the same-length vectors. For CASE A and CASE C, make z_data as the same-length binary vector.
  2. Assign sigma_fixed for CASE C and CASE D.
  3. Supply proper initial values init for optimization. If undetermined, use linear regression estimators with complete case data using lm(y_data[delta_data == 1] ~ w_data[delta_data == 1] (CASE B and CASE D) or lm(y_data[delta_data == 1] ~ w_data[delta_data == 1] + z_data[delta_data == 1] (CASE A and CASE C).
  4. Supply conditional survival function values in surv_c_vals and/or surv_x_vals for each observation $(W_i,Y_i,Z_i)$. You may use conditional_Kaplan_Meier function.
  5. If needed, put extra options nleqslv_args that will be used in optimizer nleqslv::nleqslv function.
  6. Compute the estimator using get_... function. Save the final estimates.
  7. To find asymptotic variance of the estimator, use variance_... function with the saved final estimates.

More detailed examples are provided in help() document of each function.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages