create_standata_outcome: Create List for Fitting Outcome Model via STAN

Description Usage Arguments Details See Also

View source: R/functions_outcome_model.R

Description

Generates a 'standata_outcome' object from a 'long' data frame of outcome data

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
create_standata_outcome(..., datalist = NULL, Mtlist = NULL, covarslist = NULL)

create_standata_outcome_singlestudy(
  data = NULL,
  unit_id = data$unit_id,
  conc = data$conc,
  study = data$study,
  clust_id = data$clust_id,
  case = data$case,
  at_risk = data$at_risk,
  covars = "1",
  scale_covars = TRUE,
  xdf = 1,
  xfn = "iSpline",
  xfnargs = list(),
  Mt = NULL,
  timefn = "ns",
  timedf = 0,
  timefnargs = list(),
  return_addition = FALSE
)

Arguments

...

arguments passed to create_standata_outcome_singlestudy. See Details.

datalist

List of data frames, containing the data in 'long' format.

Mtlist

time spline matrix, or a list of such matrices.

covarslist

list of covariate variable names for each study, or a list of covariate matrices.

data

Optional data frame containing data in a long format.

unit_id

Vector identifying the distinct unit (e.g. person) for each observation.

conc

Vector of exposure concentrations for each observation.

study

Vector identifying the study of each observation.

clust_id

Optional vector identifying cluster membership for each observation.

case

Count of cases for the observations. In most cases, this is a 0/1 indicator.

at_risk

Time at risk for the observation

covars

character vector of variables to include as covariates, or a vector/matrix of covariate values. Should not include an intercept. If a character vector, this intercept is automatically removed (so default of "1" leads to no covariates).

scale_covars

should the covariate matrix be centered and scaled?

xdf

Degrees of freedom for exposure splines

xfn

name of function used to generate exposure splines

xfnargs

named list of additional arguments for xfn

Mt

Optional matrix of time splines

timefn

name of function used to generate time splines

timedf

degrees of freedom for time spline

timefnargs

named list of additional arugments to timefn

return_addition

should the modified version of data be returned in addition to the standata_outcome object?

Details

An important special case of create_standata_outcome is when there is only a single study. In this case, the values are passed to create_standata_outcome_singlestudy without pre-processing.

If using a separate temporal spline for each study, first compute the time splines for each study individually using create_spline. Combine these into a list and pass that to Mtlist.

The matrices of adjustment variables are created using the names provided to covarslist. This is done using formula and model.matrix, so transformations and interactions can be used in the typical manner.

See Also

create_standata_exposure, add_spline_exposure, sample_outcome_model


jpkeller/bercs documentation built on March 24, 2021, 5:36 a.m.