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

predict() should not require response variable to be present in newdata #461

Closed
danielinteractive opened this issue Aug 17, 2024 · 2 comments · Fixed by #463
Closed

predict() should not require response variable to be present in newdata #461

danielinteractive opened this issue Aug 17, 2024 · 2 comments · Fixed by #463
Assignees
Labels
bug Something isn't working

Comments

@danielinteractive
Copy link
Collaborator

danielinteractive commented Aug 17, 2024

Reprex:

library("mmrm")

fit <- mmrm(
  formula = FEV1 ~ RACE + SEX + ARMCD * AVISIT + us(AVISIT | USUBJID),
  data = fev_data
)

predict(fit, subset(fev_data, select = - FEV1))

fails with:

Error in eval(predvars, data, env) : object 'FEV1' not found

because h_mmrm_tmb_data() is invoked and this uses the full_formula which includes the response variable from the fit.

Reported originally in vincentarelbundock/marginaleffects#1000 (comment)

@danielinteractive danielinteractive added the bug Something isn't working label Aug 17, 2024
@github-project-automation github-project-automation bot moved this to Issue To start in mmrm package board Aug 28, 2024
@clarkliming
Copy link
Collaborator

as by default we are conducting the "conditional prediction", not the "unconditional prediction", so the response is always required by default.

@danielinteractive
Copy link
Collaborator Author

Thanks @clarkliming , I still think that this is a bug to the user. It should in that case just default to "unconditional prediction"?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Development

Successfully merging a pull request may close this issue.

2 participants