@@ -15,7 +15,7 @@ are used --- if they do not, the behavior is undefined.
15
15
The basis of Stan's execution is the evaluation of a log probability
16
16
function (specifically, a log probability density function) for a given
17
17
set of (real-valued) parameters. Log probability functions can be
18
- constructed by using distribution statements and log probability increment
18
+ constructed by using distribution statements and log probability increment
19
19
statements. Statements may be grouped
20
20
into sequences and into for-each loops. In addition, Stan allows
21
21
local variables to be declared in blocks and also allows an empty
@@ -248,7 +248,8 @@ of the posterior up to an additive constant. Data and transformed
248
248
data are fixed before the log density is evaluated. The total log
249
249
probability is initialized to zero. Next, any log Jacobian
250
250
adjustments accrued by the variable constraints are added to the log
251
- density (the Jacobian adjustment may be skipped for optimization).
251
+ density (the Jacobian adjustment may be skipped for maximum likelihood estimation
252
+ via optimization).
252
253
Distribution statements and log probability increment statements may add to the log
253
254
density in the model block. A log probability increment statement
254
255
directly increments the log density with the value of an expression as
@@ -370,9 +371,9 @@ or in functions ending with `_jacobian` to mimic the log Jacobian
370
371
adjustments accrued by built-in variable transforms.
371
372
372
373
Similarly to those implemented for the built-in transforms, these Jacobian adjustment
373
- may be skipped for optimization.
374
+ may be skipped for maximum likelihood estimation via optimization.
374
375
375
- For example, here is a program which re-creates the existing
376
+ For example, here is a program which recreates the existing
376
377
[ ` <upper=x> ` transform] ( transforms.qmd#upper-bounded-scalar ) on real numbers:
377
378
378
379
``` stan
@@ -391,16 +392,21 @@ parameters {
391
392
transformed parameters {
392
393
real b = upper_bound_jacobian(b_raw, ub);
393
394
}
395
+ model {
396
+ // use b as if it was declared `real<upper=ub> b;` in parameters
397
+ // e.g.
398
+ // b ~ lognormal(0, 1);
399
+ }
394
400
```
395
401
396
402
### Accessing the log density {-}
397
403
398
- To access accumulated log density up to the current execution point,
404
+ To access the accumulated log density up to the current execution point,
399
405
the function ` target() ` may be used.
400
406
401
407
## Sampling statements {#sampling-statements.section}
402
408
403
- The term "sampling statement" has been replaced with
409
+ The term "sampling statement" has been replaced with
404
410
[ distribution statement] ( #distribution-statements.section ) .
405
411
406
412
## Distribution statements {#distribution-statements.section}
@@ -464,7 +470,7 @@ terms in the model block. Equivalently, each $\sim$ statement
464
470
corresponds to a multiplicative factor in the unnormalized posterior
465
471
density.
466
472
467
- Distribution statements (` ~ ` ) accept only built-in or user-defined
473
+ Distribution statements (` ~ ` ) accept only built-in or user-defined
468
474
distributions on the
469
475
right side. The left side of a distribution statement may be data,
470
476
parameter, or a complex expression, but the evaluated type needs to
@@ -484,8 +490,8 @@ target += normal_lpdf(sigma | 0, 1);
484
490
```
485
491
486
492
Stan models can mix distribution statements and log probability
487
- increment statements. Although statistical models
488
- are usually defined with distributions in the literature,
493
+ increment statements. Although statistical models
494
+ are usually defined with distributions in the literature,
489
495
there are several scenarios in which we may want to code the log
490
496
likelihood or parts of it directly, for example, due to computational
491
497
efficiency (e.g. censored data model) or coding language limitations
@@ -517,7 +523,7 @@ target += dist_lpmf(y | theta1, ..., thetaN);
517
523
518
524
This will be well formed if and only if `dist_lpdf(y | theta1,
519
525
..., thetaN)` or ` dist_lpmf(y | theta1, ..., thetaN)` is a
520
- well-formed expression of type ` real ` . User defined distributions
526
+ well-formed expression of type ` real ` . User defined distributions
521
527
can be defined in functions block by using function names ending with ` _lpdf ` .
522
528
523
529
@@ -913,7 +919,7 @@ The equivalent code for a vectorized truncation depends on which of the
913
919
variables are non-scalars (arrays, vectors, etc.):
914
920
915
921
1 . If the variate ` y ` is the only non-scalar, the result is the same as
916
- described in the above sections, but the ` lcdf ` /` lccdf ` calculation is
922
+ described in the above sections, but the ` lcdf ` /` lccdf ` calculation is
917
923
multiplied by ` size(y) ` .
918
924
919
925
2 . If the other arguments to the distribution are non-scalars, then the
0 commit comments