{"id":553,"date":"2015-07-18T18:34:09","date_gmt":"2015-07-18T22:34:09","guid":{"rendered":"http:\/\/sites.berry.edu\/vbissonnette\/?page_id=553"},"modified":"2016-06-23T10:08:14","modified_gmt":"2016-06-23T14:08:14","slug":"correlation-solution","status":"publish","type":"page","link":"https:\/\/sites.berry.edu\/vbissonnette\/index\/stats-homework\/documentation\/correlation\/correlation-solution\/","title":{"rendered":"Correlation Solution"},"content":{"rendered":"<h3>Example homework problem:<\/h3>\n<p>You work for an automotive magazine, and you are investigating the relationship between a car&#8217;s gas mileage (in miles-per-gallon) and the amount of horsepower produced by a car&#8217;s engine. You collect the following data:<\/p>\n<table>\n<tbody>\n<tr>\n<td style=\"border-bottom: 1px solid black\">Automobile:<\/td>\n<td style=\"border-bottom: 1px solid black;width: 60px;text-align: center\">1<\/td>\n<td style=\"border-bottom: 1px solid black;width: 60px;text-align: center\">2<\/td>\n<td style=\"border-bottom: 1px solid black;width: 60px;text-align: center\">3<\/td>\n<td style=\"border-bottom: 1px solid black;width: 60px;text-align: center\">4<\/td>\n<td style=\"border-bottom: 1px solid black;width: 60px;text-align: center\">5<\/td>\n<td style=\"border-bottom: 1px solid black;width: 60px;text-align: center\">6<\/td>\n<td style=\"border-bottom: 1px solid black;width: 60px;text-align: center\">7<\/td>\n<td style=\"border-bottom: 1px solid black;width: 60px;text-align: center\">8<\/td>\n<td style=\"border-bottom: 1px solid black;width: 60px;text-align: center\">9<\/td>\n<td style=\"border-bottom: 1px solid black;width: 60px;text-align: center\">10<\/td>\n<\/tr>\n<tr>\n<td class=\"lf\">Horsepower:<\/td>\n<td style=\"text-align: center\">95<\/td>\n<td style=\"text-align: center\">135<\/td>\n<td style=\"text-align: center\">120<\/td>\n<td style=\"text-align: center\">167<\/td>\n<td style=\"text-align: center\">210<\/td>\n<td style=\"text-align: center\">146<\/td>\n<td style=\"text-align: center\">245<\/td>\n<td style=\"text-align: center\">110<\/td>\n<td style=\"text-align: center\">160<\/td>\n<td style=\"text-align: center\">130<\/td>\n<\/tr>\n<tr>\n<td class=\"lf\">MPG:<\/td>\n<td style=\"text-align: center\">37<\/td>\n<td style=\"text-align: center\">19<\/td>\n<td style=\"text-align: center\">26<\/td>\n<td style=\"text-align: center\">20<\/td>\n<td style=\"text-align: center\">24<\/td>\n<td style=\"text-align: center\">30<\/td>\n<td style=\"text-align: center\">15<\/td>\n<td style=\"text-align: center\">32<\/td>\n<td style=\"text-align: center\">23<\/td>\n<td style=\"text-align: center\">33<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>Is there a significant correlation between horsepower and MPG (alpha = .05)?<\/p>\n<hr \/>\n<p>The goal of your analysis is to assess the naturally-occurring relationship between these two variables. To do this, we will compute the <u>Pearson Product Moment Correlation Coefficient<\/u>:<\/p>\n<p><a href=\"http:\/\/sites.berry.edu\/vbissonnette\/wp-content\/uploads\/sites\/21\/2015\/07\/corr1.png\"><img loading=\"lazy\" decoding=\"async\" class=\" size-full wp-image-82 aligncenter\" src=\"http:\/\/sites.berry.edu\/vbissonnette\/wp-content\/uploads\/sites\/21\/2015\/07\/corr1.png\" alt=\"corr1\" width=\"261\" height=\"65\" \/><\/a>The correlation is equal to the ratio of the covariance between your variables to the variance within your variables. <i>n<\/i> is equal to the number of pairs of scores.<\/p>\n<p>The <u>Covariance<\/u> between the two variables is equal to:<\/p>\n<p><a href=\"http:\/\/sites.berry.edu\/vbissonnette\/wp-content\/uploads\/sites\/21\/2015\/07\/corr2.png\"><img loading=\"lazy\" decoding=\"async\" class=\" size-full wp-image-83 aligncenter\" src=\"http:\/\/sites.berry.edu\/vbissonnette\/wp-content\/uploads\/sites\/21\/2015\/07\/corr2.png\" alt=\"corr2\" width=\"224\" height=\"64\" \/><\/a>where \u03a3XY is equal to the sum of the crossproducts: you multiply each pair of scores and then add up the products.<\/p>\n<p><b>Compute test statistic<\/b>. Begin by computing the crossproduct scores, and then compute \u03a3XY, \u03a3X, and \u03a3Y:<\/p>\n<table>\n<tbody>\n<tr>\n<td style=\"border-bottom: 1px solid black\">Automobile:<\/td>\n<td style=\"border-bottom: 1px solid black;width: 70px;text-align: center\">1<\/td>\n<td style=\"border-bottom: 1px solid black;width: 70px;text-align: center\">2<\/td>\n<td style=\"border-bottom: 1px solid black;width: 70px;text-align: center\">3<\/td>\n<td style=\"border-bottom: 1px solid black;width: 70px;text-align: center\">4<\/td>\n<td style=\"border-bottom: 1px solid black;width: 70px;text-align: center\">5<\/td>\n<td style=\"border-bottom: 1px solid black;width: 70px;text-align: center\">6<\/td>\n<td style=\"border-bottom: 1px solid black;width: 70px;text-align: center\">7<\/td>\n<td style=\"border-bottom: 1px solid black;width: 70px;text-align: center\">8<\/td>\n<td style=\"border-bottom: 1px solid black;width: 70px;text-align: center\">9<\/td>\n<td style=\"border-bottom: 1px solid black;width: 70px;text-align: center\">10<\/td>\n<td style=\"border-bottom: 1px solid black;width: 70px;text-align: center\"><b>Sum<\/b><\/td>\n<\/tr>\n<tr>\n<td class=\"lf\">Horsepower:<\/td>\n<td style=\"text-align: center\">95<\/td>\n<td style=\"text-align: center\">135<\/td>\n<td style=\"text-align: center\">120<\/td>\n<td style=\"text-align: center\">167<\/td>\n<td style=\"text-align: center\">210<\/td>\n<td style=\"text-align: center\">146<\/td>\n<td style=\"text-align: center\">245<\/td>\n<td style=\"text-align: center\">110<\/td>\n<td style=\"text-align: center\">160<\/td>\n<td style=\"text-align: center\">130<\/td>\n<td style=\"text-align: center\"><b>1518<\/b><\/td>\n<\/tr>\n<tr>\n<td>MPG:<\/td>\n<td class=\"rtul\" style=\"text-align: center\">37<\/td>\n<td class=\"rtul\" style=\"text-align: center\">19<\/td>\n<td class=\"rtul\" style=\"text-align: center\">26<\/td>\n<td class=\"rtul\" style=\"text-align: center\">20<\/td>\n<td class=\"rtul\" style=\"text-align: center\">24<\/td>\n<td class=\"rtul\" style=\"text-align: center\">30<\/td>\n<td class=\"rtul\" style=\"text-align: center\">15<\/td>\n<td class=\"rtul\" style=\"text-align: center\">32<\/td>\n<td class=\"rtul\" style=\"text-align: center\">23<\/td>\n<td class=\"rtul\" style=\"text-align: center\">33<\/td>\n<td class=\"rtul\" style=\"text-align: center\"><b>259<\/b><\/td>\n<\/tr>\n<tr>\n<td class=\"lf\">Crossproduct:<\/td>\n<td>3515<\/td>\n<td>2565<\/td>\n<td>3120<\/td>\n<td>3340<\/td>\n<td>5040<\/td>\n<td>4380<\/td>\n<td>3675<\/td>\n<td>3520<\/td>\n<td>3680<\/td>\n<td>4290<\/td>\n<td><b>37125<\/b><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>Here are the preliminary sums: \u03a3X = 1518, \u03a3Y = 259, and \u03a3XY = 37125. <i>n<\/i> = 10.<\/p>\n<p>Compute the variance for each variable. You will find that the variance of X (horsepower) is equal to 2127.51, and the variance of Y (gas mileage) is equal to 48.99. If you would like help with these computations, see the documentation for <a href=\"https:\/\/sites.berry.edu\/vbissonnette\/index\/stats-homework\/documentation\/explore-data\/\">descriptive statistics<\/a>. Now, compute the covariance between the two variables:<\/p>\n<p><a href=\"http:\/\/sites.berry.edu\/vbissonnette\/wp-content\/uploads\/sites\/21\/2015\/07\/corr3.png\"><img loading=\"lazy\" decoding=\"async\" class=\" size-full wp-image-84 aligncenter\" src=\"http:\/\/sites.berry.edu\/vbissonnette\/wp-content\/uploads\/sites\/21\/2015\/07\/corr3.png\" alt=\"corr3\" width=\"279\" height=\"162\" \/><\/a>Let&#8217;s pause here for a moment, and place these three statistics into a <u>Variance \/ Covariance Matrix<\/u>:<\/p>\n<table>\n<tbody>\n<tr>\n<td style=\"border-bottom: 1px solid black;width: 120px\">Variable:<\/td>\n<td style=\"border-bottom: 1px solid black;width: 120px;text-align: center\">Horsepower<br \/>\n(X)<\/td>\n<td style=\"border-bottom: 1px solid black;width: 120px;text-align: center\">MPG<br \/>\n(Y)<\/td>\n<\/tr>\n<tr>\n<td class=\"lf\">Horsepower (X):<\/td>\n<td style=\"text-align: center\">2127.5111<\/td>\n<td style=\"text-align: center\">-243.4667<\/td>\n<\/tr>\n<tr>\n<td class=\"lf\">MPG (Y):<\/td>\n<td><\/td>\n<td style=\"text-align: center\">48.9889<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>&nbsp;<\/p>\n<p>where the values along the diagonal of the matrix are the variances of X and Y, and the value off the diagonal is the covariance between X and Y. It is a good habit to construct a variance\/covariance matrix when you are working on correlation and regression problems.<\/p>\n<p>Now that you have the variances and the covariance, you will find that the correlation is equal to:<\/p>\n<p><a href=\"http:\/\/sites.berry.edu\/vbissonnette\/wp-content\/uploads\/sites\/21\/2015\/07\/corr4.png\"><img loading=\"lazy\" decoding=\"async\" class=\" size-full wp-image-85 aligncenter\" src=\"http:\/\/sites.berry.edu\/vbissonnette\/wp-content\/uploads\/sites\/21\/2015\/07\/corr4.png\" alt=\"corr4\" width=\"435\" height=\"65\" srcset=\"https:\/\/sites.berry.edu\/vbissonnette\/wp-content\/uploads\/sites\/21\/2015\/07\/corr4.png 435w, https:\/\/sites.berry.edu\/vbissonnette\/wp-content\/uploads\/sites\/21\/2015\/07\/corr4-300x45.png 300w\" sizes=\"auto, (max-width: 435px) 100vw, 435px\" \/><\/a><b>Conduct hypothesis test<\/b>. Our correlation will have <i>df<\/i> equal to the number of pairs of scores minus 2. In our case, we have 10 automobiles, so we would have <i>df<\/i> = 10 &#8211; 2 = 8.<\/p>\n<p>Alpha was set at .05 and we will conduct a two-tailed test. When you consult your <a href=\"https:\/\/sites.berry.edu\/vbissonnette\/wp-content\/uploads\/sites\/21\/2015\/07\/r.pdf\">table of critical values<\/a> for <i>r<\/i>, you will find that if our obtained value of <i>r<\/i> is greater than .632, then we would conclude that the relationship between horsepower and gas mileage is significant &#8212; i.e., that <i>r<\/i> is significantly different from zero.<\/p>\n<p>Since the obtained <i>r<\/i> (-.75) is greater in absolute value than the critical <i>r<\/i> (.632), we would conclude that there is a significant negative relationship between the horsepower level of the automobile and its gas mileage &#8212; i.e., the greater the horsepower, the lower the gas<br \/>\nmileage.<\/p>\n<p>If you are not testing <i>r<\/i> directly in your class, then you are probably testing the significance of the correlation coefficient with the <i>t<\/i> distribution:<\/p>\n<p><a href=\"http:\/\/sites.berry.edu\/vbissonnette\/wp-content\/uploads\/sites\/21\/2015\/07\/corr5.png\"><img loading=\"lazy\" decoding=\"async\" class=\" size-full wp-image-86 aligncenter\" src=\"http:\/\/sites.berry.edu\/vbissonnette\/wp-content\/uploads\/sites\/21\/2015\/07\/corr5.png\" alt=\"corr5\" width=\"392\" height=\"54\" srcset=\"https:\/\/sites.berry.edu\/vbissonnette\/wp-content\/uploads\/sites\/21\/2015\/07\/corr5.png 392w, https:\/\/sites.berry.edu\/vbissonnette\/wp-content\/uploads\/sites\/21\/2015\/07\/corr5-300x41.png 300w\" sizes=\"auto, (max-width: 392px) 100vw, 392px\" \/><\/a>This <i>t<\/i> test will have <i>df<\/i> equal to n &#8211; 2, the same as <i>r<\/i>. In our case, <i>df<\/i> = 8. With alpha = .02 and assuming a two-tailed test, we would compare <i>t<\/i> to a <a href=\"https:\/\/sites.berry.edu\/vbissonnette\/wp-content\/uploads\/sites\/21\/2015\/07\/t.pdf\">critical value<\/a> of\u00a02.306.<\/p>\n<p>Since our obtained <i>t<\/i> (-3.25) is greater in absolute value than our critical value of <i>t<\/i> (2.306), we would conclude that the correlation between horsepower and gas mileage was significant. Note that these two approaches are perfectly equivalent, and will always result in the same decision.<\/p>\n<p><b>Effect Size<\/b>. The correlation is an effective descriptive statistic in its own right. You know that it ranges from 0 to +1 and from 0 to -1, where 0 = no relationship and +1\/-1 = perfect positive\/negative relationship. In <i>Statistical Power Analysis<\/i>, Cohen suggested that we interpret a correlation of .10 as a small effect, a correlation of .30 as a moderate effect, and a correlation of .50 or greater as a large effect.<\/p>\n<p>In addition, the square of the correlation (<i>r<\/i>\u00b2) is a very useful effect size estimate called the <u>Coefficient of Determination<\/u>. <i>r<\/i>\u00b2 represents the proportion of variance in X and Y that is shared &#8212; i.e., the proportion of variance in one of the variables that can be accounted for by variation in the other variable. In our case, <i>r<\/i>\u00b2 = -.7541\u00b2 = .57. Thus, if you were predicting gas milage from horsepower, you could account for 57% of the variance in gas milage by variations in horsepower.<\/p>\n<hr \/>\n<p><a href=\"http:\/\/sites.berry.edu\/vbissonnette\/index\/stats-homework\/documentation\/correlation\/\">Return to Correlation Procedure<\/a><\/p>\n<p><a href=\"http:\/\/sites.berry.edu\/vbissonnette\/index\/stats-homework\/documentation\/\">Return to Table of Contents<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Example homework problem: You work for an automotive magazine, and you are investigating the relationship between a car&#8217;s gas mileage (in miles-per-gallon) and the amount of horsepower produced by a [&hellip;]<\/p>\n","protected":false},"author":34,"featured_media":0,"parent":548,"menu_order":0,"comment_status":"open","ping_status":"open","template":"","meta":{"site-container-style":"default","site-container-layout":"default","site-sidebar-layout":"default","site-transparent-header":"default","disable-article-header":"default","disable-site-header":"default","disable-site-footer":"default","disable-content-area-spacing":"default","footnotes":""},"class_list":["post-553","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/sites.berry.edu\/vbissonnette\/wp-json\/wp\/v2\/pages\/553","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/sites.berry.edu\/vbissonnette\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/sites.berry.edu\/vbissonnette\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/sites.berry.edu\/vbissonnette\/wp-json\/wp\/v2\/users\/34"}],"replies":[{"embeddable":true,"href":"https:\/\/sites.berry.edu\/vbissonnette\/wp-json\/wp\/v2\/comments?post=553"}],"version-history":[{"count":4,"href":"https:\/\/sites.berry.edu\/vbissonnette\/wp-json\/wp\/v2\/pages\/553\/revisions"}],"predecessor-version":[{"id":950,"href":"https:\/\/sites.berry.edu\/vbissonnette\/wp-json\/wp\/v2\/pages\/553\/revisions\/950"}],"up":[{"embeddable":true,"href":"https:\/\/sites.berry.edu\/vbissonnette\/wp-json\/wp\/v2\/pages\/548"}],"wp:attachment":[{"href":"https:\/\/sites.berry.edu\/vbissonnette\/wp-json\/wp\/v2\/media?parent=553"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}