Skip to content

Instantly share code, notes, and snippets.

@aakhmetz
Created December 8, 2024 17:02
Show Gist options
  • Save aakhmetz/e3a730ae7cd87a45b86dcb0fe3014437 to your computer and use it in GitHub Desktop.
Save aakhmetz/e3a730ae7cd87a45b86dcb0fe3014437 to your computer and use it in GitHub Desktop.
20241209-Vaccine
{
"a0": 0.700102,
"b0": 1.0,
"n": 94,
"y": 8
}
data { // everything to the right of the | in Bayes' Rule
real<lower = 0> a0; // expectation for normal prior on VE
real<lower = 0> b0; // standard deviation for normal prior on VE
int<lower = 0> n; // number of people with Covid in the RCT
int<lower = 0, upper = n> y; // number of them who were vaccinated
}
parameters { // everything to the left of the | in Bayes' Rule
real<upper = 1> theta; // = 1 - Pr(covid | vax) / Pr(covid | placebo)
}
model { // target has been initialized to zero basically
target += beta_lpdf(theta | a0, b0); // prior log-kernel
target += binomial_lpmf(y | n, theta); // log-likelihood
} // model block is like a function that returns target
generated quantities {
real<lower = 0, upper = 1> VE = (1 - 2 * theta) / (1 - theta);
}
{"title":"Untitled"}
{"num_chains":4,"num_warmup":1000,"num_samples":1000,"init_radius":2}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment