r - 比较 lme 中的 beta 系数
问题描述
我正在使用 nlme 包中的 lme 进行分析。我希望测试分析中的两个系数是否在统计上彼此不同。有谁知道这是怎么做到的吗?
解决方案
让我们假设以下模型
library(nlme)
my.model=lme(mpg~cyl+disp+hp,random=~1|am,data=mtcars)
summary(my.model)
Linear mixed-effects model fit by REML
Data: mtcars
AIC BIC logLik
181.5913 189.5845 -84.79563
Random effects:
Formula: ~1 | am
(Intercept) Residual
StdDev: 2.208646 2.830831
Fixed effects: mpg ~ cyl + disp + hp
Value Std.Error DF t-value p-value
(Intercept) 32.55270 2.9628523 27 10.986945 0.0000
cyl -0.90447 0.7538504 27 -1.199794 0.2406
disp -0.00972 0.0105324 27 -0.922877 0.3642
hp -0.02971 0.0152707 27 -1.945325 0.0622
Correlation:
(Intr) cyl disp
cyl -0.738
disp 0.327 -0.564
hp 0.250 -0.484 -0.321
Standardized Within-Group Residuals:
Min Q1 Med Q3 Max
-1.6025597 -0.7952622 -0.1413537 0.5074603 2.1800330
Number of Observations: 32
Number of Groups: 2
让我们比较一下 disp 和 hp 项。模型中有四个项,所以我们需要比较第三项和第四项(我们将使用对比矩阵)
cont=matrix(c(0,0,1,-1),ncol=4)
rownames(cont)="disp - hp"
library(multcomp)
summary(glht(my.model,linfct=cont))
Simultaneous Tests for General Linear Hypotheses
Fit: lme.formula(fixed = mpg ~ cyl + disp + hp, data = mtcars, random = ~1 |
am)
Linear Hypotheses:
Estimate Std. Error z value Pr(>|z|)
disp - hp == 0 0.01999 0.02115 0.945 0.345
(Adjusted p values reported -- single-step method)
推荐阅读
- c++ - 使用 MPI_Type_vector 发送偶数矩阵行
- java - 泛型 - 如何将地图转移到地图?扩展 x?
- amazon-web-services - AWS S3 存储桶中的对象更新问题
- odata - 刷新离线 OData:清理客户端上的不匹配实体?
- ios - 如何在 swift 4 中更新 UIBarButtonItem 徽章?
- arrays - SQL Server - 具有显式架构的 OPENJSON 输出
- r - 有什么方法可以将自定义 R 功能操作添加到 DT 中的按钮?
- plot - y轴中负值和正值的不同比例 - Gnuplot
- php - 邮件、openssl、证书的 PHP (7.1) 问题
- python - 无法使用 Flask 脚本让 Flask 应用程序和另一个函数一起运行