inst/doc/hte.R

## ----include = FALSE----------------------------------------------------------
knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>",
  dev = "ragg_png",
  dpi = 192,
  fig.width = 7,
  fig.height = 4.5,
  out.width = "90%",
  fig.align = "center",
  warning = TRUE,
  message = TRUE
)

## -----------------------------------------------------------------------------
library(PDRobust)
data("BiSample", package = "PDRobust")
map <- Mapping(
  id = "id",
  time = "time",
  treatment = "A",
  survival = "S",
  outcome = "Y",
  baseline_time = 0,
  cutoff_time = 2,
  covariates = c("X1", "X2", "X3", "X4", "X5","X6"),
  interest_vars = c("X1", "X5"),
  y_type = "B"
)

## -----------------------------------------------------------------------------
pd_data <- DataStandard(BiSample, map)
head(pd_data)

## -----------------------------------------------------------------------------
ps_fo <- A ~ X1 + X3 + X4 + X5 + X6
prin_fo <- S ~ (X1 + X3 + X4 + X5 + X6 ) * A
out_fo <- Y ~ (X1 + X3 + X4 + X5 + X6) * A 

## -----------------------------------------------------------------------------
set.seed(20260912)
separate <- HTESepT(
  data = pd_data,
  ps_fo = ps_fo,
  prin_fo = prin_fo,
  out_fo = out_fo,
  target_time = c(1, 2),
  B = 5,
  conf_level = 0.95,
  max_attempts = NULL,
  verbose = TRUE
)

names(separate)

## -----------------------------------------------------------------------------
names(separate)

## ----fig.alt = "Time-specific treatment-effect model coefficients and demonstration bootstrap confidence intervals."----
separate$summary
separate$forest_plot

## -----------------------------------------------------------------------------
names(separate$bootstrap_info)

separate$bootstrap_info

## -----------------------------------------------------------------------------
separate$boot_mat

## -----------------------------------------------------------------------------
pooled <- HTEAllT(
  data = pd_data,
  ps_fo = ps_fo,
  prin_fo = prin_fo,
  out_fo = out_fo,
  B = 0,
  conf_level = 0.95,
  max_attempts = NULL,
  verbose = FALSE
)
names(pooled)

## ----fig.alt = "Pooled treatment-effect model point estimates; bootstrap intervals are not calculated in this example."----
pooled$summary
pooled$forest_plot

## -----------------------------------------------------------------------------
pooled$time_effect_estimable
pooled$analysis_times

Try the PDRobust package in your browser

Any scripts or data that you put into this service are public.

PDRobust documentation built on Oct. 2, 2026, 5:09 p.m.