This is an umbrella issue to start refactoring the code into something more reusable, sustainable and testable. The idea would be to have the code for Model 1 split in different files depending on its functionality. A possible structure could be the following (feel free to use other names):
main_1.Rmd: Rmarkdown file that explains what is all about, where the input parameters for the simulated data and the fitting routine are explained and defined, where the relevant auxiliary R files are sourced, and run.
models.R: To include the different models, like SEIR.
simulated_data.R: Contains the functions required to simulate a dataset.
fit_data.R: Contains not only the actual call to the Stan functions, but also any pre- and post-processing steps.
The last 3 files only contain functions, not declaration of parameters. Those are declared in the Rmd file and provided as inputs to the functions. Use input arguments with default values for those cases where the user is not likely to change the value you set.
The Rmd file should be heavily documented with high level explanations of what is going on and what each input represents. In the others, each function should be appropriately documented, but that documentation would be more technical and using appropriate formatting.
This is an umbrella issue to start refactoring the code into something more reusable, sustainable and testable. The idea would be to have the code for Model 1 split in different files depending on its functionality. A possible structure could be the following (feel free to use other names):
main_1.Rmd
: Rmarkdown file that explains what is all about, where the input parameters for the simulated data and the fitting routine are explained and defined, where the relevant auxiliaryR
files are sourced, and run.models.R
: To include the different models, like SEIR.simulated_data.R
: Contains the functions required to simulate a dataset.fit_data.R
: Contains not only the actual call to the Stan functions, but also any pre- and post-processing steps.The last 3 files only contain functions, not declaration of parameters. Those are declared in the
Rmd
file and provided as inputs to the functions. Use input arguments with default values for those cases where the user is not likely to change the value you set.The
Rmd
file should be heavily documented with high level explanations of what is going on and what each input represents. In the others, each function should be appropriately documented, but that documentation would be more technical and using appropriate formatting.Issues: