Skip to content

Commit 4760764

Browse files
authored
Merge pull request #130 from stan-dev/bugfix/empty-model-block
The model block is not mandatory, can be omitted if empty
2 parents f5c5f96 + a236cf2 commit 4760764

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

src/reference-manual/mcmc.Rmd

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -531,8 +531,10 @@ large as necessary.
531531
In some situations, such as pure forward data simulation in a directed
532532
graphical model (e.g., where you can work down generatively from known
533533
hyperpriors to simulate parameters and data), there is no need to
534-
declare any parameters in Stan, the model block will be empty, and all
535-
output quantities will be produced in the generated quantities block.
534+
declare any parameters in Stan, the model block will be empty (and thus
535+
can be omitted), and all output quantities will be produced in the
536+
generated quantities block.
537+
536538
For example, to generate a sequence of $N$ draws from a binomial with
537539
trials $K$ and chance of success $\theta$, the following program suffices.
538540

@@ -542,20 +544,16 @@ data {
542544
int<lower=0> K;
543545
int<lower=0> N;
544546
}
545-
model {
546-
}
547547
generated quantities {
548548
int<lower=0,upper=K> y[N];
549549
for (n in 1:N)
550550
y[n] = binomial_rng(K, theta);
551551
}
552552
```
553553

554-
This program includes an empty model block because every Stan program
555-
must have a model block, even if it's empty. For this model, the
556-
sampler must be configured to use the fixed-parameters setting because
557-
there are no parameters. Without parameter sampling there is no need
558-
for adaptation and the number of warmup iterations should be set to
554+
For this model, the sampler must be configured to use the fixed-parameters
555+
setting because there are no parameters. Without parameter sampling there
556+
is no need for adaptation and the number of warmup iterations should be set to
559557
zero.
560558

561559
Most models that are written to be sampled without parameters will not

0 commit comments

Comments
 (0)