createEncodedPs: Create propensity scores

Description Usage Arguments Examples

View source: R/MetisCohortMethod.R

Description

Creates propensity scores using a regularized logistic regression.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
createEncodedPs(
  cohortMethodData,
  encoder = NULL,
  population = NULL,
  excludeCovariateIds = c(),
  includeCovariateIds = c(),
  maxCohortSizeForFitting = 250000,
  errorOnHighCorrelation = TRUE,
  stopOnError = TRUE,
  prior = createPrior("laplace", exclude = c(0), useCrossValidation = TRUE),
  control = createControl(noiseLevel = "silent", cvType = "auto", seed = 1, tolerance =
    2e-07, cvRepetitions = 10, startingVariance = 0.01),
  removeRedundancy = T,
  cmEncoder = NULL
)

Arguments

cohortMethodData

An object of type [CohortMethodData] as generated using [getDbCohortMethodData()].

population

A data frame describing the population. This should at least have a 'rowId' column corresponding to the 'rowId' column in the [CohortMethodData] covariates object and a 'treatment' column. If population is not specified, the full population in the [CohortMethodData] will be used.

excludeCovariateIds

Exclude these covariates from the propensity model.

includeCovariateIds

Include only these covariates in the propensity model.

maxCohortSizeForFitting

If the target or comparator cohort are larger than this number, they will be downsampled before fitting the propensity model. The model will be used to compute propensity scores for all subjects. The purpose of the sampling is to gain speed. Setting this number to 0 means no downsampling will be applied.

errorOnHighCorrelation

If true, the function will test each covariate for correlation with the treatment assignment. If any covariate has an unusually high correlation (either positive or negative), this will throw and error.

stopOnError

If an error occurr, should the function stop? Else, the two cohorts will be assumed to be perfectly separable.

prior

The prior used to fit the model. See [Cyclops::createPrior()] for details.

control

The control object used to control the cross-validation used to determine the hyperparameters of the prior (if applicable). See [Cyclops::createControl()] for details.

removeRedundancy

If true, the function will remove the redundant covariates by using 'FeatureExtraction::tidyCovariateData' function. Default setting is true.

Examples

1
2
3
data(cohortMethodDataSimulationProfile)
cohortMethodData <- simulateCohortMethodData(cohortMethodDataSimulationProfile, n = 1000)
ps <- createPs(cohortMethodData)

ABMI/Prometheus documentation built on Sept. 29, 2020, 8:45 p.m.