--- title: "Simulation workflows" author: "Kaique S. Alves" date: "`r Sys.Date()`" output: rmarkdown::html_vignette vignette: > %\VignetteIndexEntry{Simulation workflows} %\VignetteEncoding{UTF-8} %\VignetteEngine{knitr::rmarkdown} --- ```{r setup, message=FALSE, warning=FALSE} library(epifitter) library(ggplot2) library(cowplot) theme_set(cowplot::theme_half_open(font_size = 12)) ``` ## Overview The `sim_` family creates synthetic disease progress curves that match the same model families used by the fitting functions. ## Simulate four canonical curve shapes ```{r} exp_model <- sim_exponential(N = 100, y0 = 0.01, dt = 10, r = 0.045, alpha = 0.2, n = 5) mono_model <- sim_monomolecular(N = 100, y0 = 0.01, dt = 5, r = 0.05, alpha = 0.2, n = 5) log_model <- sim_logistic(N = 100, y0 = 0.01, dt = 5, r = 0.10, alpha = 0.2, n = 5) gomp_model <- sim_gompertz(N = 100, y0 = 0.01, dt = 5, r = 0.07, alpha = 0.2, n = 5) ``` ```{r} exp_plot <- ggplot(exp_model, aes(time, y)) + geom_jitter(aes(y = random_y), width = 0.1, color = "#6c757d") + geom_line(color = "#b56576", linewidth = 0.8) + labs(title = "Exponential") mono_plot <- ggplot(mono_model, aes(time, y)) + geom_jitter(aes(y = random_y), width = 0.1, color = "#6c757d") + geom_line(color = "#588157", linewidth = 0.8) + labs(title = "Monomolecular") log_plot <- ggplot(log_model, aes(time, y)) + geom_jitter(aes(y = random_y), width = 0.1, color = "#6c757d") + geom_line(color = "#355070", linewidth = 0.8) + labs(title = "Logistic") gomp_plot <- ggplot(gomp_model, aes(time, y)) + geom_jitter(aes(y = random_y), width = 0.1, color = "#6c757d") + geom_line(color = "#8d5a97", linewidth = 0.8) + labs(title = "Gompertz") ``` ```{r fig.height=6, fig.width=8, fig.alt="Grid of four simulated disease progress curves showing exponential, monomolecular, logistic, and Gompertz shapes."} plot_grid(exp_plot, mono_plot, log_plot, gomp_plot, ncol = 2) ``` ## Send simulated data into the fitting pipeline ```{r} fit_from_sim <- fit_lin(time = log_model$time, y = log_model$random_y) fit_from_sim$stats_all ```