线性混合模型置信区间问题

如何解决线性混合模型置信区间问题

希望你能消除我脑海中的一些困惑。

线性混合模型由lmerTest构建:

MODEL <- lmer(Ca content ~ SYSTEM +(1 | YEAR/replicate) + 
               (1 | YEAR:SYSTEM),data = IOSDV1)

当我试图获得主效应特定水平的置信区间时,乐趣开始出现。

命令 emmeanslsmeans 产生相同的间隔(示例;SYSTEM A3: 23.9-128.9,mean 76.4,SE:8.96)。

但是,命令 as.data.frame(effect("SYSTEM",MODEL)) 会产生不同的、更窄的置信区间(示例;SYSTEM A3: 58.0-94.9,SE:8.96)。

我遗漏了什么,我应该报告什么数字?

总而言之,对于 Ca 的含量,我每次处理有 6 次总测量值(每年 3 次,每次来自不同的重复)。我将使用我的语言在代码中保留名称,如使用。想法是测试某些生产实践是否会影响谷物中特定矿物质的含量。本例的模型中保留了无残差的随机效应。

Linear mixed model fit by REML. t-tests use Satterthwaite's method ['lmerModLmerTest']
Formula: CA ~ SISTEM + (1 | LETO/ponovitev) + (1 | LETO:SISTEM)
   Data: IOSDV1

REML criterion at convergence: 202.1

Scaled residuals: 
     Min       1Q   Median       3Q      Max 
-1.60767 -0.74339  0.04665  0.73152  1.50519 

Random effects:
 Groups         Name        Variance Std.Dev.
 LETO:SISTEM    (Intercept)   0.0     0.0    
 ponovitev:LETO (Intercept)   0.0     0.0    
 LETO           (Intercept) 120.9    11.0    
 Residual                   118.7    10.9    
Number of obs: 30,groups:  LETO:SISTEM,10; ponovitev:LETO,8; LETO,2

Fixed effects:
               Estimate Std. Error      df t value Pr(>|t|)  
