皮尔逊功能

它测量了由随机人群连续数据定义的两个变量之间的相关性。

皮尔逊功能是用于计算的统计函数皮尔逊相关系数由r代表。它测量了由随机人群连续数据定义的两个变量之间的相关性。

相关系数源自皮尔森相关测试,该测试确定变量的方向和强度,使输出在-1至1的范围内表示相关强度。

What is the Pearson correlation test?

它决定了两个变量的方向和强度,并将输出作为皮尔逊相关系数。如果r的值为-1,则代表完美的负相关,而+1的值表示完美的正相关。

如果该值为零,则两个变量之间没有关联。

实际上,看到完美的相关性并不容易,即将R值作为-1或+1。

当您计算值时,结果大部分时间将是系数的上限和下限之间的小数值(即,它始终范围从-1到1)。

为了更好地理解它,让我们看一个相关测试的示例。假设来自随机人群的四个人具有两个不同的变量,年龄(x)和收入(y)。桌子看起来如下:

示例01
Name 年龄(x) Income(y)
杰米 26 2800
乔纳森 44 3400
雅各布 32 3000
内森 28 3000

通过代表他们在X轴上的年龄和Y轴收入的年龄,我们的散点图将如下:

图形

如您所见,我们的散点图几乎是线性的(线性意味着可以通过它绘制直线)。因此,如果我们通过数据划出一条直线,数据之间的线性关系将看起来像:

图形2

这种线性关系称为变量之间的相关性。

Excel Modeling Course

您需要掌握Excel建模所需的一切

To Help You Thrive in the Most Prestigious Jobs on Wall Street.

2ManBetX登陆

皮尔逊相关系数(R)

One of the outputs returned by performing the correlation test is the correlation coefficient (r)。的价值r表示相关性的两个基本特征:

  • The direction of the correlation
  • 相关的强度

对于我们从年龄(x)和收入(y)的四个人群中的四个人的数据作为两个不同的变量,相关系数(r)为0.969。由于R的值是正的,接近+1,因此它定义了两个变量之间的正相关。

如果r的值为负,朝-1,则定义两个变量之间的负相关性。但这是变量相关性的方向因素。

那力量呢?价值越接近r对于-1或+1,值之间的相关性越强。另一方面,接近0的值r,相关性较低。

Assume that our data consist of the same age but different income values as below:

示例02
Name 年龄(x) Income(y)
杰米 26 1800
乔纳森 44 1200
雅各布 32 1500
内森 28 1700

The scatter plot for the data would look as below:

图3

您是否注意到数据之间有线性关系,但处于向下方向?

这表示两个变量之间的负相关性,即相关系数的值倾向于-1。当我们计算此数据的R值时,我们将获得-0.984的结果。

Note

数据点越接近线性关系,两个值之间的相关性越强。

As we have represented how the negative and positive correlation looks on a scatter plot, it's only fair we show what the scatter plot should look like when the correlation coefficient value is near 0.

Assume the data below with different income values:

示例03
Name 年龄(x) Income(y)
杰米 26 3500
乔纳森 44 2000
雅各布 32 2500
内森 28 500

The scatter plot for the data would look as below:

图4

