Created
May 3, 2021 21:57
-
-
Save tvladeck/6d7659056a5a21da14497669dad7968c to your computer and use it in GitHub Desktop.
vaccine threshold price model
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
data { | |
int n_respondents; | |
int n_choices; | |
int n_vaccines; | |
int responses[n_choices]; | |
int respondent[n_choices]; | |
int vaccine[n_choices]; | |
vector[n_choices] money; | |
} | |
parameters { | |
real intercept; | |
vector[n_respondents] a_respondent; | |
real<lower=0> b_money; | |
vector[n_vaccines] a_vaccine; | |
} | |
transformed parameters { | |
vector[n_respondents] respondent_intercept = intercept + a_respondent; | |
vector[n_choices] phi; | |
for(i in 1:n_choices) { | |
phi[i] = respondent_intercept[respondent[i]] + | |
b_money * money[i] + | |
a_vaccine[vaccine[i]]; | |
} | |
} | |
model { | |
intercept ~ normal(0, 1); | |
a_respondent ~ normal(0, .5); | |
a_vaccine ~ normal(0, .5); | |
b_money ~ exponential(1); | |
responses ~ bernoulli_logit(phi); | |
} | |
generated quantities { | |
matrix[n_respondents, n_vaccines] threshold_payment; | |
for(i in 1:n_respondents) { | |
for(j in 1:n_vaccines) { | |
threshold_payment[i, j] = -(respondent_intercept[respondent[i]] + a_vaccine[j]) / b_money; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment