knitr::opts_chunk$set( collapse = TRUE, comment = "#>" )
library(odin2data)
test_data <- data.frame( t = 1:5, incidence = c(20, 49, 109, 184, 206) / 1000 )
knitr::kable(test_data)
f <- system.file("models/SIR.txt", package = "odin2data") test_m <- odin::odin(f, verbose=F)
r_prior <- function() { list( beta = runif(1, 1, 10), gamma = runif(1, .1, 1) ) } d_prior <- function(pars) { dunif(pars$beta, 1, 10, log = T) + dunif(pars$gamma, .1, 1, log = T) }
times = seq(0, 10, 0.2) y0 <- c(995, 5, 0) sim <- compile_model(r_prior = r_prior, d_prior = d_prior, y0 = y0, ts_sim = times, m_sim = test_m) lf <- compile_model_likefree(test_data, sim)
pars <- lf$Model$r_prior() calc_dist(lf, pars)
fitted <- fit_abc(lf, 100, target_acc = 0.3)
knitr::kable(summary(fitted)$Post, digits = 2)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.