-
Notifications
You must be signed in to change notification settings - Fork 12
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
Fix loo/add pp_checks #19
Conversation
…t now it makes very strong assumptions about the data structure; this will likely be revisited later. The main changes are everything that has been added in R/predict.R, which implements both the predict and pp_check methods.
…t now it makes very strong assumptions about the data structure; this will likely be revisited later. The main changes are everything that has been added in R/predict.R, which implements both the predict and pp_check methods.
…Also added standard errors for both the looic and the ELPD of the model. The documentation has been updated and the print.baggr_cv function reurns more information. There is a testing script that runs the same model in brms and baggr for comparison purposes.
FYI, I've added a formal test for LOO, but it looks like the failing test is in the test_mutau section. |
Travis says that the check failed because you have a dependence on brms. Rather than fitting with a |
@@ -18,26 +11,26 @@ | |||
#' full model, prior values and _lpd_ of each model are also returned. | |||
#' These can be examined by using `attributes()` function. | |||
#' | |||
#' @references Gelman, Andrew, et al. Bayesian data analysis. Chapman and Hall/CRC, 2013. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe a reference like this is not the best, i.e. referencing a whole book
tests/testthat/test_loo.R
Outdated
fit <- brm(tau | se(se) ~ 1 + (1 | group), | ||
data = schools, | ||
control = list(adapt_delta = 0.95), | ||
prior = c(set_prior("normal(0,100)", class = "Intercept"), | ||
set_prior("uniform(0, 104.44)", class = "sd")), | ||
file = "misc/brms_kfold_test") | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See my comment elsewhere
If you could just make sure that
I will then review locally |
I'll make these changes and push them. Thanks for the comments. I'll keep the function in there but commented out in case we want to re-run later? I can just save the kfold output object, it should be pretty small. |
Yes, that's exactly what I had in mind. I think testthat has a lot of
functionality for testing against predefined objects, maybe you can quickly
check what is Hadley's recommendation? I never used it.
…On Fri, Oct 4, 2019 at 12:45 PM be-green ***@***.***> wrote:
I'll make these changes and push them. Thanks for the comments. I'll keep
the function in there but commented out in case we want to re-run later? I
can just save the kfold output object, it should be pretty small.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#19?email_source=notifications&email_token=AE5QPJSQWV7LQW7HW4B27W3QM4UHLA5CNFSM4IURGMIKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEALMQEI#issuecomment-538363921>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AE5QPJUZY2P34ZKOKOID423QM4UHLANCNFSM4IURGMIA>
.
|
PS: Same idea applies to 8 schools check of correctness. You did it
recently (and it worked OK) but it's just not included in this pull
request, right?
…On Fri, Oct 4, 2019 at 12:45 PM be-green ***@***.***> wrote:
I'll make these changes and push them. Thanks for the comments. I'll keep
the function in there but commented out in case we want to re-run later? I
can just save the kfold output object, it should be pretty small.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#19?email_source=notifications&email_token=AE5QPJSQWV7LQW7HW4B27W3QM4UHLA5CNFSM4IURGMIKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEALMQEI#issuecomment-538363921>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AE5QPJUZY2P34ZKOKOID423QM4UHLANCNFSM4IURGMIA>
.
|
Yes, I can add it in. I didn't use pre-specified values since I didn't have BDA3, I just used BRMS to fit the same model with the same priors and compared. I can also include that check. |
…t now it makes very strong assumptions about the data structure; this will likely be revisited later. The main changes are everything that has been added in R/predict.R, which implements both the predict and pp_check methods.
…t now it makes very strong assumptions about the data structure; this will likely be revisited later. The main changes are everything that has been added in R/predict.R, which implements both the predict and pp_check methods.
…Also added standard errors for both the looic and the ELPD of the model. The documentation has been updated and the print.baggr_cv function reurns more information. There is a testing script that runs the same model in brms and baggr for comparison purposes.
Alright, I've added everything in, made sure to rebase on your devel branch, and I'm going to push as soon as devtools::check passes locally. The error I'm running into is a compilation error, something about "did not create dll". @wwiecek have you ever seen that before? |
That usually means that you didn't unload the dynamic library. R is trying
to overwrite the dll file but is not allowed to do it. Make sure you don't
have multiple R sessions running, restart R or RStudio prior to running
checks.
…On Fri, 4 Oct 2019, 14:29 be-green, ***@***.***> wrote:
Alright, I've added everything in, made sure to rebase on your devel
branch, and I'm going to push as soon as devtools::check passes locally.
The error I'm running into is a compilation error, something about "did not
create dll". @wwiecek <https://github.com/wwiecek> have you ever seen
that before?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#19?email_source=notifications&email_token=AE5QPJXBUVNGKRFJM6Y6O6TQM5AKDA5CNFSM4IURGMIKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEALUQ6I#issuecomment-538396793>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AE5QPJUJ2M2AFB4WPVPEWMTQM5AKDANCNFSM4IURGMIA>
.
|
Try checking which test fails and met me know!
…On Fri, 4 Oct 2019, 13:14 be-green, ***@***.***> wrote:
It might just be my local machine, but I've removed the references to BRMS
and the tests seem to fail here:
[image: image]
<https://user-images.githubusercontent.com/23174585/66206729-901f2380-e676-11e9-8445-b70ef824b001.png>
rather than at the test_loo stage.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#19?email_source=notifications&email_token=AE5QPJXWREI24BOVNI3YNBTQM4XSXA5CNFSM4IURGMIKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEALOPDQ#issuecomment-538371982>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AE5QPJVUL7JB2UZQWFTSZQTQM4XSXANCNFSM4IURGMIA>
.
|
The first mu-tau test consistently crashes my RStudio for some reason. I think I may be having build issues that are as-of-yet diagnosed, so I'll let travis decide what's working. |
Travis failed again at
The first check that I see is |
Looks like all the errors are fixed in travis, still some warnings though. I'll check the devtools::load_all with the mutau model. Again, the package is still not building via cmd check on my machine (even running it via RScript and no open interactive sessions) so I think it must be an issue with my compiler or something. I had a similar issue with a different model at one point that no one else could replicate. |
Thanks, this looks OK! I flagged two check NOTEs/WARNINGs FYI, but no need to fix - I will edit myself. |
R/predict.R
Outdated
predict.baggr <- function(x, newdata = NULL, | ||
allow_new_levels = T, nsamples, ...) { | ||
allow_new_levels = T, nsamples = 100, ...) { | ||
switch(x$model, | ||
rubin = predict_rubin(x, newdata = newdata, | ||
allow_new_levels = allow_new_levels, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* checking S3 generic/method consistency ... WARNING
predict:
function(object, ...)
predict.baggr:
function(x, newdata, allow_new_levels, nsamples, ...)
See section ‘Generic functions and methods’ in the ‘Writing R
Extensions’ manual.
R/predict.R
Outdated
pp_check.baggr <- function(x, type = "dens_overlay", nsamples = 40) { | ||
pp_fun <- getFromNamespace(paste0("ppc_",type),ns = "bayesplot") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pp_check.baggr: no visible global function definition for
‘getFromNamespace’
Undefined global functions or variables:
getFromNamespace
Consider adding
importFrom("utils", "getFromNamespace")
I reviewed this -- I need to rethink the I also rebased your code & made various small fixes, I think now it will pass checks both locally & on Travis. |
@wwiecek when you have an idea of what you'd like to change/implement, let me know so I can help. Happy to write documentation or change the api. |
Fixes looic, adds standard errors to both ELPD and looic, and tests against the BRMS package's meta-analysis models. It also updates the documentation for the loocv() function.
Previous commits of mine add posterior_predictive checks and a predict function to the package (only implemented for the rubin model thus far).