Docsity

Lecture Notes on Simple Linear Regression | STAT 205, Study notes of Statistics

Toggle sidebar
bg1
70.067.565.062.560.057.555.0
200
180
160
140
120
100
Lengt h (cm)
Weight (g)
Scatterplot of Weight vs Length
Female Vi pera bertis
Simple๎˜ƒLinear๎˜ƒRegression๎˜ƒ
We๎˜ƒhave๎˜ƒbeen๎˜ƒintroduced๎˜ƒto๎˜ƒthe๎˜ƒnotion๎˜ƒthat๎˜ƒa๎˜ƒcategorical๎˜ƒvariable๎˜ƒcould๎˜ƒdepend๎˜ƒon๎˜ƒdifferent๎˜ƒ
levels๎˜ƒof๎˜ƒanother๎˜ƒvariable๎˜ƒwhen๎˜ƒwe๎˜ƒdiscussed๎˜ƒcontingency๎˜ƒtables.๎˜ƒ๎˜ƒ
Weโ€™ll๎˜ƒextend๎˜ƒthis๎˜ƒidea๎˜ƒto๎˜ƒthe๎˜ƒcase๎˜ƒof๎˜ƒpredicting๎˜ƒa๎˜ƒcontinuous๎˜ƒresponse๎˜ƒvariable๎˜ƒfrom๎˜ƒdifferent๎˜ƒ
levels๎˜ƒof๎˜ƒanother๎˜ƒvariable.๎˜ƒ๎˜ƒWe๎˜ƒsay๎˜ƒthe๎˜ƒvariable,๎˜ƒY,๎˜ƒis๎˜ƒthe๎˜ƒresponse๎˜ƒvariable๎˜ƒdependent๎˜ƒon๎˜ƒan๎˜ƒ
explanatory๎˜ƒpredictor๎˜ƒvariable,๎˜ƒX.๎˜ƒ
There๎˜ƒare๎˜ƒmany๎˜ƒexamples๎˜ƒin๎˜ƒthe๎˜ƒlife๎˜ƒsciences๎˜ƒof๎˜ƒsuch๎˜ƒa๎˜ƒsituation๎˜ƒโ€“๎˜ƒheight๎˜ƒto๎˜ƒpredict๎˜ƒweight,๎˜ƒ
dose๎˜ƒof๎˜ƒan๎˜ƒalgaecide๎˜ƒto๎˜ƒpredict๎˜ƒalgae๎˜ƒgrowth,๎˜ƒskinfold๎˜ƒmeasurements๎˜ƒto๎˜ƒpredict๎˜ƒtotal๎˜ƒbody๎˜ƒfat,๎˜ƒ
etcโ€ฆ๎˜ƒ๎˜ƒOften๎˜ƒtimes,๎˜ƒseveral๎˜ƒpredictors๎˜ƒare๎˜ƒused๎˜ƒto๎˜ƒmake๎˜ƒa๎˜ƒprediction๎˜ƒof๎˜ƒone๎˜ƒvariable๎˜ƒ(ex.๎˜ƒheight,๎˜ƒ
weight,๎˜ƒage,๎˜ƒsmoking๎˜ƒstatus,๎˜ƒgender๎˜ƒcan๎˜ƒall๎˜ƒbe๎˜ƒused๎˜ƒto๎˜ƒpredict๎˜ƒblood๎˜ƒpressure).๎˜ƒ๎˜ƒ๎˜ƒ
We๎˜ƒfocus๎˜ƒon๎˜ƒthe๎˜ƒspecial๎˜ƒcase๎˜ƒof๎˜ƒusing๎˜ƒone๎˜ƒpredictor๎˜ƒvariable๎˜ƒfor๎˜ƒa๎˜ƒresponse,๎˜ƒwhere๎˜ƒthe๎˜ƒ
relationship๎˜ƒis๎˜ƒlinear.๎˜ƒ๎˜ƒ๎˜ƒ
Example๎˜ƒ12.3๎˜ƒ๎˜ƒIn๎˜ƒa๎˜ƒstudy๎˜ƒof๎˜ƒa๎˜ƒfree๎˜ƒliving๎˜ƒpopulation๎˜ƒof๎˜ƒthe๎˜ƒsnake๎˜ƒVipera๎˜ƒbertis,๎˜ƒresearchers๎˜ƒ
caught๎˜ƒand๎˜ƒmeasured๎˜ƒnine๎˜ƒadult๎˜ƒfemales.๎˜ƒ๎˜ƒThe๎˜ƒgoal๎˜ƒis๎˜ƒto๎˜ƒpredict๎˜ƒweight๎˜ƒ(Y)๎˜ƒfrom๎˜ƒlength๎˜ƒ(X).๎˜ƒ๎˜ƒ
The๎˜ƒdata๎˜ƒand๎˜ƒa๎˜ƒscatterplot๎˜ƒof๎˜ƒthe๎˜ƒdata๎˜ƒare๎˜ƒbelow.๎˜ƒ๎˜ƒ
Notice๎˜ƒthis๎˜ƒdata๎˜ƒcomes๎˜ƒin๎˜ƒpairs.๎˜ƒFor๎˜ƒexample๎˜ƒ(x1,y1)๎˜ƒ=๎˜ƒ(60,๎˜ƒ136)๎˜ƒ
๎˜ƒ
First,๎˜ƒwe๎˜ƒlook๎˜ƒat๎˜ƒa๎˜ƒscatterplot๎˜ƒof๎˜ƒthe๎˜ƒdata.๎˜ƒ๎˜ƒWeโ€™d๎˜ƒlike๎˜ƒto๎˜ƒfit๎˜ƒa๎˜ƒ(straight)๎˜ƒline๎˜ƒto๎˜ƒthe๎˜ƒdata.๎˜ƒ๎˜ƒWhy๎˜ƒ
linear?๎˜ƒ
๎˜ƒ
๎˜ƒ
Does๎˜ƒfitting๎˜ƒa๎˜ƒ(straight๎˜ƒline)๎˜ƒseem๎˜ƒreasonable?๎˜ƒ
๎˜ƒ
Snake๎˜ƒLength๎˜ƒ(cm)๎˜ƒWeight๎˜ƒ(g)
1๎˜ƒ60๎˜ƒ136๎˜ƒ
2๎˜ƒ69๎˜ƒ198๎˜ƒ
3๎˜ƒ66๎˜ƒ194๎˜ƒ
4๎˜ƒ64๎˜ƒ140๎˜ƒ
5๎˜ƒ54๎˜ƒ93๎˜ƒ
6๎˜ƒ67๎˜ƒ172๎˜ƒ
7๎˜ƒ59๎˜ƒ116๎˜ƒ
8๎˜ƒ65๎˜ƒ174๎˜ƒ
9๎˜ƒ63๎˜ƒ145๎˜ƒ
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12

