robin_ps {RobinCID}R Documentation

Post-Stratification Based Inference

Description

Provides robust inference via post stratification.

Usage

robin_ps(
  data,
  estimand = list(tx_colname = NULL, tx_to_compare = NULL),
  design = list(randomization_var_colnames = NULL, randomization_table = NULL),
  stratify_by = NULL,
  outcome_model = list(formula = NULL, family = gaussian()),
  contrast_specs = list(contrast = "difference", contrast_jac = NULL),
  alpha = 0.05,
  ...
)

Arguments

data

(data.frame) A data frame containing the dataset.

estimand

(list) A list specifying the estimand, with two elements:

  • tx_colname (character): The column name of the treatment variable in data.

  • tx_to_compare (⁠character vector⁠): A vector specifying exactly two treatment levels to compare.

design

(list) A list specifying randomization information, with two elements:

  • randomization_var_colnames (⁠character vector⁠): Column names of randomization variables in data.

  • randomization_table (data.frame, default: NULL): A data frame containing treatment assignment probabilities for each level of the randomization variables. See Details.

stratify_by

(character, optional) The column name of the stratification variable in data. If provided, stratify_by overrides design.

outcome_model

(list) A list specifying the outcome working model, with two elements:

  • formula (formula): The regression formula for the analysis.

  • family A description of the error distribution and link function for the model. Default: gaussian().

contrast_specs

(list) A list specifying the contrast function and its Jacobian:

  • contrast (function or character): A function to compute the treatment effect, or one of "difference", "risk_ratio", or "odds_ratio" for default contrasts.

  • contrast_jac (function, optional): A function to compute the Jacobian of the contrast function. Ignored if using default contrasts.

alpha

(numeric) The nominal significance level. Default: 0.05.

...

Additional arguments passed to glm.

Details

If family is MASS::negative.binomial(NA), the function will use MASS::glm.nb instead of glm.

Value

A treatment_effect object.

Examples

data_sim <- RobinCID::example
tx_colname <- "treatment"
treatment_levels <- unique(data_sim[[tx_colname]])
tx_to_compare <- c("trt.1", "trt.3")
randomization_var_colnames <- c("t", "subtype")
df <- data_sim[c("xb", "xc", tx_colname, randomization_var_colnames, "y")]
randomization_table <- unique(data_sim[c(randomization_var_colnames, treatment_levels)])
robin_ps(
  data = df,
  estimand = list(tx_colname = tx_colname,
                  tx_to_compare = tx_to_compare),
  design = list(randomization_var_colnames = randomization_var_colnames,
                randomization_table = randomization_table),
  stratify_by = NULL,
  outcome_model = list(formula = y ~ 1,
                       family = gaussian())
)

[Package RobinCID version 1.0.0 Index]