Skip to content

Commit

Permalink
Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
andrjohns committed Sep 10, 2023
1 parent 295204a commit 6308b7e
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions inst/stan/chunks/psma_likelihoods.stan
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,19 @@ real normal_lnorm(real theta, real tau, real sigma,
array[] real alpha, vector eta) {
int k = size(alpha);
real cutoff;
real lcdf;
real cdf;
array[k - 1] real summands;
vector[k] log_eta = log(eta);

summands[1] = log_eta[1];
summands[1] = eta[1];

for(i in 2:(k - 1)) {
cutoff = inv_Phi(1 - alpha[i])*sigma;
lcdf = normal_lcdf(cutoff | theta, sqrt(tau * tau + sigma * sigma));
summands[i] = lcdf + log_diff_exp(log_eta[i], log_eta[i - 1]);
cdf = exp(normal_lcdf(cutoff | theta, sqrt(tau * tau + sigma * sigma)));
summands[i] = cdf*(eta[i] - eta[i - 1]);
}


return(log_sum_exp(summands));
return(log(sum(summands)));
}

// Both the prior and likelihood make use of the same normalizing constant from
Expand Down

0 comments on commit 6308b7e

Please sign in to comment.