Download - Simple Linear Regression and Multiple Regressioncourse1.winona.edu/bdeppa/STAT 110/Notes/Handout 10... · Web view12- Correlation Correlation measures to what degree two numeric variables,

Transcript
Page 1: Simple Linear Regression and Multiple Regressioncourse1.winona.edu/bdeppa/STAT 110/Notes/Handout 10... · Web view12- Correlation Correlation measures to what degree two numeric variables,

12- Correlation

Correlation measures to what degree two numeric variables, X and Y generically, are related to another in a linear fashion.  In other words the correlation measures the strength and direction of the linear relationship between two numeric/continuous random variables.

If the correlation is 1 or -1, then the variables are perfectly linearly related.  A scale for correlations is given below.

Scatterplots and Correlation:

Sample Correlation (r) (Pearson’s)

r=∑i=1

n

(x i− x )( y i− y )

√∑i=1

n

(xi− x )2√∑i=1

n

( y i− y )2

FYI only: NO ONE COMPUTES THIS BY HAND!

125

Page 2: Simple Linear Regression and Multiple Regressioncourse1.winona.edu/bdeppa/STAT 110/Notes/Handout 10... · Web view12- Correlation Correlation measures to what degree two numeric variables,

Common misconceptions and things to watchout for:

126

Page 3: Simple Linear Regression and Multiple Regressioncourse1.winona.edu/bdeppa/STAT 110/Notes/Handout 10... · Web view12- Correlation Correlation measures to what degree two numeric variables,

Example: Berkley Guidance Study (BGSgirls.JMP)The data for this example are excerpted from the Berkeley Guidance Study, a longitudinal monitoring the growth of boys and girls in Berkelely, CA, born between January 1928 and June 1929. 

The variables in the data for girls are: WT2 = weight at age 2 (kg) HT2 = height at age 2 (cm) WT9 = weight at age 9 HT9 = height at age 9 LEG9 = leg circumference at age 9 (cm) STR9 = a composite measure of strength at age 9 (high values = stronger) WT18 = weight at age 18 HT18 = height at age 18 LEG18 = leg circumference at age 18 STR18 = strength at age 18 SOMA = somatotype, a seven-point scale, as a measure of fatness (1 = slender, 7

= fat), determined using a photograph taken at age 18.

Obtaining Correlations in JMP :This gives us some idea about whether or not the predictor(s) X and response Y are linearly related.  The correlations are obtained under Analyze > Multivariate.

Next, select the variables of interest and place them all in the Y box.

Results from Multivariate Analysis

Put any numeric/continuous variables you are interested in finding the correlations between in the Y,Columns box.

127

Page 4: Simple Linear Regression and Multiple Regressioncourse1.winona.edu/bdeppa/STAT 110/Notes/Handout 10... · Web view12- Correlation Correlation measures to what degree two numeric variables,

Reading correlation and scatterplot matrices

128

Page 5: Simple Linear Regression and Multiple Regressioncourse1.winona.edu/bdeppa/STAT 110/Notes/Handout 10... · Web view12- Correlation Correlation measures to what degree two numeric variables,

To test whether a correlation is significantly different from 0, we select Multivariate > Pairwise Correlations.

= population correlation between the two variables, the correlation between the two variables if the entire population were sampled.

H o : ρ=0H a : ρ ≠0

 Here we see that most correlations are significantly different from 0. When considering the somatotype (Soma) we see that two variables, strength at age 9 and height at age 2, do not have statistically significant correlations with body size at age 18.

Common way to report correlations in papers is to present the correlations in a table format with the p-values from the significance test in parentheses.

Wt2 Ht2 Wt9 Ht9 Leg9 Str9 SomaWt2 1.0000 0.6445

(<.0001)

0.6925(<.0001)

0.6071(< .0001)

0.6164(<.0001)

0.4516(<.0001)

0.2715 (.0230)

Ht2 1.0000 0.5229(<.0001)

0.7384(<.0001)

0.4688(<.0001)

0.3617(.0021)

0.0398(.7436)

Wt9 1.0000 0.7276(<.0001)

0.9044(<.0001)

0.45300406(<.0001)

0.6181(<.0001)

Ht9 1.0000 0.5981(<.0001)

0.6034(<.0001)

0.2740(.0217)

Leg9 1.0000 0.4129(.0004)

0.5794(<.0001)

Str9 1.0000 0.0887

129

Page 6: Simple Linear Regression and Multiple Regressioncourse1.winona.edu/bdeppa/STAT 110/Notes/Handout 10... · Web view12- Correlation Correlation measures to what degree two numeric variables,

(.4654)Soma

1.0000

Example 2: GPA and Hours Spent Studying Per Week

What can we say about the correlation between hours spent studying per week, GPA, and credits currently enrolled in for WSU students?

Discussion:

130

Page 7: Simple Linear Regression and Multiple Regressioncourse1.winona.edu/bdeppa/STAT 110/Notes/Handout 10... · Web view12- Correlation Correlation measures to what degree two numeric variables,

13 - Simple Linear Regression and Multiple Regression

Regression is used to study relationships between variables. Linear regression is used for a special class of relationships, namely, those that can be described by straight lines, or by generalizations of straight lines to many dimensions.

In regression we seek to understand how the value of a response of variable (Y) is related to a set of explanatory variables or predictors (X’s). This is done by specifying a model that relates the mean or average value of the response to the predictors in mathematical form. In simple linear regression we have single predictor variable (X) and we use a line (of the form y = mx + b) to relate the response to the predictor.

Regression Model Notation:

E(Y|X) =

In regression we first specify a functional form or model for E(Y|X). We then fit that model with using available data and then assess the adequacy of the model. We may then decide to remove some of the explanatory variables that do not appear important, add others to improve the model, change the function form of the model, etc. Regression is an iterative process where we fit a preliminary model and then modify our model based on the results.

Regression Examples:

E(Cholesterol Level |Weight, Height, Age, Daily Caloric Intake) =

β0+β1 Weight+β2 Length+β3 Age+β4 Calories

E(Blood Pressure| ) =

E(Survival Time of Cancer Patient | ) =

131

Page 8: Simple Linear Regression and Multiple Regressioncourse1.winona.edu/bdeppa/STAT 110/Notes/Handout 10... · Web view12- Correlation Correlation measures to what degree two numeric variables,

Example 1: Diastolic and Systolic Blood Pressure in Hypertensive Patients

 Data File:  Hypertension.JMP 

Background: 

These data were collected as part of a large study looking at patients with hypertension.

Variables:  Diastolic BP: diastolic blood pressure (mmHg) Systolic BP: systolic blood pressure (mmHg)

Goal: Investigate the relationship between diastolic blood pressure (X) and systolic blood pressure (Y).

Note: the roles of X and Y could certainly be reversed for this study. In others, there is usually a clear response of interest.

 Assumptions for a Simple Linear Regression Model

1. The mean of the response variable (Y) can be modeled using X in the following

form: E(Y |X )=βo+ β1∗X Recall: E(Y|X) is the notation we use to denote the mean value of Y given X. Here we are using a line to summarize the mean value of Y as a function of X.

2. The variability in the response variable (Y) must be the same for each X, i.e. Var (Y |X )=σ2 or SD(Y|X )=σ . In other words, the variance of Y must be constant across the entire range of X.

3. The response measurements (Y’s) should be independent of each other. If a simple random sample is taken from the population this typically the case. One situation where this assumption is violated is when data if collected over time.

4. The response measurements (Y), for a given value of X, should follow a normal distribution.

You should also take the time to identify outliers and influential points. Outliers and influential points can be very problematic in a regression model. We will discuss how to check the assumptions outlined above after fitting our initial model.

Outlier Influential Point

132

Page 9: Simple Linear Regression and Multiple Regressioncourse1.winona.edu/bdeppa/STAT 110/Notes/Handout 10... · Web view12- Correlation Correlation measures to what degree two numeric variables,

Start with a Plot of your DataSelect Analyze > Fit Y by X and place Systolic BP (mmHg) in the Y box and Diastolic BP (mmHg) in the X box.

The resulting scatterplot is shown below.

Fitting the regression model relating Systolic BP (Y) to Diastolic BP (X)What is the population model?  We want to model the mean value of Y using X, so the model is given by:

E(Y |X )=βo+ β1∗X

or being specific for this situation, we have

E( Systolic|Diastolic)=βo+β1∗Diastolic

Again: E(Y|X) is the notation we use to denote the mean value of Y given X.

133

Page 10: Simple Linear Regression and Multiple Regressioncourse1.winona.edu/bdeppa/STAT 110/Notes/Handout 10... · Web view12- Correlation Correlation measures to what degree two numeric variables,

Taking a closer look at its pieces:

For this data set, Y = Systolic BP and X = Diastolic BP.

How is the line that best fits our data determined? Answer: Method of Least Squares

To fit the model 

E( Systolic|Diastolic)=βo+β1∗Diastolic

we first select Analyze > Fit Y by X and place Systolic BP in the Y box and Diastolic BP in the X box as shown below. This will give us scatter plot of Y vs. X, from which we can fit the simple linear regression model.

E(Y|X) =X

slope

134

