View source: R/outcome_regression.R

outcome_regression | R Documentation |

'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.

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

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

`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 |

`contrasts` |
a list of continuous covariates and values in the model to be included in the contrast matrix
(e.g. |

`...` |
additional arguments that may be passed to the underlying |

`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. |

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)))

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.