I have generated a series of linear mixed models from my data and wanted to generate some estimated means using the emmeans package. My master dataset contains both night time and day time data to which I have successfully gotten the night time data to output what I want. I then used the same structure (modified slightly to account for different factor names etc.) to generate my linear mixed models for the day time data. However, when I try to generate estimated means using a single factor (in this case time which is a 3 level factor), I get estimated means for 1 of the 3 levels and nonEST for the other 2 and I have no idea why this is happening.
I am not sure how I can best provide information as the dataset used to generate the linear mixed model is a bit too large for dput(), but the basics of what I have done are below.
My model:
countsleepdataon25WAKEANGLMM2<-lmer(unlist(propnssANGon)~as.factor(intonidhrtime)+Daysincedisturb/Stressor+as.factor(intonidhrtime)*Daysincedisturb/Stressor+(1|Batch)+(1|Batch_Bird_ID)+(1|fdfsrtoff)+(1|fdfsrtoff_intonidhrtimertoff),data=countsleepdataon25WAKE)
My code:
emmeans(countsleepdataon25WAKEANGLMM2,specs='intonidhrtime')
The output:
> emmeans(countsleepdataon25WAKEANGLMM2,specs='intonidhrtime')
NOTE: A nesting structure was detected in the fitted model:
Stressor %in% Daysincedisturb
NOTE: Results may be misleading due to involvement in interactions
intonidhrtime emmean SE df lower.CL upper.CL
12-15.5 nonEst NA NA NA NA
15.5-19 nonEst NA NA NA NA
5-8.5 65.4 2.01 8.11 60.8 70
Results are averaged over the levels of: Stressor, Daysincedisturb
Degrees-of-freedom method: kenward-roger
Results are given on the unlist (not the response) scale.
Confidence level used: 0.95
For the sake of comparison, here is the output using the same model parameters/code but for the night time data set:
> emmeans(countsleepdataoff25WAKEANGLMM2,specs='intoffidhrtime')
NOTE: A nesting structure was detected in the fitted model:
Stressor %in% Daysincedisturb
NOTE: Results may be misleading due to involvement in interactions
intoffidhrtime emmean SE df lower.CL upper.CL
1-3 27.8 2.72 7.51 21.5 34.2
19-21 30.7 2.89 9.35 24.2 37.2
21-23 25.4 2.71 7.37 19.1 31.8
23-1 29.5 2.72 7.52 23.1 35.8
3-5 38.7 2.72 7.48 32.4 45.1
Results are averaged over the levels of: Stressor, Daysincedisturb
Degrees-of-freedom method: kenward-roger
Results are given on the unlist (not the response) scale.
Confidence level used: 0.95
I do not understand why there are no estimated means generated when the day time data has at least 50 values for each of the 3 time levels which I assume would be sufficient to generate some kind of value here.
The problem was an issue with the interaction between factor levels and time intervals. Effectively the 5-8.5 time interval estimated means were calculated using all 3 'Daysincedisturb' levels but because the 12-15.5 and 15.5-19 time intervals were missing 1/3 'Daysincedisturb' levels (based on the experimental design), it was not possible to generate estimated means for these 2 time intervals. Reducing 'Daysincedisturb' to a 2 level factor allowed for the generation of all necessary estimated means.