Partial preview of the text

Download Lecture Notes on Simple Linear Regression | STAT 205 and more Study notes Statistics in PDF only on Docsity!

55.0 57.5 60.0 62.5 65.0 67.5 70.

200 180 160 140 120 100 Length (cm)

Weight (g)

Scatterplot of Weight vs Length Female Vipera bertis

Simple Linear Regression

We have been introduced to the notion that a categorical variable could depend on different levels of another variable when we discussed contingency tables.

Weโ€™ll extend this idea to the case of predicting a continuous response variable from different levels of another variable. We say the variable, Y, is the response variable dependent on an explanatory predictor variable, X.

There are many examples in the life sciences of such a situation โ€“ height to predict weight, dose of an algaecide to predict algae growth, skinfold measurements to predict total body fat, etcโ€ฆ Often times, several predictors are used to make a prediction of one variable (ex. height, weight, age, smoking status, gender can all be used to predict blood pressure).

We focus on the special case of using one predictor variable for a response, where the relationship is linear.

Example 12.3 In a study of a free living population of the snake Vipera bertis , researchers caught and measured nine adult females. The goal is to predict weight (Y) from length (X). The data and a scatterplot of the data are below. Notice this data comes in pairs. For example (x 1 ,y 1 ) = (60, 136)

First, we look at a scatterplot of the data. Weโ€™d like to fit a (straight) line to the data. Why linear?

Does fitting a (straight line) seem reasonable?

Snake Length (cm) Weight (g) 1 60 136 2 69 198 3 66 194 4 64 140 5 54 93 6 67 172 7 59 116 8 65 174 9 63 145

Simple Linear Model (Regression Equation)

The simple linear model relating Y and X is Y = bO + b 1 X

bO is the intercept, the point where the line crosses the Y axis b 1 is the slope, the change in Y over the change in X (rise over run)

Definition: A predicted value (or fitted value) is the predicted value of yi for a given x (^) i based on the regression equation, b (^) O + b 1 x (^) i Notation: yเทœ (^) i = bO + b 1 x (^) i

A residual is the departure from Y of a fitted value. Notation: residi = yi โ€ yเทœ (^) i

Which line do we fit? We will fit a line that goes through the data in the best way possible, based on the least squares criterion.

Definition: The residual sum of squares (a.k.a. SS(resid) or SSE) is

SSแˆบresidแˆป เตŒ SSE เตŒ เท แˆบyi โ€yเทœ (^) i

n

iเตŒ

The least squares criterion states that the optimal fit of a model to data occurs when the SS(resid) is as small as possible. Note that under our model

SSแˆบresidแˆป เตŒ SSE เตŒ เท แˆบyi โ€yเทœ (^) i

n

iเตŒ

แˆป 2 เตŒ เท แˆบyi โ€แˆบb (^) O เต…b 1 x (^) i

n

iเตŒ

Refer to the applet at http://standards.nctm.org/document/eexamples/chap7/7.4/

55.0 57.5 60.0 62.5 65.0 67.5 70.

200 180 160 140 120 100

Length (cm)

Weight (g)

Scatterplot of Weight vs Length with Fitted Regression Line

A Measure of Variability โ€“ s Y|X

Once we fit a line to our data and use it to make predictions, it is natural to ask the question of how far off our predictions are in general.

Definition: The residual standard deviation is

sY|X เตŒ เถจ

SSแˆบresidแˆป nโ€2 เตŒ เถจ

โˆ‘ niเตŒ1แˆบyi โ€yเทœ (^) i แˆป 2 nโ€

Caution: This is not to be confused with sY! Recall,

sY เตŒ เถจ

โˆ‘ niเตŒ1แˆบyi โ€yเดคแˆป 2 nโ€

Determine and interpret sY|X for the regression of female Vipera bertis weight on length.

The Linear Statistical Model

Definition: A conditional mean is the expected value of a variable conditional on another variable. Notation: ฮผY|X

Defiinition: A conditional standard deviation is the standard deviation of a variable conditional on another variable. Notation: ฯƒY|X

The linear regression model of Y on X assumes

Y = ฮผY|X + ฮต

where the conditional mean is linear with

ฮผY|X = ฮฒO + ฮฒ 1 X

and ฮผฮต = 0 and ฯƒ (^) ฮต = ฯƒY|X

We use ______ to estimate ฮฒO, ______ to estimate ฮฒ 1 , and __________ to estimate ฯƒY|X.

Then, we can estimate (or predict) ฮผY|X=x at any X so that

ฮผเทœ (^) Y|XเตŒx = bO + b 1 x

Assuming the linear model is appropriate here, find estimates of the mean and standard deviation of female Vipera bertis weight at a length of 65 cm.

Should we estimate female Vipera bertis weight at a length of 75 cm? Why or why not?

How to Check Assumptions

ฮตi independent

ฮตi normally^ distributed

ฮตi must have equal variance

ฮตi must have mean zero

Looking at Residuals vs. Predicted (or X) Plot

Check the assumptions (that can be checked) for the female Vipera bertis regression using the plots below.

Hypothesis Test for ฮฒ 1

Similar to the development of the confidence interval for ฮฒ 1 , we can use the t distribution to conduct a hypothesis test for ฮฒ 1 with

t (^) s เตŒ (^) SEแˆบbb^1 1 แˆป

Under H (^) O, ts ~ tdf=nโ€ 2

Weโ€™ll test HO: _________________________________________________________________

HA : _________________________________________________________________

Use the LinRegTTest option in your calculator to conduct a test of hypothesis at the ฮฑ = 0. significance level whether true mean female Vipera bertis weight tends to increase with increase in female Vipera bertis length.

55.0 57.5 60.0 62.5 65.0 67.5 70.

200 180 160 140 120 100

Length (cm)

Weight (g)

Scatterplot of W with Fitted Regression Line eight vs Length

Coefficient of Determination (r 2 )

Recall SS(resid) is a measure of the unexplained variablility in Y (the variation in Y not explained by X through the regression model) and is given by

SSแˆบresidแˆป เตŒ SSE เตŒ เท แˆบyi โ€yเทœ (^) i

n

iเตŒ

แˆป^2

Definition: SS(total) measures the total variability in Y and is given by

SSแˆบtotalแˆป เตŒ SST เตŒ เท แˆบyi โ€yเดค

n

iเตŒ

แˆป^2

Definition: SS(reg) measures the variability in Y that is explained by X through the regression model and is given by

SSแˆบregแˆป เตŒ SSR เตŒ เท แˆบyเทœ (^) i โ€yเดค

n

iเตŒ

แˆป^2

Then, SS(total) = SS(reg) + SS(resid) or the total variability in Y is explained by the regression model plus the unexplained residual variation.

Definition: The coefficient of determination is the ratio between the SS(reg) and SS(total) and is given by

coefficient of determinationเตŒ r 2 เตŒ SSแˆบregแˆป SSแˆบtotalแˆป

แˆพ โˆ‘^ niเตŒ1แˆบx (^) i โ€xเดคแˆปแˆบyi โ€yเดคแˆปแˆฟ 2 โˆ‘ niเตŒ1แˆบx (^) i โ€xเดคแˆป 2 โˆ‘ niเตŒ1แˆบyi โ€yเดคแˆป 2

and is interpreted as the proportion (or percentage) of variability in Y that is explained by the linear regression of Y on X.

Find and interpret r^2 for the regression of female Vipera bertis weight on length.

