convert_inputs: Convert inputs for baggr models

View source: R/convert_inputs.R

convert_inputsR Documentation

Convert inputs for baggr models

Description

Converts data to a list of inputs suitable for Stan models, checks integrity of data and suggests the appropriate default model if needed. Typically all of this is done automatically by baggr, so this function is included only for debugging or running (custom) models "by hand".

Usage

convert_inputs(
  data,
  model,
  quantiles,
  effect = NULL,
  group = "group",
  outcome = "outcome",
  treatment = "treatment",
  covariates = c(),
  test_data = NULL,
  silent = FALSE
)

Arguments

data

'data.frameā€œ with desired modelling input

model

valid model name used by baggr; see baggr for allowed models if model = NULL, this function will try to find appropriate model automatically

quantiles

vector of quantiles to use (only applicable if model = "quantiles")

effect

Only matters for binary data, use logOR, logRR, or RD. Otherwise ignore. See prepare_ma for details.

group

name of the column with grouping variable

outcome

name of column with outcome variable (designated as string)

treatment

name of column with treatment variable

covariates

Character vector with column names in data. The corresponding columns are used as covariates (fixed effects) in the meta-regression model.

test_data

same format as data argument, gets left aside for testing purposes (see baggr)

silent

Whether to print messages when evaluated

Details

Typically this function is only called within baggr and you do not need to use it yourself. It can be useful to understand inputs or to run models which you modified yourself.

Value

R structure that's appropriate for use by baggr Stan models; group_label, model, effect and n_groups are included as attributes and are necessary for baggr to work correctly

Author(s)

Witold Wiecek

Examples

# simple meta-analysis example,
# this is the formatted input for Stan models in baggr():
convert_inputs(schools, "rubin")

baggr documentation built on March 31, 2023, 10:02 p.m.