R平方/相关性取决于预测变量的方差

作者: 拓端tecdat | 来源:发表于2020-04-13 22:11 被阅读0次

原文链接:http://tecdat.cn/?p=6289

在我今天参与的一个讨论中,提出了一个问题,即在具有单个连续预测器的线性回归模型中R平方如何/是否取决于预测变量的方差。这个问题的答案当然是肯定的。

可视化

我们还可以在R中轻松地可视化前面的概念。我们首先从具有非常大的样本大小的线性模型中模拟数据:

n < - 10000 x < - 100 * runif(n) y < - x + rnorm(n)

我们有:

need-to-insert-img

Y对X,对X没有限制

拟合相应的线性模型证实了这一点:

|t|) \n(Intercept) 0.0068489 0.0204500 0.335 0.738 \nx 0.9999752 0.0003534 2829.539 <2e-16 ***\n---\nSignif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1\n\nResidual standard error: 1.015 on 9998 degrees of freedom\nMultiple R-squared: 0.9988,\tAdjusted R-squared: 0.9988 \nF-statistic: 8.006e+06 on 1 and 9998 DF, p-value: < 2.2e-16\n"}"> summary(lm(y~x)) Call: lm(formula = y ~ x) Residuals: Min 1Q Median 3Q Max -4.1295 -0.6794 -0.0023 0.6879 3.5579 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 0.0068489 0.0204500 0.335 0.738 x 0.9999752 0.0003534 2829.539 <2e-16 *** --- Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 Residual standard error: 1.015 on 9998 degrees of freedom Multiple R-squared: 0.9988, Adjusted R-squared: 0.9988 F-statistic: 8.006e+06 on 1 and 9998 DF, p-value: < 2.2e-16

need-to-insert-img

给出R平方0.9988。

接下来,我们再次绘制数据,

need-to-insert-img

<1]~x[x<1]))\n\nCall:\nlm(formula = y[x < 1] ~ x[x < 1])\n\nResiduals:\n Min 1Q Median 3Q Max \n-2.93421 -0.73513 -0.09459 0.69282 2.59506 \n\nCoefficients:\n Estimate Std. Error t value Pr(>|t|) \n(Intercept) -0.0893 0.2432 -0.367 0.71459 \nx[x < 1] 1.3960 0.4386 3.183 0.00215 **\n---\nSignif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1\n\nResidual standard error: 1.121 on 72 degrees of freedom\nMultiple R-squared: 0.1233,\tAdjusted R-squared: 0.1112 \nF-statistic: 10.13 on 1 and 72 DF, p-value: 0.002155"}"> summary(lm(y[x<1]~x[x<1])) Call: lm(formula = y[x < 1] ~ x[x < 1]) Residuals: Min 1Q Median 3Q Max -2.93421 -0.73513 -0.09459 0.69282 2.59506 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) -0.0893 0.2432 -0.367 0.71459 x[x < 1] 1.3960 0.4386 3.183 0.00215 ** --- Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 Residual standard error: 1.121 on 72 degrees of freedom Multiple R-squared: 0.1233, Adjusted R-squared: 0.1112 F-statistic: 10.13 on 1 and 72 DF, p-value: 0.002155

need-to-insert-img

R平方值低得多,为0.1233。

相关文章

  • R平方/相关性取决于预测变量的方差

    原文链接:http://tecdat.cn/?p=6289 在我今天参与的一个讨论中,提出了一个问题,即在具有单个...

  • P36-P41方差

    方差 随机变量的数学期望,称为随机变量的离差 即离差平方的数学期望 方差计算公式 方差的性质 随机变量 相互独立 ...

  • 统计学(71)-相关性分析

    1、方差到协方差,再从协方差到线性相关系数 (1)已知变量x 和y, 现在想了解x和y的相关性(x和y均为连续变量...

  • 协方差矩阵

    协方差的定义 在统计学上,协方差用来刻画两个随机变量之间的相关性,反映的是变量之间的二阶统计特性,两个随机变量Xi...

  • 给女朋友写的生统资料_Part15

    相关性 当我们在衡量两个变量的相关关系的时候,我们可以用协方差来进行描述。协方差的公式为 协即协同的意思,X的方差...

  • 白化

    白化:相关性低,方差相同。 PCA:去均值,去相关性。 PCA白化:去均值,去相关性,方差相同为1。 ZCA白化:...

  • pandas笔记(Summarizing and Computi

    Correlation and Covariance(相关性和协方差) 一些总结性的统计信息,如相关性和协方差,是...

  • R语言实战__第9章 方差分析

    第9章 方差分析 名义型或有序因子也可作为预测变量进行建模。当包含的因子是解释变量时,关注的重点通常从预测转向组别...

  • 信用评分卡研究第4章 预测力指标

    第4章 预测力指标 这个部分主要是评判自变量与因变量之间,自变量之间的预测能力。这里明确相关性和关联性的一些细微区...

  • 广义R平方-原理

    1、自变量的个数对于R平方的影响 增加模型的自变量个数,R平方只会增加,不会减少,对于这一点我们可以考虑极端情况,...

网友评论

    本文标题:R平方/相关性取决于预测变量的方差

    本文链接:https://www.haomeiwen.com/subject/fkedmhtx.html