第8章統計学
Linear Regression線形回帰
The final step in our analysis of the relationship between two datasets is to find and use the equation of the regression line. For a given set of explanatory and response data, the regression line (also called the least-squares line or line of best fit) is the line that does the best job of approximating the data.
英語のヒント
2つのデータセットの関係の分析の最後の手順は、回帰直線の式を求めて使うことである。与えられた説明と応答のデータの集まりについて、回帰直線(最小二乗直線、最良適合直線とも呼ばれる)とは、データをいちばんよく近似する直線である。
What does it mean to say that a particular line does the “best job” of approximating the data? The way that statisticians characterize this “best line” is rather technical, but we’ll include it for the sake of satisfying your curiosity (and backing up the claim of "best"). Imagine drawing a line that looks like it does a pretty good job of approximating the data. Most of the points in the scatter plot will probably not fall exactly on the line; the distance above or below the line a given point falls is called that point’s residual. We could compute the residuals for every point in the scatter plot. If you take all those residuals and square them, then add the results together, you get a statistic called the sum of squared errors for the line (the name tells you what it is: “sum” because we’re adding, “squared” because we’re squaring, and “errors” is another word for “residuals”). The line that we choose to be the “best” is the one that has the smallest possible sum of squared errors. The implied minimization (“smallest”) is where the “least” in “least squares” comes from; the “squares” comes from the fact that we’re minimizing the sum of squared errors. This is very similar to the process we outlined in the "game" that we used to introduce the mean. Both the regression line and the mean are designed to minimize a sum of squared errors. Here ends the super technical part.
英語のヒント
ある直線がデータを「いちばんよく」近似するとはどういうことか。統計学者がこの「最良の直線」を特徴づける方法はかなり専門的だが、好奇心を満たすために(そして「最良」という主張を裏づけるために)載せる。データをかなりよく近似しているように見える直線を引くことを想像しよう。散布図の点のほとんどは、おそらく直線の上にちょうどは来ない。ある点が直線の上または下にある距離を、その点の残差という。散布図のすべての点について残差を計算できる。それらの残差をすべて2乗して足し合わせると、その直線の誤差平方和という統計量が得られる(名前がそれが何かを教えてくれる。足すので「和」、2乗するので「平方」、「誤差」は「残差」の別の言葉である)。「最良」として選ぶ直線は、ありうるもっとも小さい誤差平方和をもつものである。その最小化(「最小」)が「最小二乗」の「最小」の由来で、「二乗」は誤差平方和を最小化することに由来する。これは、平均を導入するのに使った「ゲーム」で述べた過程ととてもよく似ている。回帰直線も平均も、誤差平方和を最小にするように作られている。超専門的な部分はここまでである。
Finding the Equation of the Regression Line回帰直線の式を求める
So, how do we find the equation of the regression line? Recall the point-slope form of the equation of a line:
英語のヒント
では、回帰直線の式はどう求めるのか。直線の式の点傾き形を思い出そう:
The regression line has two properties that we can use to find its equation. First, it always passes through the point of means. If and are the means of the explanatory and response datasets, respectively, then the point of means is . We’ll use that as the point in the point-slope form of the equation. Second, if and are the standard deviations of the explanatory and response datasets, respectively, and if is the correlation coefficient, then the slope is . Putting all that together with the point-slope formula gives us this:
英語のヒント
回帰直線には、式を求めるのに使える2つの性質がある。第1に、つねに平均の点を通る。とがそれぞれ説明と応答のデータセットの平均なら、平均の点はである。これを式の点傾き形の点に使う。第2に、とがそれぞれ説明と応答のデータセットの標準偏差で、が相関係数なら、傾きはである。これらすべてを点傾きの公式と合わせると、次が得られる:
Let's walk through an example.
英語のヒント
例を見ていこう。
Example 8.49例題 8.49
Finding the Equation of the Regression Line from Statistics統計量から回帰直線の式を求める
Suppose you have datasets and with the following statistics: has mean 21 and standard deviation 4, has mean 8 and standard deviation 2, and their correlation coefficient is −0.4. What’s the equation of the regression line?
英語のヒント
次の統計量をもつデータセットとがあるとする。は平均21、標準偏差4で、は平均8、標準偏差2で、相関係数は−0.4である。回帰直線の式は何か。
Solution解答
Step 1: We’re given , , , , and . Let's start with the formula for the equation of the regression line:
英語のヒント
手順1:、、、、が与えられている。回帰直線の式の公式から始めよう:
Step 2: Plugging in our values gives us:
英語のヒント
手順2:値を代入すると、次が得られる:
Step 3: Our final regression line equation is:
英語のヒント
手順3:最終的な回帰直線の式は次のとおりである:
As you can see, finding the equation of the regression line involves a lot of steps if you have to find all of the values of the needed quantities yourself. But, as usual, technology comes to our rescue. This video (which you actually watched earlier when learning how to create scatter plots) covers the regression line at around the 3:30 mark. Note that Google Sheets calls it the "trendline."
英語のヒント
わかるように、必要な量の値をすべて自分で求めなければならないなら、回帰直線の式を求めるには多くの手順が必要である。しかし、例によって、計算機器が助けてくれる。この動画(実は前に散布図の作り方を学ぶときに見た)は、3:30あたりで回帰直線を扱っている。Google Sheetsはそれを「トレンドライン」と呼ぶことに注意しよう。
Let's put this into practice.
英語のヒント
これを実践しよう。
Example 8.50例題 8.50
Finding the Equation of the Regression Line Using Google SheetsGoogle Sheetsを使って回帰直線の式を求める
In Example 8.46, we considered the relationship between goals scored (GF) and goals against (GA) using the dataset “NHL19”. Recreate the scatter plot in Google Sheets, and use it to find the equation of the regression line.
英語のヒント
Solution解答
Once we have recreated the scatter plot, we find the equation of the regression line by clicking the three dots at the top right of the plot, selecting “Edit chart,” then clicking on “Customize” and “Series.” We add the regression line by checking the box next to “Trendline,” and then we show the equation by selecting “Use Equation” in the drop-down menu under “Label.” The equation of the tangent line is .
英語のヒント
散布図を作り直したら、図の右上の3つの点をクリックして「グラフを編集」を選び、次に「カスタマイズ」と「系列」をクリックして、回帰直線の式を求める。「トレンドライン」の隣のボックスにチェックを入れて回帰直線を加え、「ラベル」の下のドロップダウンメニューで「方程式を使用」を選んで式を表示する。回帰直線の式はである。
Using the Equation of the Regression Line回帰直線の式を使う
Once we’ve found the equation of the regression line, what do we do with it? We’ll look at two possible applications: making predictions and interpreting the slope.
英語のヒント
回帰直線の式を求めたら、それをどうするのか。2つの応用を見る。予測することと、傾きを解釈することである。
We can use the equation of the regression line to predict the response value for a given explanatory value . All we have to do is plug that explanatory value into the formula and see what response value results. This is useful in two ways: first, it can be used to make a guess about an unknown data value (like one that hasn’t been observed yet). Second, it can be used to evaluate performance (meaning, we can predict an outcome given a particular event). In Example 8.45, we created a scatter plot of final exam scores vs. midterm exam scores using this data:
英語のヒント
回帰直線の式を使って、与えられた説明の値に対する応答の値を予測できる。その説明の値を公式に代入して、どんな応答の値が出るかを見るだけでよい。これは2つの点で役に立つ。第1に、未知のデータの値(まだ観察されていないものなど)を推測するのに使える。第2に、成績を評価するのに使える(つまり、ある出来事が与えられたときの結果を予測できる)。例題8.45で、次のデータを使って期末試験の点数対中間試験の点数の散布図を作った:
| Name名前 | Midterm Grade中間試験の点 | Final Grade期末試験の点 |
|---|---|---|
| Allisonアリソン | 88 | 84 |
| Benjaminベンジャミン | 71 | 80 |
| Carlyカーリー | 75 | 77 |
| Danielダニエル | 94 | 95 |
| Elmoエルモ | 68 | 73 |
The equation of the regression line is , where is the final exam score and is the midterm exam score. If Frank scored 85 on the midterm, then our prediction for his final exam score is . To use the regression line to evaluate performance, we use a data value we’ve already observed. For example, Allison scored 88 on the midterm. The regression line predicts that someone who scores an 88 on the midterm will get on the final. Allison actually scored 84 on the final, meaning she underperformed expectations by almost 4 points .
英語のヒント
回帰直線の式はで、は期末試験の点数、は中間試験の点数である。フランクが中間試験で85点をとったなら、期末試験の点数の予測はである。回帰直線を使って成績を評価するには、すでに観察したデータの値を使う。たとえば、アリソンは中間試験で88点をとった。回帰直線は、中間試験で88点をとった人は期末試験でをとると予測する。アリソンは実際には期末試験で84点をとったので、期待を約4点下回った。
The second application of the equation of the regression line is interpreting the slope of the line to describe the relationship between the explanatory and response datasets. For the exam data in the previous paragraph, the slope of the regression line is 0.687. Recall that the slope of a line can be computed by finding two points on the line and dividing the difference in the -values of those points by the difference in the -values. Keeping that in mind, we can interpret our slope as . Multiplying both sides of that equation by the denominator of the fraction, we get . Thus, a one-point increase in the midterm score would result in a predicted increase in the final score of 0.687 points. A ten-point drop in the midterm score would give us a decrease in the predicted final score of 6.87 points. In general, the slope gives us the predicted change in the response that corresponds to a one unit increase in the explanatory variable.
英語のヒント
回帰直線の式の2つ目の応用は、直線の傾きを解釈して説明と応答のデータセットの関係を述べることである。前の段落の試験のデータでは、回帰直線の傾きは0.687である。直線の傾きは、直線上の2点を見つけ、それらの点のの値の差をの値の差で割って計算できることを思い出そう。それを念頭に置くと、傾きをと解釈できる。その等式の両辺に分数の分母をかけると、が得られる。したがって、中間試験の点数が1点増えると、期末試験の予測の点数は0.687点増える。中間試験の点数が10点下がると、期末試験の予測の点数は6.87点下がる。一般に、傾きは、説明変数が1単位増えることに対応する応答の予測の変化を与える。
Example 8.51例題 8.51
Applying the Equation of the Regression Line回帰直線の式を当てはめる
The data in “MLB2019Off” gives offensive team stats for the 2019 Major League Baseball season. Use that dataset to answer the following questions:
英語のヒント
「MLB2019Off」のデータは、2019年のメジャーリーグのシーズンのチームの攻撃の統計を示している。そのデータセットを使って次の問いに答えよ:
- What is the equation of the regression line for runs (R) vs. hits (H)?
英語のヒント
得点(R)対ヒット(H)の回帰直線の式は何か。 - How many runs would we expect a team to score if the team got 1500 hits in a season?
英語のヒント
シーズンに1500本のヒットを打ったチームは何点とると期待できるか。 - Did the Kansas City Royals (KCR) overperform or underperform in terms of runs scored, based on their hit total? By how much?
英語のヒント
カンザスシティ・ロイヤルズ(KCR)は、ヒットの総数にもとづくと、得点で予想を上回ったか、下回ったか。どれだけか。 - Write a sentence to interpret the slope of the regression line.
英語のヒント
回帰直線の傾きを解釈する文を書け。
Solution解答
- Using Google Sheets, we find that the regression line equation is , where is the number of runs scored and is the number of hits.
英語のヒント
Google Sheetsを使うと、回帰直線の式はで、は得点の数、はヒットの数である。 - Plugging 1500 into the equation of the regression line, we get . We would predict that a team with 1500 hits would score 870 runs.
英語のヒント
回帰直線の式に1500を代入すると、が得られる。1500本のヒットを打つチームは870点をとると予測する。 - The Royals had 1356 hits, so we would predict their run total to be . They actually scored 691 runs, so they underperformed expectations by 52 runs .
英語のヒント
ロイヤルズのヒットは1356本だったので、得点の総数はと予測する。実際には691点だったので、期待を52点下回った。 - The slope gives us the predicted change in the response that corresponds to a one unit increase in the explanatory variable. So, we expect one additional hit to result in 0.884 more runs. Since 0.884 runs doesn’t really make sense, we can get a better interpretation by multiplying through by ten or one hundred: Ten additional hits will result in almost nine additional runs, or a hundred additional hits will yield on average just over 88 additional runs.
英語のヒント
傾きは、説明変数が1単位増えることに対応する応答の予測の変化を与える。だから、ヒットが1本増えると得点が0.884増えると期待する。0.884点はあまり意味をなさないので、10倍や100倍するとよりよい解釈が得られる。ヒットが10本増えると得点はほぼ9点増え、ヒットが100本増えると得点は平均で88点を少し超えて増える。