psrwe_est: Estimate propensity scores

View source: R/psrwe_ps_est.R

psrwe_estR Documentation

Estimate propensity scores

Description

Estimate propensity scores using logistic regression or random forest model.

Usage

psrwe_est(
  data,
  ps_fml = NULL,
  ps_method = c("logistic", "randomforest"),
  v_covs = "V1",
  v_grp = "Group",
  cur_grp_level = 1,
  v_arm = NULL,
  ctl_arm_level = NULL,
  stra_ctl_only = TRUE,
  nstrata = 5,
  trim_ab = c("both", "above", "below", "none"),
  .drop_arg_fml = FALSE,
  ...
)

Arguments

data

Data frame with group assignment and covariates.

ps_fml

Propensity score (PS) formula. If NULL, all covariates will be included in the PS model in a linear form.

ps_method

Method to calculate propensity scores. Can be set to logistic for logistic regression or randomforest for a random forest approach.

v_covs

Column names corresponding to covariates.

v_grp

Column name corresponding to group assignment.

cur_grp_level

Group level for the current study. Default is cur_grp_level = 1. Ignored for single arm studies.

v_arm

Column name corresponding to arm assignment.

ctl_arm_level

Arm level for the control arm. Ignored for single-arm studies.

stra_ctl_only

Create strata by control arm patients only. Default TRUE. Ignored by single arm studies. For randomized studies, when stra_ctl_only is FALSE, strata are created based on the PS scores of the entire current study patients.

nstrata

Number of PS strata to be created.

trim_ab

Trim external subjects who are above or below the range of current study. Default both trims both above and below. Other options include above for above only, below for below only, and none for no trimming.

.drop_arg_fml

internal use to drop arguments and call, this is only used in cjk.

...

Additional parameters for calculating the propensity score to be used in randomForest or glm .

Value

A list of class PSRWE_DAT with items:

data

Original data with column _ps_ for estimated PS scores and _strata_ for PS stratum added.

ps_fml

PS formula for estimated PS scores.

is_rct

Whether the current study is a randomized study.

nstrata

Number of strata.

Examples

data(ex_dta)
psrwe_est(ex_dta,
       v_covs = paste("V", 1:7, sep = ""),
       v_grp = "Group",
       cur_grp_level = "current")


olssol/psrwe documentation built on July 17, 2024, 4:06 p.m.