check_covar_balance: Check Covariate Balance

View source: R/check_covar_balance.R

check_covar_balanceR Documentation

Check Covariate Balance

Description

Checks the covariate balance of original population or pseudo population.

Usage

check_covar_balance(
  w,
  c,
  ci_appr,
  optimized_compile,
  counter_weight = NULL,
  nthread = 1,
  ...
)

Arguments

w

A vector of observed continuous exposure variable.

c

A data.frame of observed covariates variable.

ci_appr

The causal inference approach.

optimized_compile

If TRUE, use optimized compile approach.

counter_weight

A weight vector in different situations. If the matching approach is selected, it is an integer data.table of counters. In the case of the weighting approach, it is weight data.table.

nthread

The number of available threads.

...

Additional arguments passed to different models.

Details

Additional parameters

  • For ci_appr == matching:

    • covar_bl_method

    • covar_bl_trs

Value

output object:

  • corr_results

    • absolute_corr

    • mean_absolute_corr

  • pass (TRUE,FALSE)

Examples

set.seed(422)
n <- 100
mydata <- generate_syn_data(sample_size=100)
year <- sample(x=c("2001","2002","2003","2004","2005"),size = n, replace = TRUE)
region <- sample(x=c("North", "South", "East", "West"),size = n, replace = TRUE)
mydata$year <- as.factor(year)
mydata$region <- as.factor(region)
mydata$cf5 <- as.factor(mydata$cf5)



pseudo_pop <- generate_pseudo_pop(mydata$Y,
                                 mydata$treat,
                                 mydata[c("cf1","cf2","cf3","cf4","cf5","cf6","year","region")],
                                 ci_appr = "matching",
                                 pred_model = "sl",
                                 gps_model = "non-parametric",
                                 trim_quantiles = c(0.01,0.99),
                                 optimized_compile = TRUE,
                                 sl_lib = c("m_xgboost"),
                                 covar_bl_method = "absolute",
                                 covar_bl_trs = 0.1,
                                 covar_bl_trs_type = "mean",
                                 max_attempt = 1,
                                 matching_fun = "matching_l1",
                                 delta_n = 1,
                                 scale = 0.5,
                                 nthread = 1)

adjusted_corr_obj <- check_covar_balance(w = pseudo_pop$pseudo_pop[, c("w")],
                                        c = pseudo_pop$pseudo_pop[ ,
                                        pseudo_pop$covariate_cols_name,
                                         with=FALSE],
                                        counter = pseudo_pop$pseudo_pop[, c("counter_weight")],
                                        ci_appr="matching",
                                        nthread=1,
                                        covar_bl_method = "absolute",
                                        covar_bl_trs = 0.1,
                                        covar_bl_trs_type = "mean",
                                        optimized_compile=TRUE)


wxwx1993/GPSmatching documentation built on March 1, 2023, 9:32 p.m.