-
Notifications
You must be signed in to change notification settings - Fork 105
Open
Labels
quick-winpick these offpick these off
Description
Hi all,
Turing includes a useful function predict
for generating posterior predictive samples. Unfortunately, many users will not find this because it is not listed in the online documentation.
A secondary issue is plotting the posterior predictive distributions. Currently, predict
returns a chain, which is not conducive to certain plots (e.g. a scatter plot in the case of regression). Would it better to return an array of predictions, which could be converted to an MCMCChain
if needed? Here is an example based on the doc string:
using Turing; Turing.setprogress!(false);
@model function linear_reg(x, y, σ = 0.1)
β ~ Normal(0, 1)
for i ∈ eachindex(y)
y[i] ~ Normal(β * x[i], σ)
end
end;
σ = 0.1; f(x) = 2 * x + 0.1 * randn();
Δ = 0.1; xs = 0:Δ:10; ys = f.(xs);
model = linear_reg(xs, ys, σ);
chain_lin_reg = sample(model, NUTS(100, 0.65), 200);
m_pred = linear_reg(xs, Vector{Union{Missing, Float64}}(undef, length(ys)), σ);
predictions = predict(m_pred, chain_lin_reg)
Metadata
Metadata
Assignees
Labels
quick-winpick these offpick these off