[英]Summary Extract Correlation Coefficient
我在R
的大數據集上使用lm()
。 使用summary()
可以獲得有關這兩個參數之間的線性回歸的許多詳細信息。
我很困惑的部分是,在“ Coefficients:
”摘要部分中,哪個參數是正確的,用作相關系數?
樣本數據
c1 <- c(1:10)
c2 <- c(10:19)
output <- summary(lm(c1 ~ c2))
摘要
Call:
lm(formula = c1 ~ c2)
Residuals:
Min 1Q Median 3Q Max
-2.280e-15 -8.925e-16 -2.144e-16 4.221e-16 4.051e-15
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) -9.000e+00 2.902e-15 -3.101e+15 <2e-16 ***
c2 1.000e+00 1.963e-16 5.093e+15 <2e-16 ***
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Residual standard error: 1.783e-15 on 8 degrees of freedom
Multiple R-squared: 1, Adjusted R-squared: 1
F-statistic: 2.594e+31 on 1 and 8 DF, p-value: < 2.2e-16
這是我應該使用的相關系數嗎?
output$coefficients[2,1]
1
請提出建議,謝謝。
系數估計的完整方差協方差矩陣為:
fm <- lm(c1 ~ c2)
vcov(fm)
特別是sqrt(diag(vcov(fm)))
等於coef(summary(fm))[, 2]
相應的相關矩陣為:
cov2cor(vcov(fm))
系數估計之間的相關性為:
cov2cor(vcov(fm))[1, 2]
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.