【发布时间】:2016-02-03 22:43:54
【问题描述】:
假设我有一个类似的数据集
df <- data.frame(y=c(11:16), x1=c(23,NA,27,20,20,21), x2=c(NA,9,2,9,7,8))
df
y x1 x2
1 11 23 NA
2 12 NA 9
3 13 27 2
4 14 20 9
5 15 20 7
6 16 21 8
如果我执行多元线性回归,我会得到
m <- lm(y~x1+x2, data=df)
summary(m)
Call:
lm(formula = y ~ x1 + x2, data = df)
Residuals:
3 4 5 6
-1.744e-01 -1.047e+00 -4.233e-16 1.221e+00
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 19.72093 27.06244 0.729 0.599
x1 -0.24419 0.93927 -0.260 0.838
x2 0.02326 1.01703 0.023 0.985
Residual standard error: 1.617 on 1 degrees of freedom
(2 observations deleted due to missingness)
Multiple R-squared: 0.4767, Adjusted R-squared: -0.5698
F-statistic: 0.4556 on 2 and 1 DF, p-value: 0.7234
这里我们有 2 个观察值(1 和 2)由于缺失而被删除。
为了减少缺失数据的影响,计算 2 个不同的简单线性回归是否明智?
即
m1 <- lm(y~x1, data=df)
m2 <- lm(y~x2, data=df)
在这种情况下,对于每个模型,由于缺失,我们将仅删除 1 个观察值。
【问题讨论】:
标签: statistics linear-regression missing-data