knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>"
)
rm(list=ls())
library(RobinCar)

Linear and Joint Calibration for Guaranteed Efficiency Gain and Universality

The dataset that we will use for this is included in the package.

data <- RobinCar:::data_sim
data$A <- as.factor(data$A)
 # add some noise as an extra covariate as toy example
data$extra_cov <- rnorm(nrow(data))

Adjustment with Binary Outcomes

Dichotomize the continuous outcome.

data$y_bin <- ifelse(data$y > 2, 1, 0)

Fit a heterogeneous working model with biased coin randomization, then perform linear and joint calibration.

result <- robincar_glm(
  df=data,
  response_col="y_bin",
  treat_col="A",
  car_strata_cols=c("z1"),
  car_scheme="biased-coin",
  g_family=binomial(link="logit"),
  g_accuracy=7,
  formula="y_bin ~ A + x3 + z1"
)
print(result)

Calibration

Use joint = FALSE to indicate linear calibration. This fits a model with the predicted potential outcomes as covariates.

robincar_calibrate(
  result=result,
  joint=FALSE
)

Use joint = TRUE to indicate joint calibration. This fits a model with the predicted potential outcomes and the joint strata variables.

robincar_calibrate(
  result=result,
  joint=TRUE
)

Use add_x to include additional covariates in the calibration. This fits a model with the predicted potential outcomes and specified additional covariates (and the joint strata if joint = TRUE).

robincar_calibrate(
  result=result,
  joint=TRUE,
  add_x=c("extra_cov")
)


tye27/RobinCar documentation built on June 13, 2025, 7:04 p.m.