Skip to content

Commit c105a11

Browse files
committed
export predict
1 parent 686741f commit c105a11

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

docs/src/api.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,32 @@ Similarly, we can [`unfix`](@ref) variables, i.e. return them to their original
104104
unfix
105105
```
106106

107+
## Predicting
108+
109+
DynamicPPL provides functionality for generating samples from the posterior predictive distribution through the `predict` function. This allows you to use posterior parameter samples to generate predictions for unobserved data points.
110+
111+
```@docs
112+
predict
113+
```
114+
115+
The `predict` function has two main methods:
116+
117+
1. For `AbstractVector{<:AbstractVarInfo}` - useful when you have a collection of `VarInfo` objects representing posterior samples.
118+
2. For `MCMCChains.Chains` - useful when you have posterior samples in the form of a `Chains` object from MCMCChains.jl.
119+
120+
### Basic Usage
121+
122+
The typical workflow for posterior prediction involves:
123+
124+
1. Fitting a model to observed data to obtain posterior samples
125+
2. Creating a new model instance with some variables marked as missing (unobserved)
126+
3. Using `predict` to generate samples for these missing variables based on the posterior parameter samples
127+
128+
When using `predict` with `MCMCChains.Chains`, you can control which variables are included in the output with the `include_all` parameter:
129+
130+
- `include_all=false` (default): Include only newly predicted variables
131+
- `include_all=true`: Include both parameters from the original chain and predicted variables
132+
107133
## Models within models
108134

109135
One can include models and call another model inside the model function with `left ~ to_submodel(model)`.

src/DynamicPPL.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ export AbstractVarInfo,
121121
decondition,
122122
fix,
123123
unfix,
124+
predict,
124125
prefix,
125126
returned,
126127
to_submodel,

0 commit comments

Comments
 (0)