Skip to content

Conversation

@devmotion
Copy link
Member

This PR implements some of the discussion in #44 and simplifies turing_model.

It also fixes a bug in the current implementation: Currently, turing_model(formula, data; model=M, ...) always returns a model with a Gaussian likelihood, regardless of M.

Comment on lines +169 to +176
predictors=size(X, 2),
idxs=idxs,
n_gr=n_gr,
intercept_ranef=intercept_ranef,
μ_X=μ_X,
σ_X=σ_X,
prior=prior,
residual=1 / std(y),
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some of these arguments depend on y and X dynamically whereas others are fixed - is this intended? I assume this will be problematic if you reinstantiate the model with new data since then some of the arguments are not synced anymore.

Why do you include all of these arguments in the first place? Do you ever plan to update y or X or change any of the keyword arguments?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a great point David. I didn't preview updates on the data. My main focus was to have the user API to be the simplest as possible. We can change it if necessary. My main idea was to mirror rstanarm/brms default priors.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My main focus was to have the user API to be the simplest as possible. We can change it if necessary. My main idea was to mirror rstanarm/brms default priors.

Isn't it simpler to just use model(y, X)? It's still not clear to me why/how these goals imply that you want to use keyword arguments here.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes you are right, we can probably move these keywords to the body of the function. We might just keep prior then.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We might just keep prior then.

Because users should be able to call the model with a different prior?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And standardize also, forgot that.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see.

Another observation: It seems mu_X and sigma_X are not used at all in the models, and there are issues with undefined variables due to the isempty(intercept_ranef) checks.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And standardize also, forgot that.

standardize is not part of the model keyword arguments. Maybe you are referring (also for the priors?) to turing_model? I focused only on the Turing model that this function creates, and the keyword arguments that are currently defined for it.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

standardize is not part of the model keyword arguments. Maybe you are referring (also for the priors?) to turing_model?

yes, you are correct. I've made a mess.

Copy link
Member

@storopoli storopoli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a great PR! Thanks!

One comment: Why not change all Gaussian to Normal?

EDIT: I think I got all Gaussians in the PR changes, but might be worth to have a double check.

@devmotion
Copy link
Member Author

devmotion commented Mar 1, 2022

One comment: Why not change all Gaussian to Normal?

Because I assumed you prefer the name Gaussian 😄 Both are equivalent since Distributions defines const Gaussian = Normal.

@storopoli
Copy link
Member

storopoli commented Mar 1, 2022

I prefer, but for our target user might be daunting. I think they would prefer Normal.

I only used Gaussian because the original API did not used Distributions.jl types. So I needed to circumvent that. And the second candidate BellDist was an awful name 😂

Co-authored-by: Jose Storopoli <[email protected]>
Copy link
Collaborator

@rikhuijzer rikhuijzer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome stuff, David 👍 👍

Copy link
Member

@storopoli storopoli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you want to merge, go ahead. We can address the isempty(intercept_ranef) checks in another PR.

@yebai
Copy link
Member

yebai commented Mar 1, 2022

Thanks for the nice improvements, @devmotion. It’ll be great if we can track performance regression for TuringGLM (e.g. using a notebook similar to tutorials), but that can be done in a separate PR.

@rikhuijzer
Copy link
Collaborator

It’ll be great if we can track performance regression for TuringGLM (e.g. using a notebook similar to tutorials), but that can be done in a separate PR.

You mean by reporting allocations like in something like fonsp/Pluto.jl#1959? Note that that PR is about compilation time, but runtime could be following a similar procedure. Reporting CPU time doesn't make sense because GitHub Runners run on different CPUs.

@storopoli
Copy link
Member

Also, we are not doing anything special on TuringGLM.jl we just call Turing.jl under the hood. The overhead might be negligible.

@devmotion
Copy link
Member Author

If you want to merge, go ahead. We can address the isempty(intercept_ranef) checks in another PR.

I have many more changes in a local branch but I guess it is cleaner to open a separate PR and do not modify the implementation of the Turing models in this PR.

@devmotion devmotion merged commit 5731396 into main Mar 1, 2022
@devmotion devmotion deleted the dw/distributions branch March 1, 2022 18:06
@yebai
Copy link
Member

yebai commented Mar 1, 2022

Also, we are not doing anything special on TuringGLM.jl. We just call Turing.jl under the hood. The overhead might be negligible.

That's right. However, the performance of TuringGLM probably depends on the actual turing_model implementation. When we change the turing_model function, it might incur performance changes. So it is good to have a way to track these performance variations. However, I'm not quite sure the best way of automating this.

Reporting CPU time doesn't make sense because GitHub Runners run on different CPUs.

That's correct - not quite sure how to automate performance tracking.

@storopoli
Copy link
Member

That's right. However, the performance of TuringGLM probably depends on the actual turing_model implementation. When we change the turing_model function, it might incur performance changes. So it is good to have a way to track these performance variations. However, I'm not quite sure the best way of automating this.

This makes total sense! Yes, now I get it.

I've asked @rikhuijzer to help us with this since he is pretty good on that.

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.

5 participants