-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Agregar más diagnósticos y continuar el ejemplo de variables latentes
- Loading branch information
1 parent
587c623
commit 8c71af7
Showing
7 changed files
with
635 additions
and
1 deletion.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
parameters { | ||
real y; | ||
vector[9] z; | ||
} | ||
|
||
transformed parameters { | ||
vector[9] x; | ||
|
||
x = exp(y/2) * z; | ||
|
||
} | ||
|
||
model { | ||
y ~ normal(0, 3); | ||
z ~ std_normal(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
parameters { | ||
real y; | ||
vector[9] x; | ||
} | ||
model { | ||
y ~ normal(0, 3); | ||
x ~ normal(0, exp(y/2)); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,3 +26,4 @@ model { | |
Q ~ std_normal(); | ||
sigma ~ exponential(1); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
data { | ||
int<lower=0> N; //número de calificaciones | ||
int<lower=0> n_vinos; //número de vinos | ||
int<lower=0> n_jueces; //número de jueces | ||
int<lower=0> n_origen; //número de jueces | ||
vector[N] S; | ||
array[N] int juez; | ||
array[N] int vino; | ||
array[N] int origen; | ||
} | ||
|
||
parameters { | ||
vector[n_vinos] Q; | ||
vector[n_origen] O; | ||
real <lower=0> sigma; | ||
} | ||
|
||
transformed parameters { | ||
vector[N] media_score; | ||
// determinístico dado parámetros | ||
for (i in 1:N){ | ||
media_score[i] = Q[vino[i]] + O[origen[i]]; | ||
} | ||
} | ||
|
||
model { | ||
// partes no determinísticas | ||
S ~ normal(media_score, sigma); | ||
Q ~ std_normal(); | ||
O ~ std_normal(); | ||
sigma ~ exponential(1); | ||
} | ||
|
||
generated quantities { | ||
real dif_origen; | ||
dif_origen = O[1] - O[2]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
data { | ||
int<lower=0> N; //número de calificaciones | ||
int<lower=0> n_vinos; //número de vinos | ||
int<lower=0> n_jueces; //número de jueces | ||
int<lower=0> n_origen; //número de jueces | ||
vector[N] S; | ||
array[N] int juez; | ||
array[N] int vino; | ||
array[N] int origen; | ||
} | ||
|
||
parameters { | ||
vector[n_vinos] Q; | ||
vector[n_origen] O; | ||
vector[n_jueces] H; | ||
vector<lower=0>[n_jueces] D; | ||
|
||
real <lower=0> sigma; | ||
} | ||
|
||
transformed parameters { | ||
vector[N] media_score; | ||
// determinístico dado parámetros | ||
for (i in 1:N){ | ||
media_score[i] = (Q[vino[i]] + O[origen[i]] - H[juez[i]]) * D[juez[i]]; | ||
} | ||
} | ||
|
||
model { | ||
// partes no determinísticas | ||
S ~ normal(media_score, sigma); | ||
Q ~ std_normal(); | ||
O ~ std_normal(); | ||
H ~ std_normal(); | ||
D ~ std_normal(); | ||
sigma ~ exponential(1); | ||
} | ||
|
||
generated quantities { | ||
real dif_origen; | ||
dif_origen = O[1] - O[2]; | ||
} |