– Working with relationships between two variables
• “Donation “ made to teacher & Stats Test Score
0
10
20
30
40
50
60
70
80
90
100
$0 $20 $40 $60 $80
StatsTestScore
Correlation & Regression
• Univariate & Bivariate Statistics – U: frequency distribution, mean, mode, range, standard deviation– B: correlation – two variables
• Correlation– linear pattern of relationship between one variable (x) and
another variable (y) – an association between two variables– relative position of one variable correlates with relative
distribution of another variable
• X - An explanatory variable attempts to explain the observed outcomes in Y –A response variable measures an outcome of a study.
• Warning: – No proof of causality– Cannot assume x causes y
Scatterplot orScatter Diagram
a plot of paired data to determine or show a relationship between two variables
Graduating Seniors by State in 2005
The state of Louisiana
The state of Rhode Island
AP Statistics, Section 3.1, Part 1
5
Figure 3.1 (Percent taking SAT vs. Score)
• Attributes of a good scatterplot– Consistent and uniform scale– Label on both axis– Accurate placement of data– Data throughout the axis– Axis break lines if not starting at zero.
• To achieve this goal you should try to do your scatterplots on graph paper.
Graduating Seniors by State in 2005
States from NE, Mid-Atlantic and West
States from Midwest, Mtn Central, and Southwest
Paired Data
Miles traveled Minutes2 65 9
12 237 187 15
15 2810 19
Scatter Diagram
Relationship between miles traveled and minutes
0
10
20
30
0 5 10 15 20
miles
min
utes
Miles Minutes2 65 912 237 187 1515 2810 19
Linear Correlation
The general trend of the points seems to follow a straight line segment.
Linear Correlation
Non-Linear Correlation
No Linear Correlation
High Linear Correlation
Points lie close to a straight line.
High Linear Correlation
Moderate Linear Correlation
Low Linear Correlation
Perfect Linear Correlation
Questions Arising
• Can we find a relationship between x and y?
• How strong is the relationship?
Relationship between miles traveled and minutes
05
1015202530
0 5 10 15 20
miles
min
utes
When there appears to be a linear relationship between x and y:
attempt to “fit” a line to the scatter diagram.
When using x values to predict y values:
• Call x the explanatory variable
• Call y the response variable
Scatterplot!
• No Correlation– Random or circular assortment of dots
• Positive Correlation– ellipse leaning to right
– GPA and SAT– Smoking and Lung Damage
– Number of Whoppers eaten and Mr. Flynn’s weight
• Negative Correlation– ellipse learning to left
– Depression & Self-esteem
– Studying & test errors
– Vampire friends & Werewolf boyfriends
AP Statistics, Section 3.1, Part 1
22
Interpreting Scatterplots
• Pattern/Shape: linear, parabola, bell shaped– Deviations from pattern: Are there areas where the data conform
less to the pattern?
– Form: Are there clusters of data?
– Special data: Are there any influential points?
– Is a transformation of data necessary?
• Trend/Direction: positive, negative, or WTF?– As x increases what happens to y?
• Strength/Association: weak, moderate, strong– IF a line were drawn through the data, how close would the points
be to the line?
– Is the a small or large amount of variability within the y values?
Pearson’s Correlation Coefficient
• “r” indicates…– strength of relationship (strong, weak, or none)
– the variation of the points around the model (linear)
– direction of relationship
• positive (direct) – variables move in same direction
• negative (inverse) – variables move in opposite directions
• r ranges in value from –1.0 to +1.0
Strong Negative No Rel. Strong Positive-1.0 0.0 +1.0
•Try quick estimates–Next slide and strange quiz
Practice with Scatterplots
r = .__ __
r = .__ __
r = .__ __
r = .__ __
A relationship between correlation coefficient, r, and the slope, b, of the least squares line:
x values theofdeviation standards and
y values theofdeviation standards where
x
y
y
x
s
sbr
Linear correlation coefficient
1 r +1
Calculating the Correlation Coefficient, r
pairsdataofnumbern
n
yySS
n
xxSS
n
yxxySSwhere
SSSS
SSr
2
2
y
2
2
x
xy
yx
xy
Paired Data
Miles traveled Minutes2 65 9
12 237 187 15
15 2810 19
Scatter Diagram
Relationship between miles traveled and minutes
0
10
20
30
0 5 10 15 20
miles
min
utes
Miles Minutes2 65 912 237 187 1515 2810 19
Find the Least Squares Linex (Miles
Traveled)y
(Minutes)x2 xy
2 6 4 12
5 9 25 45
12 23 144 276
7 18 49 126
7 15 49 105
15 28 225 420
10 19 100 190
x = 58 y = 118 x2 = 596 xy = 1174
Finding the slope
700495.142857.115
28571.196
SS
SSbslope
42857.1157
58596
n
xxSSand
28571.1967
)118)(58(1174
n
yxxySS
x
xy
22
2
x
xy
Finding the y-intercept
7673273.2)2857143.8(700495.1857143.16
xbyaerceptinty
2857143.87
58valuesxofmeanx
857143.167
118valuesyofmeany
The equation of the least squares line is:
y = a + bx
y = 2.8 + 1.7x
To Compute r:
• Complete a table, with columns listing x, y, x2, y2, xy
• Compute SSxy, SSx, and SSy
• Use the formula:
yx
xy
SSSS
SSr
Find the Correlation Coefficientx
(Miles)y
(Min.)x2 y2 xy
2 6 4 36 12
5 9 25 81 45
12 23 144 529 276
7 18 49 324 126
7 15 49 225 105
15 28 225 784 420
10 19 100 361 190
x = 58 y = 118 x2 = 596 y2=2340 xy = 1174
Calculations:
9753643.085714.35042857.115
28571.196
SSSS
SSr
85714.3507
1182340
n
yySS
42857.1157
58596
n
xxSS
28571.1967
)118)(58(1174
n
yxxySS
yx
xy
22
2
y
22
2
x
xy
The Correlation Coefficient,
r = 0.9753643
r 0.98
AP Statistics, Section 3.2, Part 1 38
Calculating Correlation
• The calculation of correlation is based on mean and standard deviation.
• Remember that both mean and standard deviation are not resistant measures.
1
1i i
x y
x x y yr
n s s
AP Statistics, Section 3.2, Part 1 39
Calculating Correlation
• What does the contents of the parenthesis look like?
• What happens when the values are both from the lower half of the population? From the upper half?
1
1i i
x y
x x y yr
n s s
Both z-values are negative.
Their product is positive.
Both z-values are positive.
Their product is positive.
The formula for calculating z-
values.
AP Statistics, Section 3.2, Part 1 40
Calculating Correlation
• What happens when one value is from the lower half of the population but other value is from the upper half?
1
1i i
x y
x x y yr
n s s
One z-value is positive and the other is negative. Their product is
negative.
AP Statistics, Section 3.2, Part 1 41
Using the TI-83/84 to calculate r• With Diagnostics ON:
• Run LinReg(a+bx) [STAT>CALC>option 8] with the explanatory variable as the first list, and response variable as the second list
The results are the slope and vertical intercept of the regression equation (more on that later) and values of r and r2. (More on r2 check next handout ;)
Predictive Potential
• Coefficient of Determination– r²
– Amount of variance accounted for in y by x
– Percentage increase in accuracy you gain by using the regression line to make predictions
– Without correlation, you can only guess the mean of y
– [Used with regression]
20%0% 80% 100%60%40%
Understanding r-squared actvity
Limitations of Correlation
• linearity: – can’t describe (accurately) non-linear relationships
– e.g., flavor and % eaten, thickness and strength
• truncation of range: – underestimate strength of relationship if you can’t see full range
of x value
• no proof of causation– third variable problem:
• could be 3rd variable causing change in both variables
• directionality: can’t be sure which way causality “flows”
• “We don’t get it” – what does it have to do with that f#$%@! Line?
That is for another session…
Regression
• Regression: Correlation + Prediction– predicting y based on x
– e.g., predicting….
• throwing points (y)
• based on distance from target (x)
• Regression equation – formula that specifies a line
– y’ = a + bx
– plug in a x value (distance from target) and predict y (points)
– note
• y= actual value of a score
• y’= predict value •Data Handout–Test takers, planets, darts
AP Statistics, Section 3.3, Part 1 45
The Least-Square Regression
• Finds the best fit line by trying to minimize the areas formed by the difference of the real data from the values predicted by the model.
AP Statistics, Section 3.3, Part 1 46
The Least-Square Regression
• Statisticians use a slightly different version of “slope-intercept” form.
y
x
y a bx
sb r
s
a y bx
Slope is the product of r value and std dev ratio
Y-intercept is the value found using the avg x and avg y
Distance from target
2624222018161412108
Tota
l ba
ll to
ss p
oin
ts
120
100
80
60
40
20
0 Rsq = 0.6031
Regression Graphic – Regression Line
if x=18 then…
y’=47
if x=24 then…
y’=20
AP Statistics, Section 3.3, Part 1 48
Predicting Model
• To put the regression line on the graph use the Statistics:Eq:RegEQ from the Vars menu to put the Y1
equation.
• Then you can use Trace or Table or Y1 to find response values that correspond to particular experimental values.
Regression Equation
• y’= a + bx– y’ = predicted value of y– b = slope of the line– x = value of x that you plug-in– a = y-intercept (where line crosses y axis)
• In the dart throwing case….– y’ = 125.401 - 4.263(x)
• So if the distance is 2020 feet– y’ = 125.401 - 4.263(2020) – y’ = 125.401 -85.26
– y’ = 40.141
See STAT – CALC – LinReg: a + bx
Drawing a Regression Line by Hand
Four steps
1. Use the y-intercept (if possible; does it have meaning =interval vs. rational)
2. Plot the average point (mean x, mean y)
3. Plug in a large value for x (just so it falls on the right end of the graph), plug it in for x, then plot the resulting point
4. Connect the three points with a straight line!
AP Statistics, Section 3.3, Part 1 51
Residuals
• It is important to note that the observed value almost never match the predicted values exactly
• The difference between the observed value and predicted has a special name: residual
Observed Value: (y)
Predicted Value ( ) y
Residual:ˆy y
AP Statistics, Section 3.3, Part 1 52
Residual Plots
• You can plot the residuals to see if the there is any trends with the quality of the predictive model
• Try looking in the List menu for “RESID:”
AP Statistics, Section 3.3, Part 1 53
Residual Plots
• This residual shows no tendencies. It is equally bad throughout.
• This suggests that the original relationship is linear.
AP Statistics, Section 3.3, Part 1
54
“Pattern” =Not Linear
“Well Distributed”=Linear
Predictive Ability
• Mantra!! – As variability decreases, prediction accuracy __________
– if we can account for variance, we can make better predictions
• As r increases:– r² increases
• “variance accounted for” increases
• the prediction accuracy increases
– prediction error decreases (distance between y’ and y)
– Sy decreases
• the standard error of the residual/predictor
• measures overall amount of prediction error
– It can be thought of like this …
Thanks – Peace !
We like big r’s and we cannot lie!!!
You other brothers can’t deny!!!
Check out those residuals son
and plot em with your TI-84 on
Cause if they don’t look all scattered and patterned
then your least squared line is shattered
Then I only want that - if your scale and r squared is fat
So kick out those nasty outliers
When your correlation factor is on
BABY GOT STATS!
Top Related