diff --git a/notas/src/heart-agregado.stan b/notas/src/heart-agregado.stan new file mode 100644 index 0000000..85c60a7 --- /dev/null +++ b/notas/src/heart-agregado.stan @@ -0,0 +1,30 @@ +data { + int N; + array[N] int e; + array[N] int y; +} + +parameters { + real lambda; +} + +transformed parameters { + vector[N] media_hospital; + // lambda es por cada 1000 expuestos: + for (i in 1:N){ + media_hospital[i] = lambda * e[i] / 1000; + } +} + +model { + // partes no determinísticas + y ~ poisson(media_hospital); + lambda ~ exponential(1); +} + +generated quantities { + array[N] int y_sim; + for (i in 1:N){ + y_sim[i] = poisson_rng(media_hospital[i]); + } +} diff --git a/notas/src/heart-individual.stan b/notas/src/heart-individual.stan new file mode 100644 index 0000000..7fd6376 --- /dev/null +++ b/notas/src/heart-individual.stan @@ -0,0 +1,30 @@ +data { + int N; + array[N] int e; + array[N] int y; +} + +parameters { + vector[N] lambda; +} + +transformed parameters { + vector[N] media_hospital; + // lambda es por cada 1000 expuestos: + for (i in 1:N){ + media_hospital[i] = lambda[i] * e[i] / 1000; + } +} + +model { + // partes no determinísticas + y ~ poisson(media_hospital); + lambda ~ exponential(1); +} + +generated quantities { + array[N] int y_sim; + for (i in 1:N){ + y_sim[i] = poisson_rng(media_hospital[i]); + } +} diff --git a/notas/src/heart-jerarquico.stan b/notas/src/heart-jerarquico.stan new file mode 100644 index 0000000..1684aa3 --- /dev/null +++ b/notas/src/heart-jerarquico.stan @@ -0,0 +1,34 @@ +data { + int N; + array[N] int e; + array[N] int y; +} + +parameters { + vector[N] lambda; + real alpha; + real mu; +} + +transformed parameters { + vector[N] media_hospital; + // lambda es por cada 1000 expuestos: + for (i in 1:N){ + media_hospital[i] = lambda[i] * e[i] /1000; + } +} + +model { + // partes no determinísticas + y ~ poisson(media_hospital); + lambda ~ gamma(alpha, alpha / mu); + mu ~ exponential(1); + alpha ~ exponential(1); +} + +generated quantities { + array[N] int y_sim; + for (i in 1:N){ + y_sim[i] = poisson_rng(media_hospital[i]); + } +}