wglm: Logistic Regression Using IPCW

View source: R/wglm.R

wglmR Documentation

Logistic Regression Using IPCW

Description

Logistic regression over multiple timepoints where right-censoring is handled using inverse probability of censoring weighting (IPCW).

Usage

wglm(
  formula.event,
  times,
  data,
  formula.censor = ~1,
  cause = NA,
  fitter = NULL,
  ties = NULL,
  product.limit = NULL,
  store = NULL
)

Arguments

formula.event

[formula] a formula with a Surv object on the left hand side and the covariates for the logistic regression on the right hand side.

times

[numeric vector] time points at which to model the probability of experiencing an event.

data

[data.frame] dataset containing the time at which the event occured, the type of event, and regressors used to fit the censoring and logistic models.

formula.censor

[formula] an optional formula indicating on its right hand side the covariates for the censoring model.

cause

[character or numeric] the cause of interest. Defaults to the first cause.

fitter

[character] routine to fit the Cox regression models.

ties

[character] method used to handle ties when using a Cox model ("breslow" or "efron"). Ignored if fitter equals to "prodlim".

product.limit

[logical] if TRUE the survival is computed using the product limit estimator.

store

[vector of length 2] Whether prediction should only be computed for unique covariate sets and mapped back to the original dataset (data="minimal") and whether the influence function should be stored in a memory efficient way (iid="minimal"). Otherwise use data="full" and/or iid="full".

Details

First, a Cox model is fitted (argument formula.censor) and the censoring probabilities are computed relative to each timepoint (argument times) to obtain the censoring weights. Then, for each timepoint, a logistic regression is fitted with the appropriate censoring weights and where the outcome is the indicator of having experience the event of interest (argument cause) at or before the timepoint.

Value

an object of class "wglm".

Examples

library(survival)

#### simulate data ####
set.seed(10)
n <- 250
tau <- 1:5
d <- sampleData(n, outcome = "competing.risks")
dFull <- d[event!=0] ## (artificially) remove censoring
dSurv <- d[event!=2] ## (artificially) remove competing risk

#### no censoring ####
e.wglm <- wglm(Surv(time,event) ~ X1, 
               times = tau, data = dFull, product.limit = TRUE)
e.wglm ## same as a logistic regression

summary(ate(e.wglm, data = dFull, times = tau, treatment = "X1", verbose = FALSE))

#### right-censoring ####
## no covariante in the censoring model (independent censoring)
eC.wglm <- wglm(Surv(time,event) ~ X1,
               times = tau, data = dSurv, product.limit = TRUE)
eC.wglm

## with covariates in the censoring model
eC2.wglm <- wglm(Surv(time,event) ~ X1 + X8, formula.censor = ~ X1*X8,
                 times = tau, data = dSurv)
eC2.wglm

#### Competing risks ####
## here Kaplan-Meier as censoring model
eCR.wglm <- wglm(Surv(time,event) ~ X1, formula.censor = ~X1,
                 times = tau, data = d)
eCR.wglm
summary(eCR.wglm)
eCR.wglm <- wglm(Surv(time,event) ~ X1, formula.censor = ~X1,
                 times = tau, data = d)

tagteam/riskRegression documentation built on Oct. 19, 2024, 7:43 p.m.