This function simulates repeated measurements of normally-distributed covariates, binary treatments, and an end-of-study outcome for longitudinal causal analyses. When `right_censor = TRUE`, a right-censoring indicator `Cj` is generated at each visit: if `Cj = 1`, all subsequent `L`, `A`, and `Y` values are set to `NA`.
Arguments
- n
Integer. Sample size.
- n_visits
Integer. Number of visits (including baseline as visit 1).
- covariate_counts
Integer vector of length `n_visits`. Number of covariates per visit (default: rep(2, n_visits)).
- amodel
List of length `n_visits`. Each element is a named numeric vector of coefficients for the logistic model of treatment `Aj` on covariates (and `A_prev` for j > 1).
- ymodel
Named numeric vector. Coefficients for the end-of-study outcome model. If `y_type = "binary"`, a logistic model is used; if `"continuous"`, a linear model with Gaussian noise.
- y_type
Character. One of "binary" or "continuous".
- right_censor
Logical. If TRUE, generates `Cj` using `cmodel` at each visit.
- cmodel
List of length `n_visits`. Named numeric vectors for logistic censoring models at each visit, regressing `Cj` on covariates and current `Aj`.
- seed
Integer. Optional random seed.