Supplementary materials for the manuscript "Latent-class trajectory modeling with a heterogeneous mean-variance relation" by N. G. P. Den Teuling, F. Ungolo, S.C. Pauws, and E.R. van den Heuvel
This repository contains the source code for the conditional growth mixture Stan models, the estimation of the marginal loglikelihood thereof, and for running and analyzing the simulation study and case study.
- Install R.
- Create an
.Rprofile
file with the following content, and fill in the placeholders:
source("renv/activate.R")
FIG_DIR = 'figs'
RESULTS_DIR = 'results'
TABLES_DIR = 'tables'
COVID_DATA_DIR = '~/data/csse_covid_19_data' # set to correct folder
REDIS_HOST_FILE = file.path('redis', 'redis_host.txt') # used by worker.R to connect to the Redis server
options(
redis.host = 'localhost',
redis.port = 6379,
redis.pwd = '', # set password if configured
latrend.warnMetricOverride = FALSE,
mc.cores = parallel::detectCores(logical = FALSE)
)
source('include.R')
- Install the required packages via
renv::restore()
or manually.
In case you want to run the simulation or case study, proceed with the next steps.
- Install Redis.
- Configure Redis and the credentials in the
.Rprofile
file. - Run Redis
- Test if you can connect from R by running
sim_init()
. - Submit jobs, e.g., by running sim_all.R.
- Run worker.R as one or more stand-alone processes, e.g., by executing
worker6.bat
on Windows. - Wait a long time for computations to finish.
- Collect and process results (in case of the simulation study) by running process_results.R.
The simulation datasets for a given simulation scenario can be generated using the gen_gtsdata()
function located in data/util_datasets.R`.
The simulation settings are stored in data/datasets_sim.R.
The case study data was obtained from the COVID-19 Data Repository by the Center for Systems Science and Engineering (CSSE) at Johns Hopkins University.
To obtain the final processed dataset used in our case study analysis, run the load_csse_covid19_data()
function located in data/data_covid.R.