1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768 |
- functions {
- #include "blocks/confusion_model_binomial_hurdle_fast.stan"
- }
- // TODO
- // use speech rates to set priors on truth_vocs
- data {
- int<lower=1> n_classes; // number of classes
- // speaker confusion data block
- int<lower=1> n_clips; // number of clips
- int<lower=1> n_groups; // number of groups
- int<lower=1> n_corpora;
- array [n_clips] int group;
- array [n_clips] int conf_corpus;
- array [n_clips,n_classes] int<lower=0> algo_total; // algo vocs attributed to specific speakers
- array [n_clips,n_classes] int<lower=0> truth_total;
- array [n_clips] real<lower=0> clip_duration;
- array [n_clips] real<lower=0> clip_age;
- int<lower=0> n_validation;
-
- // parallel processing
- int<lower=1> threads;
- }
- transformed data {
- array [n_groups,n_classes] int group_truth;
- for (i in 1:n_classes) {
- for (g in 1:n_groups) {
- group_truth[g,i] = 0;
- }
- for (c in 1:n_clips) {
- group_truth[group[c],i] += truth_total[c,i];
- }
- }
-
- }
- parameters {
- #include "blocks/confusion_model_parameters_binomial_hurdle.stan"
- }
- model {
- target += reduce_sum(
- confusion_model_lpdf, lambda, 1,
- n_classes, n_clips,
- algo_total, truth_total, group, clip_duration, clip_age,
- p
- );
- #include "blocks/confusion_model_priors_binomial_hurdle.stan"
- }
- generated quantities {
- array [n_groups,n_classes] int sim_vocs_given_lambda;
- array [n_groups,n_classes] int sim_vocs;
- for (g in 1:n_groups) {
- for (i in 1:n_classes) {
- array [n_classes] int n = binomial_rng(group_truth[g,:], lambda[g,:,i]);
- sim_vocs_given_lambda[g,i] = sum(n)+sum(binomial_rng(n, 1-p[:,i]));
- n = binomial_rng(group_truth[g,:], to_vector(beta_proportion_rng(mus[:,i], etas[:,i])));
- sim_vocs[g,i] = sum(n)+sum(binomial_rng(n, 1-p[:,i]));
- }
- }
- }
|