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.

disruption.stan 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. functions {
  2. vector z_scale(vector x) {
  3. return (x-mean(x))/sd(x);
  4. }
  5. }
  6. data {
  7. int<lower=1> N;
  8. int<lower=1> K;
  9. vector<lower=0>[N] soc_cap;
  10. vector<lower=0>[N] soc_div;
  11. vector<lower=0>[N] int_div;
  12. //vector<lower=0>[N] age;
  13. vector<lower=0>[N] m;
  14. matrix<lower=0,upper=1>[N,K] x;
  15. vector[N] stable;
  16. array [N] int<lower=0,upper=K-1> primary_research_area;
  17. }
  18. transformed data {
  19. vector[N] z_m = z_scale(m);
  20. vector[N] z_soc_cap = z_scale(soc_cap);
  21. vector[N] z_soc_div = z_scale(exp(soc_div));
  22. vector[N] z_int_div = z_scale(exp(int_div));
  23. }
  24. parameters {
  25. real beta_soc_cap;
  26. real beta_soc_div;
  27. real beta_int_div;
  28. real beta_stable;
  29. vector[K] beta_x;
  30. real mu;
  31. real<lower=0> tau;
  32. real<lower=0> sigma;
  33. real lambda_div;
  34. real mu_div;
  35. real<lower=0> sigma_div;
  36. vector<lower=0,upper=1>[K] mu_x;
  37. vector<lower=1>[K] eta;
  38. real<lower=0,upper=1> mu_pop;
  39. real<lower=1> eta_pop;
  40. }
  41. model {
  42. vector[N] beta_research_area;
  43. for (k in 1:N) {
  44. beta_research_area[k] = beta_x[primary_research_area[k]+1];
  45. }
  46. vector[N] res_soc_div = z_scale(soc_div - (lambda_div*z_int_div + mu_div));
  47. beta_soc_cap ~ normal(0, 1);
  48. beta_soc_div ~ normal(0, 1);
  49. beta_int_div ~ normal(0, 1);
  50. beta_x ~ normal(0, tau);
  51. beta_stable ~ normal(0, 1);
  52. z_soc_div ~ normal(lambda_div*z_int_div + mu_div, sigma_div);
  53. lambda_div ~ normal(0, 1);
  54. mu_div ~ normal(0, 1);
  55. sigma_div ~ exponential(1);
  56. mu ~ normal(0, 1);
  57. tau ~ exponential(1);
  58. sigma ~ exponential(1);
  59. z_m ~ normal(beta_soc_cap*z_soc_cap + beta_soc_div*res_soc_div + beta_int_div*z_int_div + beta_stable*stable + beta_research_area + mu, sigma);
  60. eta ~ pareto(1, 1.5);
  61. mu_x ~ uniform(0, 1);
  62. eta_pop ~ pareto(1, 1.5);
  63. mu_pop ~ uniform(0, 1);
  64. for (k in 1:N) {
  65. m[k] ~ beta_proportion(mu_x[primary_research_area[k]+1], eta[primary_research_area[k]+1]);
  66. }
  67. m ~ beta_proportion(mu_pop, eta_pop);
  68. }
  69. generated quantities {
  70. real R2 = 0;
  71. {
  72. vector[N] beta_research_area;
  73. for (k in 1:N) {
  74. beta_research_area[k] = beta_x[primary_research_area[k]+1];
  75. }
  76. vector[N] res_soc_div = z_scale(soc_div - (lambda_div*z_int_div + mu_div));
  77. vector[N] pred = beta_soc_cap*z_soc_cap + beta_soc_div*res_soc_div + beta_int_div*z_int_div + beta_stable*stable + beta_research_area + mu;
  78. R2 = mean(square(z_m-pred))/variance(z_m);
  79. R2 = 1-R2;
  80. }
  81. }