Package 'ivsacim'

Title: Structural Additive Cumulative Intensity Models with IV
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.
Authors: Andrew Ying
Maintainer: Andrew Ying <[email protected]>
License: GPL (>= 2)
Version: 2.1.0
Built: 2024-09-19 06:43:41 UTC
Source: CRAN

Help Index


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)

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)