Reputation: 143
I'm following the vignette for examining interactions using emmeans here https://cran.r-project.org/web/packages/emmeans/vignettes/interactions.html
But I'm using my own dataset (all.det) - which does have significant interactions. all.det contains 1621 observations of 12 variables, 3 of which are factors. I did try to create a re-producible example, but haven't figured out how to create one with all interactions significant. So I'm hoping this description will be enough for someone to point out where I am going wrong.
I am using
library(data.table)
library(car)
library(emmeans)
I run an anova using this code
DistanceKm is a numeric and Method, IDGroup and Sightability are factors.
model = lm(DistanceKm ~ Method * IDGroup * Sightability,
data=all.det[(IDGroup == "Whale" | IDGroup == "Dolphin")
& DistanceKm <=5])
Anova(model, type="II")
All the interactions are significant, so I follow this up with an interaction plot as advised in the vignette
emmip(model, Method ~ Sightability | IDGroup)
But I get these errors
Error in if (!all(chk == tbl)) stop("Data appear to be randomized -- ", :
missing value where TRUE/FALSE needed
Error in ref_grid(object, ...) :
Perhaps a 'data' or 'params' argument is needed
I did try to create a subset of my data
sub=all.det[(IDGroup == "Whale" | IDGroup == "Dolphin") & DistanceKm <=5]
And then re-ran the model, followed with an Anova
model=lm(DistanceKm ~ Method * IDGroup * Sightability, data=sub)
Anova(model, type="II")
I get the same Anova results (as expected), but now I'm also able to produce the interaction plot without errors.
emmip(model, Method ~ Sightability | IDGroup)
I just get a single warning instead about a missing value
Am I missing something when calling emmip?
Upvotes: 1
Views: 1816
Reputation: 53
I had a similar warning, then found I had mislabled one of my factors in the dataframe. Check your dataframe and make sure there aren't any NA values where there shouldn't be.
Upvotes: 2