Using this dummy dataset:
dummy.data <- data.frame(vaccinated = factor(rep(c("yes", "no"), each = 64)),
infected = factor(rep(c("yes", "no"), each = 32)),
animal = factor(rep(1:16, each = 8)),
tissue = factor(c("blood", "liver", "kidney", "brain")),
value = runif(128)
)
This works:
library("nlme")
nlme.model <- as.formula(value ~ vaccinated * infected * tissue)
nlme.fit <- lme(fixed = nlme.model, random = ~1|animal, data = dummy.data)
library("phia")
int.nlme <- interactionMeans(nlme.fit)
plot(int.nlme)
But this doesn't:
library("lme4")
lmer.model <- as.formula(value ~ vaccinated * infected * tissue + (1 | animal))
lmer.fit <- lmer(formula = lmer.model, data = dummy.data)
library("phia")
int.lmer <- interactionMeans(lmer.fit)
plot(int.lmer)
With the latter, I only get
Error in t.default(M) : argument is not a matrix
from the plot command.
When I look at int.nlme and int.lmer with str, they do look different, but I can't figure out what the problem is. Any input is much appreciated.
The error appears to be generated from
phia:::poolseand can be replicated thus:Still digging...
And I conclude its a bug in the
phiapackage, which has neglected this:When writing an R package that uses the Matrix package, why do I have to specify Matrix::t() instead of just t()?
as a workaround, and to increase the awesomeness, turn the "covmat" attribute of
int.lmerfromMatrixclasses to standard Rmatrixclasses:The plot then works.