Closed awaldman123 closed 3 years ago
No. contrast requires an emmGrid object.
Thanks! I assume I can't use the original model object and ggeffects data frame to create an emmGrid object somehow?
No, it's not even possible, because essential info is not present, like the covariances between the EMMs.
Thanks! My apologies for the naive question but would it be viable to take the ggeffects output (ie predicted marginal means and confidence intervals) and perform pairwise contrasts outside of the emmeans package (ie within R or some other statistical software) using T-tests and a p-value adjustment of my choosing? I'm just curious as to whether that would mirror what the contrast function is doing and provide the same result as if the contrasts were performed within the emmeans package? Since I am using mixed models, I assume I would use paired T-tests for my pairwise comparisons?
I guess my answer is that these things can already be done inside of the emmeans package, which is my package, and if you want it done by some other package, I have no role nor interest in facilitating that - and you should ask that other package's developer instead. Plus I have already explained that you don't have all the needed info. What's wrong with using emmeans to begin with?
My apologies, I would like to be able to perform contrasts on estimated marginal means that take into account the zero inflation component of my glmmtmb models which I think only ggpredict does. Therefore, I wanted to garner a better understanding of what the contrast function does under the hood (R is a bit new to me) to know if I could get around the formatting issue you had described.
I'm closing this as I think I have answered the question as well as I can.
I have been calculating marginal means taking into account all sources of variation (fixed effects, zero-inflation, and random effects) using the ggpredict command (from the ggeffects package) and type="sim" argument.
However, I tried using the output of ggpredict as part of a call to the emmeans contrasts function and got the following error:
Error in UseMethod("contrast") : no applicable method for 'contrast' applied to an object of class "c('ggeffects', 'data.frame')"
Is there a way to coerce the data frame to be read by the contrasts function?
Thanks for your help!