Scheduled service maintenance on November 22


On Friday, November 22, 2024, between 06:00 CET and 18:00 CET, GIN services will undergo planned maintenance. Extended service interruptions should be expected. We will try to keep downtimes to a minimum, but recommend that users avoid critical tasks, large data uploads, or DOI requests during this time.

We apologize for any inconvenience.

Browse Source

[DATALAD] Recorded changes

Lucas Gautheron 1 month ago
parent
commit
b0281048b8

+ 4 - 0
code/models/algo_only.stan

@@ -105,4 +105,8 @@ model {
 
     // priors on the hierarchical model of speech behavior
     #include "blocks/behavior_model_priors.stan"
+}
+
+generated quantities {
+    #include "blocks/behavior_model_generated.stan"
 }

+ 9 - 0
code/models/blocks/behavior_model_generated.stan

@@ -0,0 +1,9 @@
+real adu_proportion_pop_level = 0.0;
+real fem_proportion_pop_level = 0.0;
+{
+    real mu_och = p_sib*mu_pop_level[2]+(1-p_sib)*mu_pop_level[2]*exp(beta_sib_och);
+    real mu_fem = p_sib*mu_pop_level[3]+(1-p_sib)*mu_pop_level[3]*exp(beta_sib_adu/10.0);
+    real mu_adu = p_sib*(mu_pop_level[3]+mu_pop_level[4])+(1-p_sib)*(mu_pop_level[3]+mu_pop_level[4])*exp(beta_sib_adu/10.0);
+    adu_proportion_pop_level = mu_adu/(mu_adu+mu_och);
+    fem_proportion_pop_level = mu_fem/mu_adu;
+}

+ 1 - 4
code/models/blocks/behavior_model_parameters.stan

@@ -17,7 +17,4 @@ real<lower=0> sigma_dev;
 
 // effect of excess ADU input
 real beta_dev;
-real beta_direct;
-
-// effect of mal on fem
-real beta_mal_fem;
+real beta_direct;

+ 4 - 5
code/models/blocks/behavior_model_priors.stan

@@ -1,12 +1,12 @@
 alpha_child_level ~ gamma(4,1);
 mu_pop_level ~ exponential(4); // 250 vocs/hour
-alpha_pop_level ~ gamma(8, 4); // sd = 0.35 x \mu
+alpha_pop_level ~ gamma(25, 1); // sd = 0.35 x \mu
 //alpha_pop ~ gamma(10, 10);
 for (i in 1:n_classes-1) {
     //alpha_corpus_level[1,i] ~ gamma(4, 4/alpha_pop[i]);
     //alpha_corpus_level[2,i] ~ gamma(4, 4/alpha_pop[i]);
-    alpha_corpus_level[1,i] ~ gamma(4, 2);
-    alpha_corpus_level[2,i] ~ gamma(4, 2);
+    alpha_corpus_level[1,i] ~ gamma(8, 1);
+    alpha_corpus_level[2,i] ~ gamma(8, 1);
     mu_corpus_level[i,:] ~ gamma(alpha_pop_level[i],alpha_pop_level[i]/mu_pop_level[i+1]);
 }
 
@@ -18,5 +18,4 @@ beta_sib_adu ~ normal(0, 1);
 alpha_dev ~ normal(0, 1);
 sigma_dev ~ exponential(1);
 beta_dev ~ normal(0, 1);
-beta_direct ~ normal(0, 1);
-beta_mal_fem ~ normal(0, 1);
+beta_direct ~ normal(0, 1);

+ 18 - 18
code/models/blocks/behavior_model_truth.stan