The data shows no linearity (we can't draw a straight line through all the points) and is random in all likelihood. When we calculate the data's correlation coefficient (r), we get the result of -0.107. The value of r does not have any units.

Getting the coefficient values as -1, +1, or 0 is practically difficult. However, as the values returned are in decimals, you can interpret them by applying specific cutoffs to the values to describe the strength of the correlation coefficients(r).

例如,如果该值介于0.00 - 0.10, it represents no correlation, while a value between 0.90-1.00 indicates a powerful correlation between the variables.

公式

The correlation coefficient (r) is calculated between two variables that are represented by continuous data from a random population using the formula:

公式x和y

让我们手动计算相关系数,以了解该公式如何通过节省时间为分析师提供更好的生活。让我们假设我们的四个随机人的数据是他们的年龄和收入。

示例04
Name 年龄(x) Income(y)
杰米 26 2800
乔纳森 44 3400
雅各布 32 3000
内森 28 3000

We have separated all the values from the formula and will build upon them as we calculate the coefficient value.

遵循的步骤是:

  • 分别复制F和H列中年龄和收入的值。您还可以使用等于(=)符号引用它们。
  • Calculate the mean for Age and Income using theAVERAGE functionsuch that the average age is 32.5 and the average income is 3050
  • 分别从其平均x和y中的y中减去列中的平均值y,分别从列中y中的平均值y。
  • For columns L & M, take the square of the values in columns J and K, respectively, using the formula =POWER(J3,2)
  • 将列中的值乘以J&K中的值以获取N列中的结果
  • 在单元格L9中,使用公式= sum(L3:l6)以L列中的所有值的总和
  • 同样,在单元格中,M9和N9分别采用M&N列中的值之和。
  • 最后,在细胞C10中,使用公式= N9/(SQRT(L9*M9))获得Pearson相关系数的结果,从而导致0.969。

该函数的语法是:

= pearson(array1,array2)

在哪里,

array1 = collection/set of independent values

array2 = collection/set of dependent values

笔记

当逻辑或文本值作为数组的一部分提供时,该函数会忽略它们。如果Array1和Array2的长度不同,则可能会遇到#N/A错误。

例子

Here comes the most awaited moment. Finally, we will use the Excel spreadsheet formula to calculate the value of r. Our data for age and income is as below:

桌子

Using the formula = PEARSON(C3:C6, D3:D6), we get the result of 0.969, the same as what we had calculated manually in our Excel spreadsheet. Yep, it's that simple.

But by now, you know the absolute basics of a correlation test and what we intend to achieve by calculating the correlation coefficient r.

因此,现在,即使您无法访问笔记本电脑,您仍然可以抓住一张纸和笔以及计算器,并获得相同的价值来了解不同的指标财务报表更好的。

让我们看看使用Excel中的公式计算R值的另一个示例。

假设您为Nike Inc.对于2019年财政年度结束。

在C列中,您拥有历史和预测的“收入”,而在D列中,您有预期的'每股收益。'

桌子

By using the formula = PEARSON(C3:C10, D3:D10) in cell D13, you will get the result of 0.807. This implies that the Revenue and Earnings per share have a linear relationship and a strong positive correlation.

There aren't any 'outlier' predictions or a sudden spike in either revenue or EPS (for example 100% increase in revenue in 2023 followed by a -10% decrease in revenue in 2024).

If the prediction has outlier values, the Pearson correlation coefficient deviates toward zero.

Excel功能

如果使用公式后,如果您获得重复出现的数字或小数号,则可以使用圆形功能以及=圆形的公式(Pearson(C3:C10,D3:D10),3)。

Digit 3意味着我们已将值舍入到小数点之后的三位数。

皮尔森与Correl

相关函数与Pearson函数在计算来自随机种群的两个值的相关系数R时相似。

但是,相关函数“持有”的唯一优点是,它比2003年之前的excel版本中具有更准确的值(也许是因为如今几乎没有人使用它们)。

Since then, Excel has flourished tremendously as software, and if you use either function to calculate the value of r you will get the same result (without any rounding-off errors for either function).

相关函数的语法为

= correl(array1,array2)

在哪里,
array1 = collection/set of independent values

array2 = collection/set of dependent values

笔记

当逻辑或文本值作为数组的一部分提供时,该函数会忽略它们。如果Array1和Array2的长度不同,则可能会遇到#N/A错误。

For example, assume that you have the below data for x & y:

Excel

我们在细胞F8中使用公式= Pearson(B3:B18,C3:C18),并且在细胞F9中使用= Correl(B3:B18,C3:C18),以获得两个配方的结果为0.195788。

Excel

最终,您是您使用哪种功能来找到相关系数r的值,因为两者都给出相同的结果。

要记住的重要事情

  • 如果将不同长度的数组引用,例如array1和d3:d7作为array2,则将c3:c6作为array2,因为array2比array1多一个元素。
  • 您可能会得到#DIV/0!错误,如果任何参考数组(array1或array2)为空或值为零。
Excel Modeling Course

您需要掌握Excel建模所需的一切

To Help You Thrive in the Most Prestigious Jobs on Wall Street.

2ManBetX登陆

Researched and authored by Akash Bagul|LinkedIn

免费资源manbetx3.0手机客户端

要继续学习和发展您的职业,请查看这些其他有用的WSOmanbetx3.0手机客户端资源: