0

I would like to test the main effect of a categorical variable using a permutation test on a likelihood ratio test. I have a continuous outcome and a dichotomous grouping predictor and a categorical time predictor (Day, 5 levels).

Data is temporarily available in rda format via this Drive link.

library(lme4)
lmer1 <- lmer(outcome ~ Group*Day + (1 | ID), data = data, REML = F, na.action=na.exclude)
lmer2 <- lmer(outcome ~ Group + (1 | ID), data = data, REML = F, na.action=na.exclude)

library(predictmeans)
permlmer(lmer2,lmer1)

However, this code gives me the following error:

Error in density.default(c(lrtest1, lrtest), kernel = "epanechnikov") : need at least 2 points to select a bandwidth automatically

The following code does work, but does not exactly give me the outcome of a permutated LR-test I believe:

library(nlme)
lme1 <- lme(outcome ~ Genotype*Day,
                  random = ~1 | ID,
                  data = data,
                  na.action = na.exclude)

library(pgirmess)
PermTest(lme1)

Can anyone point out why I get the "epanechnikov" error when using the permlmer function?

Thank you!

RmyjuloR
  • 369
  • 1
  • 4
  • 13
  • It's easier to help you if you include a simple [reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) with sample input and desired output that can be used to test and verify possible solutions. Sounds like you don't have enough data to do the test. – MrFlick Nov 15 '19 at 15:40
  • @MrFlick I've added the data. – RmyjuloR Nov 15 '19 at 15:56
  • 1
    The only thing in that data.rda file is a length-1 vector containing the word "data". So I think the error may be a bit misleading but it is informative in the sense that it's telling you you don't really have any _data_. Voting to close as essentially a "typo". – IRTFM Nov 15 '19 at 16:07
  • @42 That is probably just an issue with the link. I'm pretty sure I have data and the file that is linked is the correct file... I think I would be able to diagnose a data.frame is non existent when running a code like above :) – RmyjuloR Nov 15 '19 at 16:26
  • Did you try downloading the file and then using `load` in an R session? – IRTFM Nov 15 '19 at 16:51
  • @42 Yes, I did exactly that. – RmyjuloR Nov 15 '19 at 18:08

1 Answers1

1

The issue is with NANs, remove all nans from your dataset and rerun the models. I had the same problem and that solved it.