12345678910111213141516171819202122232425262728293031323334353637383940 |
- data {
- int N;
- vector<lower=0>[N] age;
- vector<lower=0,upper=1>[N] ratio;
- }
- transformed data {
- int M = 500;
- real lambda = -log(M);
- vector<lower=0,upper=5>[M] c;
- for (i in 1:M) {
- c[i] = i*5.0/(1.0*M);
- }
- }
- parameters {
- real<lower=0,upper=1> mu_low;
- real<lower=0,upper=1> mu_up;
- real<lower=1> eta;
- }
- transformed parameters {
- vector[M] lp;
- lp = rep_vector(lambda, M);
-
- for (m in 1:M) {
- for (n in 1:N) {
- lp[m] = lp[m] + beta_proportion_lpdf(ratio[n] | age[n] < c[m] ? mu_low : mu_up, eta);
- }
- }
- }
- model {
- mu_low ~ uniform(0, 1);
- mu_up ~ uniform(0, 1);
- eta ~ pareto(1,1.5);
-
- target += log_sum_exp(lp);
- }
|