You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/stan-users-guide/latent-discrete.Rmd
+16-18Lines changed: 16 additions & 18 deletions
Original file line number
Diff line number
Diff line change
@@ -4,7 +4,7 @@ Stan does not support sampling discrete parameters. So it is not
4
4
possible to directly translate BUGS or JAGS models with discrete
5
5
parameters (i.e., discrete stochastic nodes). Nevertheless, it is
6
6
possible to code many models that involve bounded discrete
7
-
parameters by marginalizing out the discrete parameters.^[The computations are similar to those involved in expectation maximization (EM) algorithms @dempster-et-al:1977.]
7
+
parameters by marginalizing out the discrete parameters.^[The computations are similar to those involved in expectation maximization (EM) algorithms [@dempster-et-al:1977].]
8
8
9
9
This chapter shows how to code several widely-used models involving
10
10
latent discrete parameters. The next chapter, the [clustering
@@ -29,12 +29,12 @@ exactly the marginalization needed for coding the model in Stan.
29
29
30
30
## Change Point Models {#change-point.section}
31
31
32
-
The first example is a model of coal mining disasters in the U.K. for the years 1851--1962.^[The source of the data is @Jarret:1979, which itself is a note correcting an earlier data collection.]
32
+
The first example is a model of coal mining disasters in the U.K. for the years 1851--1962.^[The source of the data is [@Jarret:1979], which itself is a note correcting an earlier data collection.]
33
33
34
34
35
35
### Model with Latent Discrete Parameter {-}
36
36
37
-
[@PyMC:2014 Section 3.1] provides a Poisson model of disaster
37
+
@PyMC:2014[, Section 3.1] provides a Poisson model of disaster
38
38
$D_t$ in year $t$ with two rate parameters, an early rate ($e$)
39
39
and late rate ($l$), that change at a given point in time $s$. The
40
40
full model expressed using a latent discrete parameter $s$ is
@@ -86,7 +86,7 @@ where the likelihood is defined by marginalizing $s$ as
86
86
p(D \mid e,l) &= \sum_{s=1}^T p(s, D \mid e,l) \\
87
87
&= \sum_{s=1}^T p(s) \, p(D \mid s,e,l) \\
88
88
&= \sum_{s=1}^T \textsf{uniform}(s \mid 1,T) \,
89
-
\prod_{t=1}^T \textsf{Poisson}(D_t \mid t < s \; ? \; e \: : \: l)
89
+
\prod_{t=1}^T \textsf{Poisson}(D_t \mid t < s \; ? \; e \: : \: l).
90
90
\end{align*}
91
91
92
92
Stan operates on the log scale and thus requires the log likelihood,
0 commit comments