# Untitled

a guest
Mar 26th, 2021
29
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
1. data{
2. int count[128];
3. vector[128] time;
4. }
5. parameters{
6. real logK1_std;
7. real<lower=0> r1_std;
8. real<lower=0, upper = 1> L01_prop;
9. real logK2_std;
10. real<lower=0> neg_r2_std;
11. real<lower=0, upper = 1> L02_prop;
12. real<lower=0> theta_std;
13. }
14. transformed parameters{
15. real<lower = 0> K1 = exp(log(10) + logK1_std * 3 * log(10));
16. real<lower = 0> K2 = exp(log(10) + logK2_std * 3 * log(10));
17. real<lower = 0> L01 = K1 * L01_prop;
18. real<lower = 0> L02 = K2 * L02_prop;
19. real<lower = 0> r1 = r1_std / 1;
20. real<upper = 0> r2 = -neg_r2_std / 1;
21. real<lower=0> theta = theta_std / 0.5;
22. }
23. model{
24. vector[128] lambda;
25. vector[128] alpha;
26. vector[128] beta;
27. theta_std ~ exponential( 1 );
28.
29. //growth model
30. r1_std ~ exponential( 1 );
31. L01_prop ~ beta(1, 100);
32. logK1_std ~ std_normal();
33.
34. //decay model
35. neg_r2_std ~ exponential( 1 );
36. L02_prop ~ beta(100, 1);
37. logK2_std ~ std_normal();
38.
39. //mathemagically combine them
40. for ( i in 1:128 ) {
41. lambda[i] = K1 / (1 + ((K1 - L01) / L01) * exp(-r1 * time[i])) +
42. K2 / (1 + ((K2 - L02) / L02) * exp(-r2 * time[i]));
43. alpha[i] = lambda[i] / theta;
44. beta[i] = 1 / theta;
45. }
46.
47. //evaluate likelihood
48. count ~ neg_binomial( alpha , beta );
49. }
50. generated quantities{
51. //none for now
52. }
RAW Paste Data