-
-
Notifications
You must be signed in to change notification settings - Fork 191
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
Unnecessary variables required in newdata
for predictions in projpred
#1457
Comments
thank you for checking this out!
Frank Weber ***@***.***> schrieb am Di., 14. Feb. 2023, 13:29:
… When performing predictions with new data in projpred, brms reference
models require newdata to contain the response (and in fact *all*
variables from the original dataset), which is not necessary after
projecting onto a smaller model:
library(brms)
options(mc.cores = parallel::detectCores())ref_fit <- brm(
formula = rate ~ conc + state,
data = Puromycin,
backend = "cmdstanr",
seed = 2052109,
refresh = 0
)
library(projpred)soltrms <- "conc"prj <- project(ref_fit, solution_terms = soltrms, ndraws = 40)Puromycin_new <- as.data.frame(sapply(Puromycin[soltrms], quantile))prj_linpred <- proj_linpred(prj, newdata = Puromycin_new)
with the last line throwing
Error: Response variables must be specified in 'newdata'.
Missing variables: 'rate'
(Tested with projpred 2.4.0 and brms's GitHub version, commit b31fcee
<b31fcee>
.)
This also came up in The Stan Forums
<https://discourse.mc-stan.org/t/projpred-model-with-horseshoe-prior-does-not-converge/29935>
and seems to be a long-standing bug, probably related to the
extract_model_data() function defined in brms and passed to
projpred::init_refmodel() (the extract_model_data argument was introduced
in projpred 2.0.0, so quite some time ago). I will try to fix this and then
create a PR.
—
Reply to this email directly, view it on GitHub
<#1457>, or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ADCW2ADPQJ6BHI5UGYZTHPTWXN3BPANCNFSM6AAAAAAU3P5R7U>
.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***>
|
fweber144
added a commit
to fweber144/brms
that referenced
this issue
Feb 14, 2023
This is achieved by not ignoring `extract_y` anymore (ignoring this was already undesirable from a conceptual point of view) and by setting `check_response` and `req_vars` appropriately.
fweber144
added a commit
to fweber144/projpred
that referenced
this issue
Feb 16, 2023
…t.refmodel()` and all other `extract_model_data()` calls where appropriate. This will avoid an issue similar to paul-buerkner/brms#1457, but with respect to `predict.refmodel()`.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
When performing predictions with new data in projpred, brms reference models require
newdata
to contain the response (and in fact all variables from the original dataset), which is not necessary after projecting onto a smaller model:with the last line throwing
(Tested with projpred 2.4.0 and brms's GitHub version, commit b31fcee.)
This also came up in The Stan Forums and seems to be a long-standing bug, probably related to the
extract_model_data()
function defined in brms and passed toprojpred::init_refmodel()
(theextract_model_data
argument was introduced in projpred 2.0.0, so quite some time ago). I will try to fix this and then create a PR.The text was updated successfully, but these errors were encountered: