-
Notifications
You must be signed in to change notification settings - Fork 53
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
Accept data.frame in predict() #48
Comments
But this aside, there are actually two things here: First,
works,
also throws an error. One can debate this implementation. It is less convenient, but it can also be argued to provide a certain 'safeguard' (one should only put moderators into The other thing is the class of what you put into As a general workflow that deals with these two issues automatically, you could do however:
That is also how you can deal with the fact that
(which gets really tedious when you have interactions, factors, and other 'derived' terms in your model), but one can also just do:
(the Note that for splines, you have to be careful. The knot positions that were used in the model should obviously be the same as those used in |
The way predict works for most R modeling functions is that it takes the data frame supplied and then evaluates the model formula or terms with that data frame as the environment. So, for example, I would absolutely expect to be able to provide a data frame with unused variables or a factor variable that is not already dummy coded, etc. |
Yeah, that's just not how things work in metafor. When I wrote |
Hey @wviechtb I've pulled together some functions to help construct a model matrix from a data frame in Now that the modeling objects return the data argument (bwiernik@1c57165), I could simplify these a bit, and they could work natively inside Related to this, it would be really helpful if the rma object could also store |
Hi @bwiernik. Thanks for those suggestions. Some thoughts:
|
Let me clarify a few things:
An even safer alternative might be to add a Besides those, what do you think of adding the |
|
Also 1. is done now. Will eventually tackle 3. |
Classification:
Enhancement Suggestion
Summary
I'm trying to fit an
rma.mv()
model with a fairly complex moderator structure (factor variable with several levels and splines for a continuous variable, interaction effects to model the different outcomes). Given this complexity, I'm having a really hard time trying to construct the model matrix fornewmods
by hand. It would be much easier and less error-prone ifpredict.rma()
accepted a data frame for thenewmods
argument the same way most R modeling functions do.Reproducible Example (if applicable)
cf.
predict.lm()
:The text was updated successfully, but these errors were encountered: