之后
在听说您有线性混合效应模型后,我想补充一件事:和仍可用于比较模型。例如,请参阅本文。从网站上的其他类似问题来看,这篇论文似乎至关重要。AIC,AICcBIC
原始答案
您基本上想要的是比较两个非嵌套模型。Burnham 和 Anderson模型选择和多模型推理对此进行了讨论,并推荐使用、或等,因为传统的似然比检验仅适用于嵌套模型。他们明确指出,等信息论标准不是测试,在报告结果时应避免使用“显着”一词。AICAICcBICAIC,AICc,BIC
基于这个和这个答案,我推荐这些方法:
- 制作数据集的散点图矩阵 (SPLOM),包括平滑器:
pairs(Y~X1+X2, panel = panel.smooth, lwd = 2, cex = 1.5, col = "steelblue", pch=16)
. 检查线条(平滑器)是否与线性关系兼容。必要时优化模型。
- 计算模型
m1
和m2
。做一些模型检查(残差等):plot(m1)
和plot(m2)
.
- 计算两个模型的()并计算两个之间的绝对差。该软件包为此提供了功能:. 如果这个绝对差值小于 2,则两种模型基本无法区分。否则更喜欢较低的模型。AICcAICAICc
R
pscl
AICc
abs(AICc(m1)-AICc(m2))
AICc
- 计算非嵌套模型的似然比检验。该
R
软件包lmtest
具有coxtest
(Cox 测试)、jtest
(Davidson-MacKinnon J 测试)和encomptest
(包含 Davidson & MacKinnon 测试)的功能。
一些想法:如果两个香蕉测量真的是测量同一件事,它们可能都同样适合预测,并且可能没有“最佳”模型。
这篇论文也可能会有所帮助。
这是一个例子R
:
#==============================================================================
# Generate correlated variables
#==============================================================================
set.seed(123)
R <- matrix(cbind(
1 , 0.8 , 0.2,
0.8 , 1 , 0.4,
0.2 , 0.4 , 1),nrow=3) # correlation matrix
U <- t(chol(R))
nvars <- dim(U)[1]
numobs <- 500
set.seed(1)
random.normal <- matrix(rnorm(nvars*numobs,0,1), nrow=nvars, ncol=numobs);
X <- U %*% random.normal
newX <- t(X)
raw <- as.data.frame(newX)
names(raw) <- c("response","predictor1","predictor2")
#==============================================================================
# Check the graphic
#==============================================================================
par(bg="white", cex=1.2)
pairs(response~predictor1+predictor2, data=raw, panel = panel.smooth,
lwd = 2, cex = 1.5, col = "steelblue", pch=16, las=1)

平滑器确认线性关系。这当然是有意的。
#==============================================================================
# Calculate the regression models and AICcs
#==============================================================================
library(pscl)
m1 <- lm(response~predictor1, data=raw)
m2 <- lm(response~predictor2, data=raw)
summary(m1)
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) -0.004332 0.027292 -0.159 0.874
predictor1 0.820150 0.026677 30.743 <2e-16 ***
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Residual standard error: 0.6102 on 498 degrees of freedom
Multiple R-squared: 0.6549, Adjusted R-squared: 0.6542
F-statistic: 945.2 on 1 and 498 DF, p-value: < 2.2e-16
summary(m2)
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) -0.01650 0.04567 -0.361 0.718
predictor2 0.18282 0.04406 4.150 3.91e-05 ***
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Residual standard error: 1.021 on 498 degrees of freedom
Multiple R-squared: 0.03342, Adjusted R-squared: 0.03148
F-statistic: 17.22 on 1 and 498 DF, p-value: 3.913e-05
AICc(m1)
[1] 928.9961
AICc(m2)
[1] 1443.994
abs(AICc(m1)-AICc(m2))
[1] 514.9977
#==============================================================================
# Calculate the Cox test and Davidson-MacKinnon J test
#==============================================================================
library(lmtest)
coxtest(m1, m2)
Cox test
Model 1: response ~ predictor1
Model 2: response ~ predictor2
Estimate Std. Error z value Pr(>|z|)
fitted(M1) ~ M2 17.102 4.1890 4.0826 4.454e-05 ***
fitted(M2) ~ M1 -264.753 1.4368 -184.2652 < 2.2e-16 ***
jtest(m1, m2)
J test
Model 1: response ~ predictor1
Model 2: response ~ predictor2
Estimate Std. Error t value Pr(>|t|)
M1 + fitted(M2) -0.8298 0.151702 -5.470 7.143e-08 ***
M2 + fitted(M1) 1.0723 0.034271 31.288 < 2.2e-16 ***
第一个模型的明显较低,而要高得多。AICcm1
R2
重要提示:在具有相同复杂度和高斯误差分布的线性模型中和应该给出相同的答案(参见这篇文章)。在非线性模型中,应避免用于模型性能(拟合优度)和模型选择:例如,参见这篇文章和这篇论文。R2,AICBICR2