@@ -6,49 +6,49 @@ real recs_priors_lpmf(array[] int children,
     array [] real age,
     matrix truth_vocs,
     vector mu_pop_level,
+    real mu_adu,
     matrix mu_child_level,
     vector alpha_child_level,
     real extra_chi_sd,
     vector child_dev_age,
     real beta_dev,
-    real beta_direct,
-    real beta_mal_fem
+    real beta_direct
     ) {
         real ll = 0;
         
         for (k in start:end) {
-            real expected_adu_input = mu_child_level[children[k-start+1],2]*exp((truth_vocs[k,4]/1000/recs_duration/mu_pop_level[4]-1)*beta_mal_fem/10.0) + mu_child_level[children[k-start+1],3];
+            real expected_adu_input = mu_child_level[children[k-start+1],2] + mu_child_level[children[k-start+1],3];
             real chi_mu = mu_pop_level[1]*exp(
                 (child_dev_age[children[k-start+1]])*age[k]/12.0
-                +(expected_adu_input/(mu_pop_level[3]+mu_pop_level[4])-1.0)*(beta_dev*age[k]/12.0/10.0)
-                +(((truth_vocs[k,3]+truth_vocs[k,4])/1000/recs_duration)/expected_adu_input-1.0)*(beta_direct/10.0)
+                +((expected_adu_input-mu_adu)/mu_adu)*(beta_dev*age[k]/12.0/10.0)
+                +(((truth_vocs[k,3]+truth_vocs[k,4]-expected_adu_input)/1000/recs_duration)/expected_adu_input)*(beta_direct/10.0)
             );
             
             // gamma with fixed mean (chi_mu) and sd (chi_mu/alpha_child_level[1] + extra_chi_sd)
             //real b = chi_mu/(square(chi_mu)/alpha_child_level[1]+square(extra_chi_sd));
-            real b = chi_mu/(square(chi_mu)/alpha_child_level[1]);
-            real a = chi_mu*b;
-            ll += gamma_lpdf(truth_vocs[k,1]/1000/recs_duration | a, b);
+            // real b = chi_mu/(square(chi_mu)/alpha_child_level[1]);
+            // real a = chi_mu*b;
+            ll += gamma_lpdf(truth_vocs[k,1]/1000/recs_duration | alpha_child_level[1], alpha_child_level[1]/chi_mu);
 
             // lognormal with fixed mean (chi_mu) and sd (chi_mu/alpha_child_level[1] + extra_chi_sd)
             //real mu = log(square(chi_mu)/sqrt(square(chi_mu)*(1+1.0/alpha_child_level[1])+square(extra_chi_sd)));
             //real sigma = log(1+1/alpha_child_level[1]+square(extra_chi_sd/chi_mu));
             //ll += lognormal_lpdf(truth_vocs[k,1]/1000/recs_duration | mu, sigma);
 
-            // OCH
+            // Other speakers
             ll += gamma_lpdf(
-                truth_vocs[k,2]/1000/recs_duration | alpha_child_level[2], alpha_child_level[2]/mu_child_level[children[k-start+1],1]
+                truth_vocs[k,2:]/1000/recs_duration | alpha_child_level[2:], alpha_child_level[2:]./mu_child_level[children[k-start+1],2:]' //'
             );
 
-            // FEM
-            ll += gamma_lpdf(
-                truth_vocs[k,3]/1000/recs_duration | alpha_child_level[3], alpha_child_level[3]/(mu_child_level[children[k-start+1],2]*exp((truth_vocs[k,4]/1000/recs_duration/mu_pop_level[4]-1)*beta_mal_fem/10.0))
-            );
+            // // FEM
+            // ll += gamma_lpdf(
+            //     truth_vocs[k,3]/1000/recs_duration | alpha_child_level[3], alpha_child_level[3]/(mu_child_level[children[k-start+1],2]
+            // );
 
-            // MAL
-            ll += gamma_lpdf(
-                truth_vocs[k,4]/1000/recs_duration | alpha_child_level[4], alpha_child_level[4]/mu_child_level[children[k-start+1],3]
-            );
+            // // MAL
+            // ll += gamma_lpdf(
+            //     truth_vocs[k,4]/1000/recs_duration | alpha_child_level[4], alpha_child_level[4]/mu_child_level[children[k-start+1],3]
+            // );
         }
 
         return ll;

+ 4 - 2
code/models/blocks/behavior_observations_model.stan

@@ -1,10 +1,12 @@
 // P(recs|child)
+real mu_adu = p_sib*(mu_pop_level[3]+mu_pop_level[4])+(1-p_sib)*(mu_pop_level[3]+mu_pop_level[4])*exp(beta_sib_adu/10.0);
+
 target += reduce_sum(
     recs_priors_lpmf, children, 1,
     n_recs, n_classes, recs_duration, age,
     truth_vocs,
-    mu_pop_level, mu_child_level, alpha_child_level, extra_chi_sd,
-    child_dev_age, beta_dev, beta_direct, beta_mal_fem
+    mu_pop_level, mu_adu, mu_child_level, alpha_child_level, extra_chi_sd,
+    child_dev_age, beta_dev, beta_direct
 );
 
 // P(child|corpus)

+ 3 - 1
code/models/blocks/human_annotations.stan

@@ -1,6 +1,8 @@
+real mu_adu = p_sib*(mu_pop_level[3]+mu_pop_level[4])+(1-p_sib)*(mu_pop_level[3]+mu_pop_level[4])*exp(beta_sib_adu/10.0);
+
 for (g in 1:n_rates) {
     real chi_mu = mu_pop_level[1]*exp(
-        (alpha_dev+sigma_dev*child_dev_speech_age[speech_rate_child[g]])*speech_rate_age[g]/12.0 + ((speech_rate_child_level[speech_rate_child[g],2]+speech_rate_child_level[speech_rate_child[g],3])/(mu_pop_level[3]+mu_pop_level[4])-1.0)*(beta_dev*speech_rate_age[g]/12.0/10.0)+(beta_direct/10.0)*(sum(speech_rate[3:,g])/(speech_rate_child_level[speech_rate_child[g],2]+speech_rate_child_level[speech_rate_child[g],3])-1.0)
+        (alpha_dev+sigma_dev*child_dev_speech_age[speech_rate_child[g]])*speech_rate_age[g]/12.0 + ((speech_rate_child_level[speech_rate_child[g],2]+speech_rate_child_level[speech_rate_child[g],3])/mu_adu-1.0)*(beta_dev*speech_rate_age[g]/12.0/10.0)+(beta_direct/10.0)*(sum(speech_rate[3:,g])/(speech_rate_child_level[speech_rate_child[g],2]+speech_rate_child_level[speech_rate_child[g],3])-1.0)
     );
     speech_rate[1,g] ~ gamma(
         alpha_child_level[1],

+ 4 - 0
code/models/dev.stan

@@ -121,4 +121,8 @@ model {
 
     // priors on the hierarchical model of speech behavior
     #include "blocks/behavior_model_priors.stan"
+}
+
+generated quantities {
+    #include "blocks/behavior_model_generated.stan"
 }

+ 4 - 0
code/models/human.stan

@@ -92,4 +92,8 @@ model {
     
     // human annotations contribution
     #include "blocks/human_annotations.stan"
+}
+
+generated quantities {
+    #include "blocks/behavior_model_generated.stan"
 }