Last active
August 20, 2018 15:26
-
-
Save fusaroli/6d4a406549c3750be3b786bd5790c041 to your computer and use it in GitHub Desktop.
This file contains 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
// contest model | |
data{ | |
int N_choices; // amount of data points | |
int N_items; // unique stimuli | |
int N_raters; // unique raters | |
int y[N_choices]; // outcome | |
int item1[N_choices]; // which stimulus 1 in each trials | |
int item2[N_choices]; // which stimulus 2 in each trials | |
int rater[N_choices]; // which rater in each trials | |
real Period[N_items]; // item feature: period | |
// real v[N_raters]; // rater feature | |
} | |
parameters{ | |
real PeriodB; | |
// real bvx; | |
vector[N_items] StimulusIntercept; // random intercept of item | |
vector[N_raters] PeriodSubject; // random slope of period over raters | |
real<lower=0> sigma_items; | |
real<lower=0> sigma_raters; | |
} | |
model{ | |
vector[N_choices] logit_p; | |
real wx; | |
real a1; | |
real a2; | |
PeriodB ~ normal(0,4); | |
//bvx ~ normal(0,1); | |
StimulusIntercept ~ normal(0,1); | |
PeriodSubject ~ normal(0,1); | |
sigma_items ~ exponential(1); | |
sigma_raters ~ exponential(1); | |
for ( i in 1:N_choices ) { | |
wx = PeriodB + PeriodSubject[ rater[i] ] * sigma_raters; | |
a1 = StimulusIntercept[item1[i]] * sigma_items + wx * Period[item1[i]]; | |
a2 = StimulusIntercept[item2[i]] * sigma_items + wx * Period[item2[i]]; | |
logit_p[i] = a1 - a2; | |
} | |
y ~ bernoulli_logit( logit_p ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment