Created
September 15, 2018 10:20
-
-
Save ito4303/916ae58fdc3a2308b8c499b1d0058e6c to your computer and use it in GitHub Desktop.
Distance modeling for point transect data, translated from Sec. 8.3.4 of "Applied Hierarchical Modeling in Ecology, vol. 1"
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
data { | |
int<lower = 1> N_D; | |
int<lower = 1> N_ind; | |
real B; | |
int <lower = 1, upper = N_D> D_class[N_ind]; | |
real<lower = 0, upper = B> Delta; // Width of distance bins | |
vector<lower = 0, upper = B>[N_D] Midpt; // Interval mid-points | |
} | |
transformed data { | |
vector<lower = 0, upper = 1>[N_D] pi = 2 * Midpt / square(B) * Delta; | |
} | |
parameters { | |
real<lower = 0> sigma; | |
} | |
transformed parameters { | |
vector<lower = 0, upper = 1>[N_D] p = exp(-(Midpt .* Midpt) | |
/ (2 * square(sigma))); | |
vector<lower = 0, upper = 1>[N_D] f = p .* pi; | |
real pcap = sum(f); | |
simplex[N_D] fc = f / pcap; | |
} | |
model { | |
sigma ~ normal(0, 10); | |
D_class ~ categorical(fc); | |
} | |
generated quantities { | |
real N = N_ind / pcap; | |
real D = N / (pi() * square(B)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment