Closed YyLu5 closed 1 month ago
The main functions are:
ggpredict()
(calls predict()
)ggeffect()
(calls effects::Effect()
)ggemmeans()
(calls emmeans::emmeans()
)ggaverage()
(calls marginaleffects::avg_predictions()`)For all functions, predictions are made for a reference or data grid, which is provided via the terms
argument.
Thus, the above functions all return more or less similar results. Their main difference is how non-focal terms (those model predictors that are not specified in the terms
argument) are handled. ggeffect()
and ggemmeans()
have similar approaches and usually return the same predictions. Therefore, predict_response()
is a wrapper around the four above-mentioned functions, and the margin
argument is responsible for which underlying function is called (see description for instance here: https://strengejacke.github.io/ggeffects/articles/ggeffects.html). Indeed, no margin
option calls ggeffect()
(so this function is excluded from the predict_response()
-wrapper), because results are usually the same as for ggemmeans()
(which is predict_response(margin = "marginalmeans")
).
That is the summary of predict_response()
as wrapper and the single functions. As you can see here: https://strengejacke.github.io/ggeffects/reference/ggpredict.html, ggeffect()
has no vcov_*
argument. This is only supported by ggpredict()
or ggaverage()
(or: predict_response()
and predict_response(margin = "empirical")
). ggeffect()
ignores the vcov_fun
argument and therefore throws no error.
Coming to your example that fails: The "CR3"
option requires the cluster
argument to be specified, then it works. See examples here: https://strengejacke.github.io/ggeffects/articles/practical_robustestimation.html
Hope that helps?
In a recent commit, I added warnings when non-supported arguments are used in function calls.
sounds great, this is very helpful, thank you!
I'm confused by the difference between these two functions. I've read that the predict_response is a "wrapper" function for ggeffect(). I used both the ggeffect(model, term) and predict_response (model, term) to compare, the results are different, they differ by small values and the SE is slightly larger in the ggeffect() function. Later when my model contains a random effect, I'm able to use ggeffect(model,term,vcov_fun="CR3"), while use predict_response(model,term,vcov_fun="CR3") caused an error "Error in vcovCR.default(obj = list(obj = list(par = c(beta = 5.34256429246318, : argument "cluster" is missing, with no default"
So I'm not sure which one is correct to use. Thank you!