Type: Package
Title: Structural Additive Cumulative Intensity Models with IV
Version: 2.1.0
Date: 2022-01-01
Author: Andrew Ying
Maintainer: Andrew Ying <aying9339@gmail.com>
Description: An instrumental variable estimator under structural cumulative additive intensity model is fitted, that leverages initial randomization as the IV. The estimator can be used to fit an additive hazards model under time to event data which handles treatment switching (treatment crossover) correctly. We also provide a consistent variance estimate.
License: GPL-2 | GPL-3 [expanded from: GPL (≥ 2)]
Imports: Rcpp
LinkingTo: Rcpp, RcppArmadillo
Depends: R (≥ 4.0)
RoxygenNote: 7.1.2
Encoding: UTF-8
NeedsCompilation: yes
Packaged: 2022-01-30 01:08:41 UTC; andrewying
Repository: CRAN
Date/Publication: 2022-01-30 03:10:02 UTC

This function is to compute the centralized instrument

Description

This function is to compute the centralized instrument

Usage

IV_center(Z, weights)

This is the main function to compute the estimator in C++

Description

This is the main function to compute the estimator in C++

Usage

invalidivsacim_est(
  time,
  event,
  stime,
  Z,
  Z_c,
  D_status,
  D_status_c,
  Z_model_mat,
  eps_1,
  D_model_mat,
  eps_2,
  weights
)

Arguments

time

censored event time

event

event indicator

stime

unique sorted noncensored event time

Z

the instrument

Z_c

centered IV

D_status

treatment process at each noncensored event time

D_status_c

centered treatment process at each noncensored event time

Z_model_mat

bread matrix from modeling IV

eps_1

influence function from modeling IV

D_model_mat

bread matrix from modeling treatment

eps_2

influence function from modeling treatment

weights

optional weights


Fitting a Cumulative Intensity Model for Exposure Effects with Instrumental Variables

Description

ivsacim is used to fit cumulative intensity models for exposure effects with instrumental variables.

Usage

ivsacim(
  time,
  event,
  instrument,
  IV_valid = TRUE,
  treatment_init,
  treatment_shift_time = NULL,
  max_time = NULL,
  max_time_bet = NULL,
  n_sim = 0,
  weights = NULL
)

Arguments

time

the censored event time

event

event indicator

instrument

the instrumental variable

IV_valid

whether assuming IV satisfies the exclusion restriction

treatment_init

the initial treatment assignment

treatment_shift_time

the shift time of each subject, if no shift for a subject, set as 0

max_time

the max time that we threshold for nonconstant effect

max_time_bet

the max time that we threshold for constant effect

n_sim

the number of resampling, set as 0 if no resampling is needed

weights

optional weights used in the estimating equation

Value

ivsacim returns an object of class "ivsacim". An object of class "ivsacim" is a list containing the following components:

stime

an estimate of the baseline hazards function

dB_D

an estimate of the increment of the treatment effect

B_D

an estimate of the treatment effect

beta_D

an estimate of the constant treatment effect

B_D_se

an estimate of the variance covariance matrix of B_D

beta_D_se

an estimate of the constant treatment effect

by_prod

a byproduct, that will used by other functions

Examples

n = 400
event = rbinom(n, 1, 0.8)
IV = rbinom(n, 1, 0.5)
trt_init = IV
trt_shift = rep(0, n)
time = rexp(n)/(0.5 + trt_init * 0.2)
max_t = 3
max_t_bet = 3
n_sim = 0
fit <- ivsacim(time, event, IV, TRUE, trt_init, 
trt_shift, max_t, max_t_bet, n_sim)

This is the main function to compute the estimator in C++

Description

This is the main function to compute the estimator in C++

Usage

ivsacim_est(time, event, stime, Zc, D_status, eps_1, Zc_dot, weights)

Arguments

time

censored event time

event

event indicator

stime

unique sorted noncensored event time

Zc

centered IV

D_status

treatment process at each noncensored event time

eps_1

influence function from modeling IV

Zc_dot

bread matrix from modeling IV

weights

optional weights


Plotting Estimated Cumulative Intensity function with Pointwise Confidence Intervals

Description

The function will plot the estimated cumulative intensity function of the treatment after fitting. Corresponding pointwise confidence intervals at level alpha are also included.

Usage

## S3 method for class 'ivsacim'
plot(x, gof = FALSE, ...)

Arguments

x

the fitting object after fitting IVSACIM model

gof

whether to draw the goodness-of-fit plot

...

the other arguments you want to put in the built-in plot function

Value

No return value, called for side effects

Examples

n = 400
event = rbinom(n, 1, 0.8)
IV = rbinom(n, 1, 0.5)
trt_init = IV
trt_shift = rep(0, n)
time = rexp(n)/(0.5 + trt_init * 0.2)
max_t = 3
max_t_bet = 3
n_sim = 100
fit <- ivsacim(time, event, IV, IV_valid = TRUE, trt_init, trt_shift, max_t, max_t_bet, n_sim)
plot(fit, main = "", xlab = "Time", ylab = "Cumulative Intensity Function")
plot(fit, gof = TRUE, xlab = "Time", ylab = "")

Summarizing Cumulative Intensity Function of Treatment with Instrumental Variables Estimation Using Structural Additive Cumulative Intensity Models

Description

summary method for class "ivsacim".

Usage

## S3 method for class 'ivsacim'
summary(object, ...)

## S3 method for class 'summary.ivsacim'
print(x, ...)

Arguments

object

an object of class "ivsacim", usually, a result of a call to ivsacim.

...

further arguments passed to or from other methods.

x

an object of class "summary.ivsacim", usually, a result of a call to summary.ivsacim.

Details

print.summary.ivsacim tries to be smart about formatting coefficients, an estimated variance covariance matrix of the coeffieients, Z-values and the corresponding P-values.

Value

The function summary.ivsacim computes and returns a list of summary statistics of the fitted model given in object.

Examples

n = 400
event = rbinom(n, 1, 0.8) 
IV = rbinom(n, 1, 0.5)
trt_init = IV
trt_shift = rep(0, n)
time = rexp(n)/(0.5 + trt_init * 0.2)
max_t = 3
max_t_bet = 3
n_sim = 0
fit <- ivsacim(time, event, IV, IV_valid = TRUE, trt_init, trt_shift, max_t, max_t_bet, n_sim)
summary(fit)

This function is to generate a grid of treatment status

Description

This function is to generate a grid of treatment status

Usage

treatment_status(N, K, stime, treatment_init, treatment_shift_time, max_time)

This function is to compute the centralized treatment process given the covariates Z, L at each sorted unique event time

Description

This function is to compute the centralized treatment process given the covariates Z, L at each sorted unique event time

Usage

trt_center(D_status, Z, weights)