Page 11: Simple Linear Regression and Multiple Regressioncourse1.winona.edu/bdeppa/STAT 110/Notes/Handout 10... · Web view12- Correlation Correlation measures to what degree two numeric variables,

The resulting scatter plot is shown below. With regression line added.

To perform the regression of Systolic BP on Diastolic BP in JMP, select Fit Line from the Bivariate Fit... pull-down menu.

The resulting output is shown below.

135

Page 12: Simple Linear Regression and Multiple Regressioncourse1.winona.edu/bdeppa/STAT 110/Notes/Handout 10... · Web view12- Correlation Correlation measures to what degree two numeric variables,

We begin by looking at whether or not this regression stuff is even helpful:

This says that Diastolic BP (X) explains a significantamount of variation in the response Systolic BP (Y).

Next we can assess the importance of the X variable, Diastolic BP in this case:

Conclusions from both tests:

Determining how well the model is doing in terms of explaining the response is done using the R-Square and Root Mean Square Error:

Ho : β1=0Ha : β1≠0

Ho : Regression is NOT usefulHa : Regression is useful

The proportion or percentage of variation explained by the regression of Length (Y) on Age (X) is given by the R-Square = .547 or 54.7%

The amount of unexplained variability in Systolic BP (Y) taking Diastolic BP (X) into consideration is given by the RMSE (root mean square error). This is an estimate of the SD(Systolic BP|Diastolic BP).

This is equivalent to saying the X is not useful for explaining Y. Thus the results of these two tests are identical in every way!

136

Page 13: Simple Linear Regression and Multiple Regressioncourse1.winona.edu/bdeppa/STAT 110/Notes/Handout 10... · Web view12- Correlation Correlation measures to what degree two numeric variables,

Definitions and Terms from Previous Page:

137

Page 14: Simple Linear Regression and Multiple Regressioncourse1.winona.edu/bdeppa/STAT 110/Notes/Handout 10... · Web view12- Correlation Correlation measures to what degree two numeric variables,

Describing the Relationship:E( Systolic BP|D iastolic BP)=26 . 476+1 . 242∗Diastolic BP

Interpret each of the parameter estimates: 

CI’s for the Parameter Estimates(estimate )±( t−table )⋅SE(estimate ) where t-table comes from t-distribution df = n – 2.

95% CI for the Slope (β1 )

What do we estimate for the mean systolic blood pressure of hypertension patients that have a diastolic blood pressure of 100 mmHg?

If picked a single hypertensive patient with a diastolic blood pressure of 100 mmHg at random, what do we predict their systolic blood pressure will be?

138

Page 15: Simple Linear Regression and Multiple Regressioncourse1.winona.edu/bdeppa/STAT 110/Notes/Handout 10... · Web view12- Correlation Correlation measures to what degree two numeric variables,

Checking the Assumptions:To check the adequacy of the model in terms of the basic assumptions involves looking a plots of the residuals from the fit. One plot that is particular helpful for checking a number of the model assumptions is a plot of the residuals vs. the fitted values. When we are performing simple linear regression we can alternatively plot the residuals vs. X, which is what JMP gives by default.  Ideal Residual Plot:

 Violations to Assumption #1:

The trend need not be linear (BAD) The trend need not be linear (BAD)

Violations to Assumption #2:

Megaphone opening to right (BAD) Megaphone opening to the left (BAD)

139

Page 16: Simple Linear Regression and Multiple Regressioncourse1.winona.edu/bdeppa/STAT 110/Notes/Handout 10... · Web view12- Correlation Correlation measures to what degree two numeric variables,

Violations to Assumption #3:

One point closely following another -- positive autocorrelation,  (BAD)

Extreme bouncing back and forth -- negative autocorrelation (BAD)

Violations to Assumption #4:

To check this assumption, simple save the residuals out and make a histogram of the residuals and/or look at a normal quantile plot.  Recall, you can easily make a histogram of a variable under Analyze > Distribution. We should generally assess normality using a normal quantile plot as well.

Checking for outliers:

Determine the value of 2*RMSE.  Any observations outside these bands are potential outliers and should be investigated further to determine whether or not they adversely affect the model.

140

Page 17: Simple Linear Regression and Multiple Regressioncourse1.winona.edu/bdeppa/STAT 110/Notes/Handout 10... · Web view12- Correlation Correlation measures to what degree two numeric variables,

Checking for outliers in this example we find:

To obtain the residual plot in JMP select Linear Fit > Plot Residuals

THE ASSUMPTION CHECKLIST:Model Appropriate:

  Constant Variance:

 

Independence:

 

Normality Assumption (see histogram above):

Identify Outliers:

 

Mild outliers

Mild outliers

141