This function assists the implemention of a restriction on a covariate in the date table newdf. A particular covariate is simulated only when some condition (usually a covariate representing whether a doctor's visit occurred or not) is TRUE. If the condition is FALSE, the covariate value is not simulated for that time point and the value is instead carried over from the previous time point.
carry_forward(newdf, pool, restriction, time_name, t, int_visit_type, intvar)
Arguments
newdf: Data table containing the simulated data at time t.
pool: Data table containing the simulated data at times before t.
restriction: List of vectors. Each vector contains as its first entry the covariate affected by the restriction; its second entry the condition that must be TRUE for the covariate to be modeled; its third entry a function that executes other specific actions based on the condition (in this case, this function); and its fourth entry some value used by the function (in this case, this entry is not used).
time_name: Character string specifying the name of the time variable in pool and newdf.
t: Integer specifying the current time index.
int_visit_type: Logical scalar specifying whether to carry forward the intervened value (rather than the natural value) of the treatment variables(s) when performing a carry forward restriction type
intvar: A vector specifying the name(s) of the variable(s) to be intervened on.
Returns
No value is returned. The data table newdf is modified in place.