-
-
Notifications
You must be signed in to change notification settings - Fork 189
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
Improve efficiency of the inv_link_<ordinal_family>()
functions
#1155
Conversation
…ctions: In `distributions.R`, use the more efficient implementation from the unit tests and in the unit tests, use the original implementation.
Very elegant implementations. Thank you! Will merge once the checks pass. |
When I change the number of categories in |
Yes, I'll take a look at it. Thanks for the hint. |
…maining apply() call in array(), even though it shouldn't be necessary (but better be explicit).
Should be fixed now. And I hope I have included all special cases in the unit tests now. Thanks again for pointing this out and sorry for not being aware of this. |
Thanks for fixing this! And no worries, 1/3 of all brms bugs are caused by R dropping dimensions somewhere in edge cases :-D |
Yeah, that dropping of margins is not really developer-friendly, especially when there's no way to turn it off, as for |
1/3 of all nightmares I have are caused by R dropping dimensions ;) |
And then filling up containers by repeating things is a real nightmare. |
You mean because I repeatedly added those |
that was no comment about your code I think but only about Rs way to
filling arrays with more numbers from the start if the sizes don't match.
although you are right, we could add a apply2 function as a wrapper around
apply.
Frank Weber ***@***.***> schrieb am Sa., 8. Mai 2021, 09:23:
… You mean because I repeatedly added those array(..., dim = c(dim_thres,
dim_noncat)) calls in commit 8b1704a
<8b1704a>?
That's true, that could perhaps have been solved more elegantly by adding a
custom wrapper around apply() which does not drop margins.
—
You are receiving this because you modified the open/close state.
Reply to this email directly, view it on GitHub
<#1155 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ADCW2AEAU6E4WPMDR2SJ6WDTMTRFVANCNFSM44G6RHYQ>
.
|
Ah I see :D Concerning the |
yeah no worries. I can just do that myself. the projpred things are much
more important anyway (and probably a lot of other things you have on your
table).
Frank Weber ***@***.***> schrieb am Sa., 8. Mai 2021, 17:54:
… Ah I see :D
Concerning the apply() wrapper: I'm currently lacking the time to
implement this, but I'll try to keep it in mind.
—
You are receiving this because you modified the open/close state.
Reply to this email directly, view it on GitHub
<#1155 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ADCW2AB4NPWJV76U6KTLOH3TMVNENANCNFSM44G6RHYQ>
.
|
As if the R Core Team had heard us: For R 4.1.0, the NEWS file says:
This new argument doesn't offer exactly what I would have desired, but it should be a good starting point for writing a custom |
thanks for looking into it. I don't want to strictly depend on R 4.1+ or
even R 4.0+ at the moment so I suggest we don't change it for now.
Frank Weber ***@***.***> schrieb am Do., 20. Mai 2021, 06:09:
… As if the R Core Team had heard us: For R 4.1.0, the NEWS file
<https://cran.r-project.org/doc/manuals/r-release/NEWS.html> says:
apply() gains a simplify argument to allow disabling of simplification of
results.
This new argument doesn't offer exactly what I would have desired, but it
should be a good starting point for writing a custom apply() wrapper.
@paul-buerkner <https://github.com/paul-buerkner>, do you want me to
write such a wrapper? But it would make brms depend on R >= 4.1.0.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#1155 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ADCW2AGHTDBOEFV53N4WYKTTOSDRLANCNFSM44G6RHYQ>
.
|
This PR is based on PR #1154, so it's better to merge #1154 first.
As suspected here (enumeration point 2), the current unit tests for the
inv_link_<ordinal_family>()
functions do indeed provide a more efficient implementation of theseinv_link_<ordinal_family>()
functions. Here is my requested speed comparison:Because of this speed improvement (which is sometimes smaller, sometimes larger, but always present), this PR swaps the two implementations of the
inv_link_<ordinal_family>()
functions (the original one and the one from the unit tests).Of course, one could go one step further and achieve another speed improvement by using arrays when calling
d<ordinal_family>()
inposterior_epred_ordinal()
, i.e. by not iterating over the observations, but instead including them as an additional array margin. But that probably requires larger changes.