英文:
Why are there non-estimates in my emmeans output?
问题
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 non-estimated for the other 2, and I have no idea why this is happening.
我已经从我的数据中生成了一系列线性混合模型,并希望使用emmeans包生成一些估计均值。我的主数据集包含夜间和白天数据,我已成功使夜间数据输出我想要的内容。然后,我使用相同的结构(稍微修改以考虑不同的因子名称等)为白天数据生成了我的线性混合模型。但是,当我尝试使用单个因子(在这种情况下是时间,它是一个3级因子)生成估计均值时,我得到了3个级别中的1个级别的估计均值,其他2个级别的估计均值为非估计值,我不知道为什么会发生这种情况。
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.
我不确定如何最好地提供信息,因为用于生成线性混合模型的数据集对于dput()来说有点太大,但我所做的基本情况如下。
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)
我的代码:
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)
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
对于intonidhrtime,估计均值 emmean 为 nonEst,SE 为 NA,df 为 NA,lower.CL 为 NA,upper.CL 为 NA。对于5-8.5,估计均值为65.4,SE为2.01,df为8.11,lower.CL为60.8,upper.CL为70。
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
结果经过 Stressor 和 Daysincedisturb 的水平平均,Degrees-of-freedom 方法为 kenward-roger,结果以 unlist(而不是响应)的比例给出,置信水平为0.95。
英文:
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.
答案1
得分: 1
问题出在因子水平和时间间隔之间的交互作用上。有效地,5-8.5时间间隔的估计均值是使用了所有3个'Daysincedisturb'水平计算的,但由于12-15.5和15.5-19时间间隔缺少了1/3的'Daysincedisturb'水平(基于实验设计),因此无法生成这2个时间间隔的估计均值。将'Daysincedisturb'减少为2级因子允许生成所有必要的估计均值。
英文:
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.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论