swh:1:snp:4a47993778f3ff3fe6e227d2f4c1a7654fd94e50
Tip revision: 5272bdc62fb3e8845c1b071ad04560f06f4cbcb8 authored by Bob Carpenter on 12 April 2017, 17:34:23 UTC
Merge pull request #67 from stan-dev/feature/knitr-curse-dims
Merge pull request #67 from stan-dev/feature/knitr-curse-dims
Tip revision: 5272bdc
election88_full.stan
data {
int<lower=0> N;
int<lower=0> n_age;
int<lower=0> n_age_edu;
int<lower=0> n_edu;
int<lower=0> n_region_full;
int<lower=0> n_state;
int<lower=0,upper=n_age> age[N];
int<lower=0,upper=n_age_edu> age_edu[N];
vector<lower=0,upper=1>[N] black;
int<lower=0,upper=n_edu> edu[N];
vector<lower=0,upper=1>[N] female;
int<lower=0,upper=n_region_full> region_full[N];
int<lower=0,upper=n_state> state[N];
vector[N] v_prev_full;
int<lower=0,upper=1> y[N];
}
parameters {
vector[n_age] a;
vector[n_edu] b;
vector[n_age_edu] c;
vector[n_state] d;
vector[n_region_full] e;
vector[5] beta;
real<lower=0,upper=100> sigma_a;
real<lower=0,upper=100> sigma_b;
real<lower=0,upper=100> sigma_c;
real<lower=0,upper=100> sigma_d;
real<lower=0,upper=100> sigma_e;
}
transformed parameters {
vector[N] y_hat;
for (i in 1:N)
y_hat[i] <- beta[1] + beta[2] * black[i] + beta[3] * female[i]
+ beta[5] * female[i] * black[i]
+ beta[4] * v_prev_full[i] + a[age[i]] + b[edu[i]]
+ c[age_edu[i]] + d[state[i]] + e[region_full[i]];
}
model {
a ~ normal (0, sigma_a);
b ~ normal (0, sigma_b);
c ~ normal (0, sigma_c);
d ~ normal (0, sigma_d);
e ~ normal (0, sigma_e);
beta ~ normal(0, 100);
y ~ bernoulli_logit(y_hat);
}