daily pastebin goal
37%
SHARE
TWEET

Untitled

a guest Sep 14th, 2018 61 Never
Upgrade to PRO!
ENDING IN00days00hours00mins00secs
  1. data {
  2.  int<lower = 1> N_ind;                     // Number of individuals
  3.  int<lower = 1> N_z;                       // Number of augment observed data
  4.  vector<lower = 0>[N_ind] X;               // Observed distance
  5.  int<lower = 0, upper = 1> Y[N_ind + N_z]; // Augumented inds. have y=0 by
  6.                                            // definition
  7.  real B;                                   // Strip half-width
  8.                                            // Larger than max observed distance
  9. }
  10. parameters {
  11.   real<lower = 0> sigma;          // Half-normal scale
  12.   real<lower = 0, upper = 1> psi; // DA parameter
  13.   vector<lower = 0, upper = B>[N_z] x_new;
  14. }
  15. transformed parameters {
  16.   vector<lower = 0, upper = B>[N_ind + N_z] x2 = append_row(X, x_new);
  17.   vector<lower = 0, upper = 1>[N_ind + N_z] p = exp(-(x2 .* x2)
  18.                                                     / (2 * square(sigma)));
  19. }
  20. model {
  21.   X ~ uniform(0, B);
  22.   x_new ~ uniform(0, B);
  23.   for (n in 1:N_ind) {
  24.     target += bernoulli_lpmf(1 | psi) + bernoulli_lpmf(1 | p[n]);
  25.   }  
  26.   for (n in (N_ind + 1):(N_ind + N_z)) {
  27.     target += log_sum_exp(bernoulli_lpmf(0 | psi),
  28.                           bernoulli_lpmf(1 | psi)
  29.                           + bernoulli_lpmf(0 | p[n]));
  30.   }
  31. }
  32. generated quantities {
  33.   int<lower = 0, upper = N_ind + N_z> N = N_ind;
  34.   real D;
  35.   for (n in (N_ind + 1):(N_ind + N_z)) {
  36.     real zp = psi * (1 - p[n]) / (psi * (1 - p[n]) + (1 - psi));
  37.     N = N + bernoulli_rng(zp);
  38.   }
  39.   D = N / 60.0;
  40. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top