Minitab Output DoStat Output Regression Analysis: Population versus X

The regression equation is Population = 35.5 + 0.151 X

Predictor Coef SE Coef T P Constant 35.489 4.974 7.14 0. X 0.15073 0.02422 6.22 0.

S = 2.86360 R-Sq = 88.6% R-Sq(adj) = 86.3%

Analysis of Variance Source DF SS MS F P Regression 1 317.58 317.58 38.73 0. Residual Error 5 41.00 8. Total 6 358.

Correlation

The linear regression model assumes the Xโ€™s are measured with negligible error.

Think about the snake data hereโ€ฆthe researcher measured length to predict weight! Why not the other way around? I mean, if we go out to collect snake measurements, I am not volunteering to get the length โ€“ Iโ€™m volunteering to hook the snake and throw it in a bag to weigh it. But, if we tried to use the weight to predict length, the variability in weight due to eating, pregnancy, etc. could lead to bad predictions of length. For instance, a snake in our data set that just ate a mouse, would have a shorter length that what would be predicted for a snake that actually weighed little snake + food = big snake pounds.

In other words, ฮผY|X is the mean of Y given X. We use this type of model to make predictions of Y, based on our model for a given value of X.

For the situation where weโ€™d like to make statements about the joint relationship of X and Y, weโ€™ll need for X and Y to both be random. When weโ€™re interested in examining the joint relationship of two random variables, we are interested in their joint distribution (the joint distribution of two random variables is called a bivariate distribution).

Definition The bivariate random sampling model views the pairs (X (^) i, Y (^) i) as joint random variables, with population means, ฮผX , ฮผY, population standard deviations, ฯƒX , ฯƒY, and a correlation parameter, ฯ.

In this model, ฯ measures the level of dependence between two random variables, X and Y.

  • โ€ 1 โ‰ค ฯ โ‰ค 1
  • ฯ โ†’ ยฑ 1 โ‡” X & Y become more correlated
  • ฯ โ†’ 0 โ‡” X & Y become uncorrelated

Weโ€™ll measure the sample correlation coefficient, called r.

r เตŒ

โˆ‘ niเตŒ1แˆบx (^) i โ€xเดคแˆปแˆบyi โ€yเดคแˆป เถฅโˆ‘^ niเตŒ1แˆบx^ i โ€xเดคแˆป^2 โˆ‘^ niเตŒ1แˆบyi โ€yเดคแˆป^2

Notice what is hiding inside of r.

Plots Depicting the Sensitivity of r to Outliers

Confidence Interval for ฯ

We can build a (1 โ€ ฮฑ) confidence interval on ฯ if we extend the bivariate model to include bivariate normality.

Weโ€™ll assume X ~ N(ฮผX ,ฯƒX^2 ), Y ~ N(ฮผY,ฯƒY^2 ), with Corr (X, Y) = ฯ. The following figures depict bivariate standard normal distributions with different correlations.

ฯ=0.0 ฯ=0.

Unfortunately, there is no easy way to build good intervals directly on ฯ. Instead we transform between different scales for ฯ.

Definition

The Fisher Z transform is defined as ZแˆบrแˆปเตŒ 12 ln แ‰‚ 1เต…r1โ€r แ‰ƒ

And when under the bivariate normal, Z(r) ~ N(0, (^) เฏกเฌฟเฌทเฌต )

The inverse function is r เตŒ e

2Z (^) โ€ e2Z^ เต…

Compute a confidence interval for Z(ฯ) and then invert, using the inverse formula, to get a (1โ€ฮฑ) confidence interval on ฯ.

CI on Z(ฯ) Zแˆบrแˆป เต‡ Z ฮฑ เต— 2 เถง (^) nโ€3^1

CI on ฯ เฏ˜^

เฐฎแˆพเณ‹แˆบเณแˆปเฐทเณ‹เด€/เฐฎ เถง^ เณ™เฐทเฐฏเฐญแˆฟเฌฟ (^) เฌต

เฏ˜ เฐฎแˆพเณ‹แˆบเณแˆปเฐทเณ‹เด€/เฐฎ^ เถง^ เณ™เฐทเฐฏเฐญแˆฟ^ เฌพเฌต

เต ฿ฉ เต เฏ˜^

เฐฎแˆพเณ‹แˆบเณแˆปเฐถเณ‹เด€/เฐฎ เถง^ เณ™เฐทเฐฏเฐญ แˆฟเฌฟ (^) เฌต

เฏ˜ เฐฎแˆพเณ‹แˆบเณแˆปเฐถเณ‹เด€/เฐฎ^ เถง^ เณ™เฐทเฐฏเฐญ แˆฟ^ เฌพเฌต

Compute a 95% interval for ฯ, the true correlation of platelet calcium and blood pressure.