(Intercept)      76.417      8.959   1.548   8.530   0.0276 *
SISTEM[T.C0]     -5.183      6.291  24.000  -0.824   0.4181  
SISTEM[T.C110]  -13.433      6.291  24.000  -2.135   0.0431 *
SISTEM[T.C165]   -7.617      6.291  24.000  -1.211   0.2378  
SISTEM[T.C55]   -10.883      6.291  24.000  -1.730   0.0965 .
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Correlation of Fixed Effects:
             (Intr) SISTEM[T.C0 SISTEM[T.C11 SISTEM[T.C16
SISTEM[T.C0  -0.351                                      
SISTEM[T.C11 -0.351  0.500                               
SISTEM[T.C16 -0.351  0.500       0.500                   
SISTEM[T.C5  -0.351  0.500       0.500        0.500      
optimizer (nloptwrap) convergence code: 0 (OK)
boundary (singular) fit: see ?isSingular

> ls_means(MODEL,ddf="Kenward-Roger")
Least Squares Means table:

           Estimate Std. Error  df t value    lower    upper Pr(>|t|)  
SISTEMA3    76.4167     8.9586 1.5  8.5299  23.9091 128.9243  0.02853 *
SISTEMC0    71.2333     8.9586 1.5  7.9514  18.7257 123.7409  0.03171 *
SISTEMC110  62.9833     8.9586 1.5  7.0305  10.4757 115.4909  0.03813 *
SISTEMC165  68.8000     8.9586 1.5  7.6797  16.2924 121.3076  0.03341 *
SISTEMC55   65.5333     8.9586 1.5  7.3151  13.0257 118.0409  0.03594 *
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

  Confidence level: 95%
  Degrees of freedom method: Kenward-Roger

> emmeans(MODEL,spec = c("SISTEM"))
 SISTEM emmean   SE   df lower.CL upper.CL
 A3       76.4 8.96 1.53     23.9      129
 C0       71.2 8.96 1.53     18.7      124
 C110     63.0 8.96 1.53     10.5      115
 C165     68.8 8.96 1.53     16.3      121
 C55      65.5 8.96 1.53     13.0      118

Degrees-of-freedom method: kenward-roger 
Confidence level used: 0.95

> as.data.frame(effect("SISTEM",MODEL))
  SISTEM      fit       se    lower    upper
1     A3 76.41667 8.958643 57.96600 94.86734
2     C0 71.23333 8.958643 52.78266 89.68400
3   C110 62.98333 8.958643 44.53266 81.43400
4   C165 68.80000 8.958643 50.34933 87.25067
5    C55 65.53333 8.958643 47.08266 83.98400

非常感谢。

解决方法

我很确定这与可怕的“分母自由度”问题有关,即正在使用哪种(如果有)有限样本校正。 tl;dr emmeans 正在使用 Kenward-Roger 校正,这或多或少是最准确的可用选项——使用 KR 的唯一原因是如果你有一个大数据集,它变得慢得难以忍受。

加载包,模拟数据,拟合模型

library(lmerTest)
library(emmeans)
library(effects)
dd <- expand.grid(f=factor(letters[1:3]),g=factor(1:20),rep=1:10)
set.seed(101)
dd$y <- simulate(~f+(1|g),newdata=dd,newparams=list(beta=rep(1,3),theta=1,sigma=1))[[1]]
m <- lmer(y~f+(1|g),data=dd)

比较默认的emmeans和效果

emmeans(m,~f)
##  f emmean    SE   df lower.CL upper.CL
##  a  0.848 0.212 21.9    0.409     1.29
##  b  1.853 0.212 21.9    1.414     2.29
##  c  1.863 0.212 21.9    1.424     2.30

## Degrees-of-freedom method: kenward-roger 
## Confidence level used: 0.95 

as.data.frame(effect("f",m))
##   f       fit        se     lower    upper
## 1 a 0.8480161 0.2117093 0.4322306 1.263802
## 2 b 1.8531805 0.2117093 1.4373950 2.268966
## 3 c 1.8632228 0.2117093 1.4474373 2.279008

effects 没有明确告诉我们什么/是否使用有限样本校正:我们可以在文档或代码中挖掘以试图找出答案。或者,我们可以告诉emmeans 不要使用有限样本校正:

emmeans(m,~f,lmer.df="asymptotic")
##  f emmean    SE  df asymp.LCL asymp.UCL
##  a  0.848 0.212 Inf     0.433      1.26
##  b  1.853 0.212 Inf     1.438      2.27
##  c  1.863 0.212 Inf     1.448      2.28

## Degrees-of-freedom method: asymptotic 
## Confidence level used: 0.95 

测试表明,这些大约相当于 0.001 的容差(可能足够接近)。 原则上我们应该能够指定 KR=TRUE 来让 effects 使用 Kenward-Roger 校正,但我还没有能够让它工作。 >

但是,我还要说您的示例有点奇怪。如果我们以标准误差为单位计算均值和下 CI 之间的距离,对于 emmeans,我们得到 (76.4-23.9)/8.96 = 5.86,这意味着 非常 效应自由度(例如约 1.55)。这对我来说似乎有问题,除非您的数据集非常小......


从您更新的帖子来看,Kenward-Roger 似乎确实只估计了 1.5 分母 df。

一般来说,在分组变量具有少量级别的情况下尝试拟合随机效应是冒险的/不推荐的(尽管请参阅 here 以获得反驳)。我会尝试将 LETO(只有两个级别)视为固定效果,即

CA ~ SISTEM + LETO + (1 | LETO:ponovitev) + (1 | LETO:SISTEM)

看看是否有帮助。 (我预计你会得到 7 df 的数量级,这将使你的 CI ± 2.4 SE 而不是 ± 6 SE ...)

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐


依赖报错 idea导入项目后依赖报错,解决方案:https://blog.csdn.net/weixin_42420249/article/details/81191861 依赖版本报错:更换其他版本 无法下载依赖可参考:https://blog.csdn.net/weixin_42628809/a
错误1:代码生成器依赖和mybatis依赖冲突 启动项目时报错如下 2021-12-03 13:33:33.927 ERROR 7228 [ main] o.s.b.d.LoggingFailureAnalysisReporter : *************************** APPL
错误1:gradle项目控制台输出为乱码 # 解决方案:https://blog.csdn.net/weixin_43501566/article/details/112482302 # 在gradle-wrapper.properties 添加以下内容 org.gradle.jvmargs=-Df
错误还原:在查询的过程中,传入的workType为0时,该条件不起作用 &lt;select id=&quot;xxx&quot;&gt; SELECT di.id, di.name, di.work_type, di.updated... &lt;where&gt; &lt;if test=&qu
报错如下,gcc版本太低 ^ server.c:5346:31: 错误:‘struct redisServer’没有名为‘server_cpulist’的成员 redisSetCpuAffinity(server.server_cpulist); ^ server.c: 在函数‘hasActiveC
解决方案1 1、改项目中.idea/workspace.xml配置文件,增加dynamic.classpath参数 2、搜索PropertiesComponent,添加如下 &lt;property name=&quot;dynamic.classpath&quot; value=&quot;tru
删除根组件app.vue中的默认代码后报错:Module Error (from ./node_modules/eslint-loader/index.js): 解决方案:关闭ESlint代码检测,在项目根目录创建vue.config.js,在文件中添加 module.exports = { lin
查看spark默认的python版本 [root@master day27]# pyspark /home/software/spark-2.3.4-bin-hadoop2.7/conf/spark-env.sh: line 2: /usr/local/hadoop/bin/hadoop: No s
使用本地python环境可以成功执行 import pandas as pd import matplotlib.pyplot as plt # 设置字体 plt.rcParams[&#39;font.sans-serif&#39;] = [&#39;SimHei&#39;] # 能正确显示负号 p
错误1:Request method ‘DELETE‘ not supported 错误还原:controller层有一个接口,访问该接口时报错:Request method ‘DELETE‘ not supported 错误原因:没有接收到前端传入的参数,修改为如下 参考 错误2:cannot r
错误1:启动docker镜像时报错:Error response from daemon: driver failed programming external connectivity on endpoint quirky_allen 解决方法:重启docker -&gt; systemctl r
错误1:private field ‘xxx‘ is never assigned 按Altʾnter快捷键,选择第2项 参考:https://blog.csdn.net/shi_hong_fei_hei/article/details/88814070 错误2:启动时报错,不能找到主启动类 #
报错如下,通过源不能下载,最后警告pip需升级版本 Requirement already satisfied: pip in c:\users\ychen\appdata\local\programs\python\python310\lib\site-packages (22.0.4) Coll
错误1:maven打包报错 错误还原:使用maven打包项目时报错如下 [ERROR] Failed to execute goal org.apache.maven.plugins:maven-resources-plugin:3.2.0:resources (default-resources)
错误1:服务调用时报错 服务消费者模块assess通过openFeign调用服务提供者模块hires 如下为服务提供者模块hires的控制层接口 @RestController @RequestMapping(&quot;/hires&quot;) public class FeignControl
错误1:运行项目后报如下错误 解决方案 报错2:Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project sb 解决方案:在pom.
参考 错误原因 过滤器或拦截器在生效时,redisTemplate还没有注入 解决方案:在注入容器时就生效 @Component //项目运行时就注入Spring容器 public class RedisBean { @Resource private RedisTemplate&lt;String
使用vite构建项目报错 C:\Users\ychen\work&gt;npm init @vitejs/app @vitejs/create-app is deprecated, use npm init vite instead C:\Users\ychen\AppData\Local\npm-