197 |
195 |
|
if group_data isa Union{AbstractVector{String},NTuple{N,String} where {N}} |
198 |
196 |
|
group_data = popsubdict!(post_dict, group_data) |
199 |
197 |
|
end |
200 |
|
- |
group_dataset = convert_to_dataset(group_data; library = library, kwargs...) |
|
198 |
+ |
group_dataset = convert_to_dataset(group_data; library=library, kwargs...) |
201 |
199 |
|
setattribute!(group_dataset, "inference_library", library) |
202 |
200 |
|
concat!(all_idata, InferenceData(; group => group_dataset)) |
203 |
201 |
|
end |
204 |
202 |
|
|
205 |
203 |
|
attrs = attributes_dict(posterior) |
206 |
204 |
|
attrs = merge(attrs, Dict("inference_library" => library)) |
207 |
|
- |
kwargs = convert(Dict, merge((; attrs = attrs, dims = nothing), kwargs)) |
208 |
|
- |
post_idata = _from_dict(post_dict; sample_stats = stats_dict, kwargs...) |
|
205 |
+ |
kwargs = convert(Dict, merge((; attrs=attrs, dims=nothing), kwargs)) |
|
206 |
+ |
post_idata = _from_dict(post_dict; sample_stats=stats_dict, kwargs...) |
209 |
207 |
|
concat!(all_idata, post_idata) |
210 |
208 |
|
return all_idata |
211 |
209 |
|
end |
212 |
210 |
|
function from_mcmcchains( |
213 |
|
- |
posterior = nothing; |
214 |
|
- |
posterior_predictive = nothing, |
215 |
|
- |
predictions = nothing, |
216 |
|
- |
prior = nothing, |
217 |
|
- |
prior_predictive = nothing, |
218 |
|
- |
observed_data = nothing, |
219 |
|
- |
constant_data = nothing, |
220 |
|
- |
predictions_constant_data = nothing, |
221 |
|
- |
log_likelihood = nothing, |
222 |
|
- |
library = MCMCChains, |
|
211 |
+ |
posterior=nothing; |
|
212 |
+ |
posterior_predictive=nothing, |
|
213 |
+ |
predictions=nothing, |
|
214 |
+ |
prior=nothing, |
|
215 |
+ |
prior_predictive=nothing, |
|
216 |
+ |
observed_data=nothing, |
|
217 |
+ |
constant_data=nothing, |
|
218 |
+ |
predictions_constant_data=nothing, |
|
219 |
+ |
log_likelihood=nothing, |
|
220 |
+ |
library=MCMCChains, |
223 |
221 |
|
kwargs..., |
224 |
222 |
|
) |
225 |
|
- |
kwargs = convert(Dict, merge((; dims = nothing, coords = nothing), kwargs)) |
|
223 |
+ |
kwargs = convert(Dict, merge((; dims=nothing, coords=nothing), kwargs)) |
226 |
224 |
|
|
227 |
225 |
|
all_idata = from_mcmcchains( |
228 |
226 |
|
posterior, |
229 |
227 |
|
posterior_predictive, |
230 |
228 |
|
predictions, |
231 |
229 |
|
log_likelihood; |
232 |
|
- |
library = library, |
|
230 |
+ |
library=library, |
233 |
231 |
|
kwargs..., |
234 |
232 |
|
) |
235 |
233 |
|
|
236 |
234 |
|
if prior !== nothing |
237 |
235 |
|
pre_prior_idata = convert_to_inference_data( |
238 |
|
- |
prior; |
239 |
|
- |
posterior_predictive = prior_predictive, |
240 |
|
- |
library = library, |
241 |
|
- |
kwargs..., |
|
236 |
+ |
prior; posterior_predictive=prior_predictive, library=library, kwargs... |
242 |
237 |
|
) |
243 |
238 |
|
prior_idata = rekey( |
244 |
239 |
|
pre_prior_idata, |