Creates propensity scores and inverse probability of treatment weights (IPTW) using a regularized logistic regression.

```
createPs(
cohortMethodData,
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,
resetCoefficients = TRUE, tolerance = 2e-07, cvRepetitions = 10, startingVariance =
0.01),
estimator = "att"
)
```

- 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 occur, 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.- estimator
The type of estimator for the IPTW. Options are

`estimator = "ate"`

for the average treatment effect,`estimator = "att"`

for the average treatment effect in the treated, and`estimator = "ato"`

for the average treatment effect in the overlap population.

IPTW estimates either the average treatment effect (ate) or average treatment effect in the treated (att) using stabilized inverse propensity scores (Xu et al. 2010).

Xu S, Ross C, Raebel MA, Shetterly S, Blanchette C, Smith D. Use of stabilized inverse propensity scores as weights to directly estimate relative risk and its confidence intervals. Value Health. 2010;13(2):273-277. doi:10.1111/j.1524-4733.2009.00671.x

```
data(cohortMethodDataSimulationProfile)
cohortMethodData <- simulateCohortMethodData(cohortMethodDataSimulationProfile, n = 1000)
#> Generating covariates
#> Generating treatment variable
#> Generating cohorts
#> Generating outcomes after index date
#> Generating outcomes before index date
ps <- createPs(cohortMethodData)
#> Removing 1 redundant covariates
#> Removing 0 infrequent covariates
#> Normalizing covariates
#> Tidying covariates took 0.86 secs
#> Warning: All coefficients (except maybe the intercept) are zero. Either the covariates are completely uninformative or completely predictive of the treatment. Did you remember to exclude the treatment variables from the covariates?
#> Propensity model fitting finished with status OK
#> Creating propensity scores took 3.09 secs
```