简体   繁体   English

摘要提取相关系数

[英]Summary Extract Correlation Coefficient

I am using lm() on a large data set in R . 我在R的大数据集上使用lm() Using summary() one can get lot of details about linear regression between these two parameters. 使用summary()可以获得有关这两个参数之间的线性回归的许多详细信息。

The part I am confused with is which one is the correct parameter in the Coefficients: section of summary, to use as correlation coefficient? 我很困惑的部分是,在“ Coefficients: ”摘要部分中,哪个参数是正确的,用作相关系数?

Sample Data 样本数据

c1 <- c(1:10)
c2 <- c(10:19)
output <- summary(lm(c1 ~ c2))

Summary 摘要

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

Is this the correlation coefficient I should use? 这是我应该使用的相关系数吗?

output$coefficients[2,1]
1

Please suggest, thanks. 请提出建议,谢谢。

The full variance covariance matrix of the coefficient estimates is: 系数估计的完整方差协方差矩阵为:

fm <- lm(c1 ~ c2)
vcov(fm)

and in particular sqrt(diag(vcov(fm))) equals coef(summary(fm))[, 2] 特别是sqrt(diag(vcov(fm)))等于coef(summary(fm))[, 2]

The corresponding correlation matrix is: 相应的相关矩阵为:

cov2cor(vcov(fm))

The correlation between the coefficient estimates is: 系数估计之间的相关性为:

cov2cor(vcov(fm))[1, 2]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM