generate_pseudo_pop: Generate Pseudo Population

View source: R/generate_pseudo_pop.R

generate_pseudo_popR Documentation

Generate Pseudo Population

Description

Generates pseudo population data set based on user-defined causal inference approach. The function uses an adaptive approach to satisfies covariate balance requirements. The function terminates either by satisfying covariate balance or completing the requested number of iteration, whichever comes first.

Usage

generate_pseudo_pop(
  Y,
  w,
  c,
  ci_appr,
  gps_model = "parametric",
  use_cov_transform = FALSE,
  transformers = list("pow2", "pow3"),
  bin_seq = NULL,
  trim_quantiles = c(0.01, 0.99),
  optimized_compile = FALSE,
  params = list(),
  sl_lib = c("m_xgboost"),
  nthread = 1,
  ...
)

Arguments

Y

A vector of observed outcome variable.

w

A vector of observed continuous exposure variable.

c

A data.frame of observed covariates variable.

ci_appr

The causal inference approach. Possible values are:

  • "matching": Matching by GPS

  • "weighting": Weighting by GPS

gps_model

Model type which is used for estimating GPS value, including parametric (default) and non-parametric.

use_cov_transform

If TRUE, the function uses transformer to meet the covariate balance.

transformers

A list of transformers. Each transformer should be a unary function. You can pass name of customized function in the quotes. Available transformers:

  • pow2: to the power of 2

  • pow3: to the power of 3

bin_seq

Sequence of w (treatment) to generate pseudo population. If NULL is passed the default value will be used, which is seq(min(w)+delta_n/2,max(w), by=delta_n).

trim_quantiles

A numerical vector of two. Represents the trim quantile level. Both numbers should be in the range of [0,1] and in increasing order (default: c(0.01,0.99)).

optimized_compile

If TRUE, uses counts to keep track of number of replicated pseudo population.

params

Includes list of params that is used internally. Unrelated parameters will be ignored.

sl_lib

A vector of prediction algorithms.

nthread

An integer value that represents the number of threads to be used by internal packages.

...

Additional arguments passed to different models.

Details

Additional parameters

Causal Inference Approach (ci.appr)
  • if ci.appr = 'matching':

    • matching_fun: Matching function. Available options:

      • matching_l1: Manhattan distance matching

    • delta_n: caliper parameter.

    • scale: a specified scale parameter to control the relative weight that is attributed to the distance measures of the exposure versus the GPS.

    • covar_bl_method: covariate balance method. Available options:

      • 'absolute'

    • covar_bl_trs: covariate balance threshold

    • covar_bl_trs_type: covariate balance type (mean, median, maximal)

    • max_attempt: maximum number of attempt to satisfy covariate balance.

    • See create_matching() for more details about the parameters and default values.

  • if ci.appr = 'weighting':

    • covar_bl_method: Covariate balance method.

    • covar_bl_trs: Covariate balance threshold

    • max_attempt: Maximum number of attempt to satisfy covariate balance.

Value

Returns a pseudo population (gpsm_pspop) object that is generated or augmented based on the selected causal inference approach (ci_appr). The object includes the following objects:

  • params

    • ci_appr

    • params

  • pseudo_pop

  • adjusted_corr_results

  • original_corr_results

  • optimized_compile (True or False)

  • best_gps_used_params

Examples

m_d <- generate_syn_data(sample_size = 100)
pseuoo_pop <- generate_pseudo_pop(m_d$Y,
                                  m_d$treat,
                                  m_d[c("cf1","cf2","cf3","cf4","cf5","cf6")],
                                  ci_appr = "matching",
                                  gps_model = "parametric",
                                  bin_seq = NULL,
                                  trim_quantiles = c(0.01,0.99),
                                  optimized_compile = FALSE,
                                  use_cov_transform = FALSE,
                                  transformers = list(),
                                  params = list(xgb_nrounds=c(10,20,30),
                                                xgb_eta=c(0.1,0.2,0.3)),
                                  sl_lib = c("m_xgboost"),
                                  nthread = 1,
                                  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)


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