make_histories: Generates Functions of History of Existing Covariates

View source: R/histories.R

make_historiesR Documentation

Generates Functions of History of Existing Covariates

Description

This internal function applies the history functions to create new columns in an input data table containing new variables that are functions of the histories of existing variables in the dataset.

Usage

make_histories(
  pool,
  histvars,
  histvals,
  histories,
  time_name,
  t,
  id,
  max_visits,
  baselags,
  below_zero_indicator
)

Arguments

pool

Data table containing all information prior to time t (t noninclusive).

histvars

List of vectors. The kth vector specifies the names of the variables for which the kth history function in histories is to be applied.

histvals

List of length two. The first element is a numeric vector specifying the lags used in the model statements (e.g., if lag1_varname and lag2_varname were included in the model statements, this vector would be c(1,2)). The second element is a numeric vector specifying the lag averages used in the model statements.

histories

Vector of history functions to apply to the variables specified in histvars.

time_name

Character string specifying the name of the time variable in pool.

t

Integer specifying the current time index.

id

Character string specifying the name of the ID variable in pool.

max_visits

A vector of one or more values denoting the maximum number of times a binary covariate representing a visit process may be missed before the individual is censored from the data (in the observed data) or a visit is forced (in the simulated data). Multiple values exist in the vector when the modeling of more than covariate is attached to a visit process. A value of NA should be provided when there is no visit process.

baselags

Logical scalar for specifying the convention used for lagi and lag_cumavgi terms in the model statements when pre-baseline times are not included in obs_data and when the current time index, t, is such that t < i. If this argument is set to FALSE, the value of all lagi and lag_cumavgi terms in this context are set to 0 (for non-categorical covariates) or the reference level (for categorical covariates). If this argument is set to TRUE, the value of lagi and lag_cumavgi terms are set to their values at time 0. The default is FALSE.

below_zero_indicator

Logical scalar indicating whether the observed data set contains rows for time t < 0.

Value

No value is returned. The data table pool is modified in place.


gfoRmula documentation built on Oct. 1, 2024, 9:06 a.m.