Presentation is loading. Please wait.

Presentation is loading. Please wait.

Correlation and regression

Similar presentations


Presentation on theme: "Correlation and regression"— Presentation transcript:

1 Correlation and regression
Introduction to Statistical Methods for Measuring “Omics” and Field Data Correlation and regression

2 Overview Correlation Simple Linear Regression

3 Correlation

4 General Overview of Correlational Analysis
The purpose is to measure the strength of a linear relationship between 2 variables. A correlation coefficient does not ensure “causation” (i.e. a change in X causes a change in Y) X is typically the input, measured, or independent variable. Y is typically the output, predicted, or dependent variable. If X increases and there is a predictable shift in the values of Y, a correlation exists.

5 General Properties of Correlation Coefficients
Values can range between +1 and -1 The value of the correlation coefficient represents the scatter of points on a scatterplot You should be able to look at a scatterplot and estimate what the correlation would be You should be able to look at a correlation coefficient and visualize the scatterplot

6 Interpretation Depends on what the purpose of the study is… but here is a “general guideline”... Value = magnitude of the relationship Sign = direction of the relationship

7 Correlation graph Strong relationships Weak relationships Y Y
Positive correlation X X Y Y Negtaive correlation X X

8 The Pearson Correlation Coefficient

9 Correlation Coefficient
The correlation coefficient is a measure of the strength and the direction of a linear relationship between two variables. The symbol r represents the sample correlation coefficient. The formula for r is The range of the correlation coefficient is 1 to 1. If x and y have a strong positive linear correlation, r is close to 1. If x and y have a strong negative linear correlation, r is close to 1. If there is no linear correlation or a weak linear correlation, r is close to 0.

10 Calculating a Correlation Coefficient
In Words In Symbols Find the sum of the x-values. Find the sum of the y-values. Multiply each x-value by its corresponding y-value and find the sum. Square each x-value and find the sum. Square each y-value and find the sum. Use these five sums to calculate the correlation coefficient. Continued.

11 Correlation Coefficient
Example: Calculate the correlation coefficient r for the following data. x y 1 – 3 2 – 1 3 4 5

12 Correlation Coefficient
Example: Calculate the correlation coefficient r for the following data. x y xy x2 y2 1 – 3 9 2 – 1 – 2 4 3 16 5 10 25

13 Correlation Coefficient
Example: Calculate the correlation coefficient r for the following data. x y xy x2 y2 1 – 3 9 2 – 1 – 2 4 3 16 5 10 25 There is a strong positive linear correlation between x and y.

14 Significance Test for Correlation
Hypotheses H0: ρ = 0 (no correlation) HA: ρ ≠ 0 (correlation exists) Test statistic (with n – 2 degrees of freedom)

15 Linear Regression

16 Linear regression Deals with relationship between two variables X and Y. Y is the variables whose “behavior” we wish to study ( e.g., fuel efficiency in a car). X is the variable we believe would help explain the behavior of Y (e.g., the size of the car).

17 Regression model The simple linear regression model:

18 Components of the models

19 Regression Line A regression line, also called a line of best fit, is the line for which the sum of the squares of the residuals is a minimum. The Equation of a Regression Line The equation of a regression line for an independent variable x and a dependent variable y is ŷ = mx + b where ŷ is the predicted y-value for a given x-value. The slope m and y-intercept b are given by

20 Regression Line x y 1 – 3 2 – 1 3 4 5 Example:
Find the equation of the regression line. x y 1 – 3 2 – 1 3 4 5 Continued.

21 Regression Line x y xy x2 y2 1 – 3 9 2 – 1 – 2 4 3 16 5 10 25 Example:
Find the equation of the regression line. x y xy x2 y2 1 – 3 9 2 – 1 – 2 4 3 16 5 10 25 Continued.

22 Regression Line x y xy x2 y2 1 – 3 9 2 – 1 – 2 4 3 16 5 10 25 Example:
Find the equation of the regression line. x y xy x2 y2 1 – 3 9 2 – 1 – 2 4 3 16 5 10 25 Continued.

23 Regression Line x y xy x2 y2 1 – 3 9 2 – 1 – 2 4 3 16 5 10 25 Example:
Find the equation of the regression line. x y xy x2 y2 1 – 3 9 2 – 1 – 2 4 3 16 5 10 25 Continued.

24 Regression Line Hours, x Test score, y xy x2 y2 1 2 3 5 6 7 10 96 85
Example: The following data represents the number of hours 12 different students watched television during the weekend and the scores of each student who took a test the following Monday. a.) Find the equation of the regression line. b.) Use the equation to find the expected test score for a student who watches 9 hours of TV. Hours, x 1 2 3 5 6 7 10 Test score, y 96 85 82 74 95 68 76 84 58 65 75 50 xy 164 222 285 340 380 420 348 455 525 500 x2 4 9 25 36 49 100 y2 9216 7225 6724 5476 9025 4624 5776 7056 3364 4225 5625 2500

25 Regression Line Continued. Example continued: 100 x y
Hours watching TV Test score 80 60 40 20 2 4 6 8 10 ŷ = –4.07x Continued.

26 Regression Line Example continued:
Using the equation ŷ = -4.07x , we can predict the test score for a student who watches 9 hours of TV. ŷ = –4.07x = –4.07(9) = 57.34 A student who watches 9 hours of TV over the weekend can expect to receive about a on Monday’s test.

27 Variation About a Regression Line
The total variation about a regression line is the sum of the squares of the differences between the y-value of each ordered pair and the mean of y. The explained variation is the sum of the squares of the differences between each predicted y-value and the mean of y. The unexplained variation is the sum of the squares of the differences between the y-value of each ordered pair and each corresponding predicted y-value.

28 Coefficient of Determination
The coefficient of determination R2 is the ratio of the explained variation to the total variation. That is, Example: The correlation coefficient for the data that represents the number of hours students watched television and the test scores of each student is r   Find the coefficient of determination. About 69.1% of the variation in the test scores can be explained by the variation in the hours of TV watched. About 30.9% of the variation is unexplained.

29 Regression hypothesis

30

31

32

33 RStudio Function cor.test is used to calculate correlation r, and t statistics. Function lm is used to calculate regression Example: Hours, x 1 2 3 5 6 7 10 Test score, y 96 85 82 74 95 68 76 84 58 65 75 50 X<-c(0,1,2,3,3,5,5,5,6,7,7,10) Y<-c(96,85,82,74,95,68,76,84,58,65,75,50) cor.test(X,Y) G<-lm(X~Y) Summary(G)

34 RStudio Count<-c(9,25,15,2,14,25,24,47) > Count
[1] Speed<-c(2,3,5,9,14,24,29,34) G<-lm(Count~Speed) > summary(G) Call: lm(formula = Count ~ Speed) Residuals: Min Q Median Q Max Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) Speed * --- Signif. codes: 0 ‘***’ ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 Residual standard error: on 6 degrees of freedom Multiple R-squared: , Adjusted R-squared: F-statistic: on 1 and 6 DF, p-value:


Download ppt "Correlation and regression"

Similar presentations


Ads by Google