Learn R Programming

psrwe (version 3.2)

psrwe_match: PS matching

Description

Match patients in the external data source with patients in the current study based on PS using the nearest neighbor method.

Usage

psrwe_match(
  dta_ps,
  ratio = 3,
  strata_covs = NULL,
  caliper = 1,
  seed = NULL,
  method = c("nnwor", "optm"),
  .drop_arg_fml = FALSE,
  ...
)

Value

A list of class PSRWE_DTA_MAT with items:

data

Original data with column _ps_ for estimated PS scores, match_id for matched current study subject ID, and _strata_ for PS stratum added.

ps_fml

PS formula for estimated PS scores.

nstrata

Number of strata.

ratio

Matching ratio.

Arguments

dta_ps

A list of class PSRWE_DAT that is generated using the psrwe_est function.

ratio

Matching ratio (RWD : Current). Default is 3 (i.e., 3:1 matching).

strata_covs

Covariates used for stratification in matching.

caliper

PS matching caliper width. Default 1. This specifies a width (Euclidean distance) on the probability scale.

seed

Random seed.

method

matching algorithm for PS matching.

.drop_arg_fml

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

...

Additional parameters for matching

Examples

Run this code
data(ex_dta)
dta_ps <- psrwe_est(ex_dta,
                     v_covs = paste("V", 1:7, sep = ""),
                     v_grp = "Group",
                     cur_grp_level = "current")

## With neighest neighbor
.remark_nnmatch <- function() {
  dta_ps_mat <- psrwe_match(dta_ps, ratio = 2, strata_covs = "V1",
                            seed = 123)
  dta_ps_mat
}
## Unmark below to run
# .remark_nnmatch()

## With optmatch
.remark_optmatch <- function() {
    warning("The optmatch package may restrict use (academic license).")
    dta_ps_opt <- psrwe_match(dta_ps, ratio = 2,
                               strata_covs = "V1",
                               method = "optm", seed = 123)
    dta_ps_opt
}
## Unmark below to run if optmatch is available.
# .remark_optmatch()

Run the code above in your browser using DataLab