Skip to content

Commit

Permalink
Modified vignette with better example
Browse files Browse the repository at this point in the history
  • Loading branch information
gvegayon committed Nov 20, 2024
1 parent 8c151a7 commit 24a0b96
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions vignettes/likelihood-free-mcmc.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ model_seed <- 122
model_sir <- ModelSIR(
name = "COVID-19",
prevalence = .1,
transmission_rate = .9,
transmission_rate = .3,
recovery_rate = .3
)
Expand All @@ -58,7 +58,7 @@ summary(model_sir)
## Setup LFMCMC
```{r lfmcmc-setup}
# Extract the observed data from the model
obs_data <- unname(as.integer(get_today_total(model_sir)))
obs_data <- get_today_total(model_sir)
# Define the LFMCMC simulation function
simfun <- function(params) {
Expand All @@ -71,8 +71,8 @@ simfun <- function(params) {
ndays = 50
)
res <- unname(as.integer(get_today_total(model_sir)))
return(res)
get_today_total(model_sir)
}
# Define the LFMCMC summary function
Expand All @@ -83,7 +83,7 @@ sumfun <- function(dat) {
# Define the LFMCMC proposal function
# - Based on proposal_fun_normal from lfmcmc-meat.hpp
propfun <- function(params_prev) {
res <- params_prev + rnorm(length(params_prev), )
res <- plogis(qlogis(params_prev) + rnorm(length(params_prev)))
return(res)
}
Expand All @@ -95,7 +95,7 @@ kernelfun <- function(stats_now, stats_obs, epsilon) {
stats_obs,
stats_now))
return(ifelse(sqrt(ans) < epsilon, 1.0, 0.0))
dnorm(sqrt(sum((stats_now - stats_obs)^2)))
}
# Create the LFMCMC model
Expand Down

0 comments on commit 24a0b96

Please sign in to comment.