knitr::opts_chunk$set( collapse = TRUE, comment = "#>" )
rm(list=ls()) library(RobinCar)
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))
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)
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") )
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.