I have a mixed linear model, for example,
Model <- Values ~ A + B + C + (1 | id) + A:B + A:C + B:C
I wanted to do analysis with "emmeans" a.k.a estimated marginal means, so I used these packages in sequence
ref_grid(Model)
ref_grid(Model)@grid Model.pred1 <- matrix(predict(ref_grid(Model)), nrow = 12)
- the outcome of ref_grid(Model)@grid has 12 rows so I wrote 12 in "nrow"
Model.pred1
apply(Model.pred1, 1, mean)
apply(Model.pred1, 2, mean)
Then I did analysis with Model emmeans and pairs
But I wonder whether I did it just with emmeans and pairs without procedures which I used before the emmeans & pairs cuz I cannot understand why I should use the packages(ref_grid, pred. apply etc)...I just did this with Google cuz I don't have an experience with emmenas or Estimated marginal means
Question1. Can I use only emmeans and pairs packages whenever I want to do analysis with Estimated marginal means?
Question2. Could you please explain why one should do which I described above?
vignette("basics", "emmeans")
and read it. Take careful note that no convoluted steps are performed to replace object slots. $\endgroup$emmeans()
is used without doing those extra steps. $\endgroup$