outcome_regression {CausalModels}R Documentation

Outcome Regression

Description

'outcome_regression' builds a linear model using all covariates. The treatment effects are stratified within the levels of the covariates. The model will automatically provide all discrete covariates in a contrast matrix. To view estimated change in treatment effect from continuous variables, a list called contrasts, needs to be given with specific values to estimate. A vector of values can be given for any particular continuous variable.

Usage

outcome_regression(
  data,
  f = NA,
  simple = pkg.env$simple,
  family = gaussian(),
  contrasts = list(),
  ...
)

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 gaussian. NOTE: if this is changed, the assumptions about the model output may be incorrect and may not provide accurate treatment effects.

contrasts

a list of continuous covariates and values in the model to be included in the contrast matrix (e.g. list(age = c(18, 25, 40), weight = c(90, 159))).

...

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

Value

outcome_regression returns an object of class "outcome_regression"

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

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

call

the matched call.

formula

the formula used in the model.

model

the underlying glht model.

ATE

a data frame containing the ATE, SE, and 95% CI of the ATE.

ATE.summary

a more detailed summary of the ATE estimations from glht.

Examples

library(causaldata)
library(multcomp)

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
)

out.mod <- outcome_regression(nhefs.nmv, contrasts = list(
  age = c(21, 55),
  smokeintensity = c(5, 20, 40)
))
print(out.mod)
summary(out.mod)
head(data.frame(preds = predict(out.mod)))


[Package CausalModels version 0.2.0 Index]