Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed some typos #3

Merged
merged 1 commit into from
May 10, 2021
Merged

Fixed some typos #3

merged 1 commit into from
May 10, 2021

Conversation

behinger
Copy link
Contributor

Another thing I stumbled upon: you mention that broadcasting precludes doing predictive checks

But doing that does not allow us to do predictive checks (more on this below)

But you never explicitly mention the reason. My guess y .~ Categorical(p) doesnt work if y is missing?

Another thing I stumbled upon: you mention that broadcasting precludes doing predictive checks ("But doing that does not allow us to do predictive checks (more on this below"). But you never explicitly mention the reason. My guess `y .~ Categorical(p)` doesnt work if y is missing?
@storopoli
Copy link
Owner

storopoli commented May 10, 2021

Yes, that was exactly the case. David Widmann explained this in #turing slack channel.

Here's the explanation


Yes, you can't use your model with missing data. That's a known limitation of the syntax y .~ dist , and IIRC there is no simple solution to it. But since dist is fixed and not broadcasted over a range of parameters or so, you could equally well just write

dist = Categorical(p)
for i in eachindex(y)
    y[i] ~ dist
end

You could even add @threads or @inbounds to for loops (if they are threadsafe, of course) which you can't with the broadcasting expression. The main reason for why this works and broadcasting not is that Turing figures out that variables on the left hand side of ~ have to be sampled in the following order: 1) everything that is not an argument to the model has to be sampled, 2) everything that is declared to be not an observation in the model type (this is somewhat internal and not exposed to users yet), and 3) everything else where the left hand side evaluates to missing has to be sampled. In the broadcasting expression y is not missing (it is a vector of missing values) whereas in the for loop y[i] evaluates to missing and therefore is sampled (this also shows that you could also use partially missing data with the for loop whereas you can't do that with a broadcasting expression).


Thank you for the fixes!

@storopoli storopoli merged commit f2305a2 into storopoli:master May 10, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants