I'm having trouble in R with my Linear Mixed-Effects Model. I'm working with yeast in nectar. This is a part of my data just so you can see what is going on:
For the condition sucrose, I have 4 different samples (you can only see data for sample 4 here). For each sample I did 2 replica's (so replica
is either 1 or 2). sp
tells you which species it is and condition
tells you whether the two yeast species were mixed together or just grew alone (single). I linked the two variables condition
and sp
together in treatment
. host
specifies the host plant of the species and cells1
is the number of yeast cells.
It is the number of cells (cells1
) that I want to compare for the different treatments. So I started off by making a mixed model with nested effects.
suc <- read.csv(file=file.choose(),header = TRUE,sep = ";")
attach(suc)
## load packages 'lme4', 'lsmeans', 'pbkrtest and 'Rcpp'
fit1 <- lmer(cells1~treatment+sp+treatment:sp+
(1|cont/replica)+(1|replica/Sample)+(1|Sample/host), suc)
Next, I wanted to do a post hoc test. TukeyHSD
wouldn't work. Error said something about not being able to use it with lmer
. So after doing some research, I used the function lsmeans
.
library("lsmeans")
lsmeans(fit1, pairwise~treatment, adjust="tukey")
When looking at the output, I get NA
as outcome everywhere and I have no clue what is wrong or how to resolve this.
Does anyone know how I can fix this?