propensity_scores {CausalModels}R Documentation

Propensity Scores

Description

'propensity_scores' builds a logistic regression with the target as the treatment variable and the covariates as the independent variables.

Usage

propensity_scores(
  data,
  f = NA,
  simple = pkg.env$simple,
  family = binomial(),
  ...
)

Arguments

data

a data frame containing the variables in the model. This should be the same data used in init_params.

f

(optional) an object of class "formula" that overrides the default parameter

simple

a boolean indicator to build default formula with interactions. If true, interactions will be excluded. If false, interactions will be included. By default, simple is set to false.

family

the family to be used in the general linear model. By default, this is set to binomial NOTE: if this is changed, the outcome of the model may not be the probabilities and the results will not be valid.

...

additional arguments that may be passed to the underlying glm model.

Value

propensity_scores returns an object of class "propensity_scores"

The functions print, summary, and predict can be used to interact with the underlying glm model.

An object of class "propensity_scores" is a list containing the following:

call

the matched call.

formula

the formula used in the model.

model

the underlying glm model.

p.scores

the estimated propensity scores.

Examples

library(causaldata)
data(nhefs)
nhefs.nmv <- nhefs[which(!is.na(nhefs$wt82)), ]
nhefs.nmv$qsmk <- as.factor(nhefs.nmv$qsmk)

confounders <- c(
  "sex", "race", "age", "education", "smokeintensity",
  "smokeyrs", "exercise", "active", "wt71"
)

init_params(wt82_71, qsmk,
  covariates = confounders,
  data = nhefs.nmv
)

p.score <- propensity_scores(nhefs.nmv)
p.score


[Package CausalModels version 0.2.0 Index]