contrast_data: get data for contrasts

Description Usage Arguments Value Examples

Description

get data for contrasts

Usage

1
2
3
contrast_data(stanreg, new_group = NULL, marginalize_factors = NULL,
  margin_ignore = NULL, set_numerics = NULL,
  subset_expression = NULL)

Arguments

stanreg

stanreg object from rstanarm

new_group

a character vector of column names (factors) that should be estimated "out of sample". If NA or TRUE, then all random effects will be out of sample, i.e., new levels in those factors.

marginalize_factors

a character manually choosing which factors to marginalize over (collapsing numeric values by taking the mean for each combination of factors). If NA, then the groups used as random effects will be omitted during aggregation. The default is to marginalize over all factors in the model data set.

margin_ignore

character vector of numeric variable names to ingore when marginalizing over factors

set_numerics

an optional named list, where each name is the name of a column in the data and its value is the value to use to override the numeric value instead of using the margin.

subset_expression

an optional formula expression to subset the data before marginalizing. Expressions must begin with a .~ and have conditions after this. See examples for usage details.

Value

a data.table with the same columns used in the model.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
stanreg <- example_stanreg()
model_data <- stanreg_dtbl(stanreg, TRUE) # compare below to model data

contrast_data(stanreg)

contrast_data(stanreg, new_group=TRUE)
contrast_data(stanreg, new_group=c('county'))

contrast_data(stanreg, margin_ignore = 'floor')

contrast_data(stanreg, TRUE, set_numerics = list(floor = 1))

contrast_data(stanreg, subset_expression = .~ log_uranium > 0)
contrast_data(stanreg, margin_ignore = c('floor'), subset_expression = 1:101)

iamamutt/rbaes documentation built on May 18, 2019, 1:27 a.m.