VRN 3 5 16

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 129

Regression

Introduction to R-Software and R-Studio


Simple Linear Regression

Linear Regression and ANOVA by Using R


Software

V.Ravindranath

Audit Course for Reseach Scholors 2016


J N T University Kakinada
KAKINADA, Andhra Pradesh
nath_vr@yahoo.com

VRNath, JNTU KAKINADA RM-STATS-2016


Regression
Introduction to R-Software and R-Studio
Simple Linear Regression

Outline

1 Regression
Introduction
2 Introduction to R-Software and R-Studio
Windows in R Studio
Commands in R
Plotting by using R
House Prices Problem without Explanatory Variables
3 Simple Linear Regression
Least Squares Method
Correlation
Testing of the Correlation Coefficient
Linear Regression and ANOVA

VRNath, JNTU KAKINADA RM-STATS-2016


Regression
Introduction to R-Software and R-Studio Introduction
Simple Linear Regression

Outline

1 Regression
Introduction
2 Introduction to R-Software and R-Studio
Windows in R Studio
Commands in R
Plotting by using R
House Prices Problem without Explanatory Variables
3 Simple Linear Regression
Least Squares Method
Correlation
Testing of the Correlation Coefficient
Linear Regression and ANOVA

VRNath, JNTU KAKINADA RM-STATS-2016


Regression
Introduction to R-Software and R-Studio Introduction
Simple Linear Regression

Mathematical models of Regression


Given (Yi , xi ), i = 1, 2, . . . , N
Linear Regression
1 Simple Linear Regression Y = β0 + β1 x
2 Multiple Linear Regression Y = β0 + β1 x1 + β1 x2
3 General Linear Model Y = β0 + β1 x1 + · · · + β1 xk

Non Linear Regression


1 Quadratic Regression Y = β0 + β1 x + β1 x 2 .
2 Polynomial Regression Y = β0 + β1 x + · · · + β1 x k
3 Exponential Regression Y = β0 eβ1 x
4 Power Equation Y = β0 x1β

VRNath, JNTU KAKINADA RM-STATS-2016


Regression
Introduction to R-Software and R-Studio Introduction
Simple Linear Regression

Mathematical models of Regression


Given (Yi , xi ), i = 1, 2, . . . , N
Linear Regression
1 Simple Linear Regression Y = β0 + β1 x
2 Multiple Linear Regression Y = β0 + β1 x1 + β1 x2
3 General Linear Model Y = β0 + β1 x1 + · · · + β1 xk

Non Linear Regression


1 Quadratic Regression Y = β0 + β1 x + β1 x 2 .
2 Polynomial Regression Y = β0 + β1 x + · · · + β1 x k
3 Exponential Regression Y = β0 eβ1 x
4 Power Equation Y = β0 x1β

VRNath, JNTU KAKINADA RM-STATS-2016


Regression
Introduction to R-Software and R-Studio Introduction
Simple Linear Regression

Mathematical models of Regression


Given (Yi , xi ), i = 1, 2, . . . , N
Linear Regression
1 Simple Linear Regression Y = β0 + β1 x
2 Multiple Linear Regression Y = β0 + β1 x1 + β1 x2
3 General Linear Model Y = β0 + β1 x1 + · · · + β1 xk

Non Linear Regression


1 Quadratic Regression Y = β0 + β1 x + β1 x 2 .
2 Polynomial Regression Y = β0 + β1 x + · · · + β1 x k
3 Exponential Regression Y = β0 eβ1 x
4 Power Equation Y = β0 x1β

VRNath, JNTU KAKINADA RM-STATS-2016


Regression
Introduction to R-Software and R-Studio Introduction
Simple Linear Regression

Mathematical models of Regression


Given (Yi , xi ), i = 1, 2, . . . , N
Linear Regression
1 Simple Linear Regression Y = β0 + β1 x
2 Multiple Linear Regression Y = β0 + β1 x1 + β1 x2
3 General Linear Model Y = β0 + β1 x1 + · · · + β1 xk

Non Linear Regression


1 Quadratic Regression Y = β0 + β1 x + β1 x 2 .
2 Polynomial Regression Y = β0 + β1 x + · · · + β1 x k
3 Exponential Regression Y = β0 eβ1 x
4 Power Equation Y = β0 x1β

VRNath, JNTU KAKINADA RM-STATS-2016


Regression
Introduction to R-Software and R-Studio Introduction
Simple Linear Regression

Mathematical models of Regression


Given (Yi , xi ), i = 1, 2, . . . , N
Linear Regression
1 Simple Linear Regression Y = β0 + β1 x
2 Multiple Linear Regression Y = β0 + β1 x1 + β1 x2
3 General Linear Model Y = β0 + β1 x1 + · · · + β1 xk

Non Linear Regression


1 Quadratic Regression Y = β0 + β1 x + β1 x 2 .
2 Polynomial Regression Y = β0 + β1 x + · · · + β1 x k
3 Exponential Regression Y = β0 eβ1 x
4 Power Equation Y = β0 x1β

VRNath, JNTU KAKINADA RM-STATS-2016


Regression
Introduction to R-Software and R-Studio Introduction
Simple Linear Regression

Mathematical models of Regression


Given (Yi , xi ), i = 1, 2, . . . , N
Linear Regression
1 Simple Linear Regression Y = β0 + β1 x
2 Multiple Linear Regression Y = β0 + β1 x1 + β1 x2
3 General Linear Model Y = β0 + β1 x1 + · · · + β1 xk

Non Linear Regression


1 Quadratic Regression Y = β0 + β1 x + β1 x 2 .
2 Polynomial Regression Y = β0 + β1 x + · · · + β1 x k
3 Exponential Regression Y = β0 eβ1 x
4 Power Equation Y = β0 x1β

VRNath, JNTU KAKINADA RM-STATS-2016


Regression
Introduction to R-Software and R-Studio Introduction
Simple Linear Regression

Mathematical models of Regression


Given (Yi , xi ), i = 1, 2, . . . , N
Linear Regression
1 Simple Linear Regression Y = β0 + β1 x
2 Multiple Linear Regression Y = β0 + β1 x1 + β1 x2
3 General Linear Model Y = β0 + β1 x1 + · · · + β1 xk

Non Linear Regression


1 Quadratic Regression Y = β0 + β1 x + β1 x 2 .
2 Polynomial Regression Y = β0 + β1 x + · · · + β1 x k
3 Exponential Regression Y = β0 eβ1 x
4 Power Equation Y = β0 x1β

VRNath, JNTU KAKINADA RM-STATS-2016


Regression
Introduction to R-Software and R-Studio Introduction
Simple Linear Regression

Mathematical models of Regression


Given (Yi , xi ), i = 1, 2, . . . , N
Linear Regression
1 Simple Linear Regression Y = β0 + β1 x
2 Multiple Linear Regression Y = β0 + β1 x1 + β1 x2
3 General Linear Model Y = β0 + β1 x1 + · · · + β1 xk

Non Linear Regression


1 Quadratic Regression Y = β0 + β1 x + β1 x 2 .
2 Polynomial Regression Y = β0 + β1 x + · · · + β1 x k
3 Exponential Regression Y = β0 eβ1 x
4 Power Equation Y = β0 x1β

VRNath, JNTU KAKINADA RM-STATS-2016


Regression
Introduction to R-Software and R-Studio Introduction
Simple Linear Regression

Mathematical models of Regression


Given (Yi , xi ), i = 1, 2, . . . , N
Linear Regression
1 Simple Linear Regression Y = β0 + β1 x
2 Multiple Linear Regression Y = β0 + β1 x1 + β1 x2
3 General Linear Model Y = β0 + β1 x1 + · · · + β1 xk

Non Linear Regression


1 Quadratic Regression Y = β0 + β1 x + β1 x 2 .
2 Polynomial Regression Y = β0 + β1 x + · · · + β1 x k
3 Exponential Regression Y = β0 eβ1 x
4 Power Equation Y = β0 x1β

VRNath, JNTU KAKINADA RM-STATS-2016


Regression
Introduction to R-Software and R-Studio Introduction
Simple Linear Regression

Mathematical models of Regression


Given (Yi , xi ), i = 1, 2, . . . , N
Linear Regression
1 Simple Linear Regression Y = β0 + β1 x
2 Multiple Linear Regression Y = β0 + β1 x1 + β1 x2
3 General Linear Model Y = β0 + β1 x1 + · · · + β1 xk

Non Linear Regression


1 Quadratic Regression Y = β0 + β1 x + β1 x 2 .
2 Polynomial Regression Y = β0 + β1 x + · · · + β1 x k
3 Exponential Regression Y = β0 eβ1 x
4 Power Equation Y = β0 x1β

VRNath, JNTU KAKINADA RM-STATS-2016


Regression
Introduction to R-Software and R-Studio Introduction
Simple Linear Regression

Mathematical models of Regression


Given (Yi , xi ), i = 1, 2, . . . , N
Linear Regression
1 Simple Linear Regression Y = β0 + β1 x
2 Multiple Linear Regression Y = β0 + β1 x1 + β1 x2
3 General Linear Model Y = β0 + β1 x1 + · · · + β1 xk

Non Linear Regression


1 Quadratic Regression Y = β0 + β1 x + β1 x 2 .
2 Polynomial Regression Y = β0 + β1 x + · · · + β1 x k
3 Exponential Regression Y = β0 eβ1 x
4 Power Equation Y = β0 x1β

VRNath, JNTU KAKINADA RM-STATS-2016


Regression
Introduction to R-Software and R-Studio Introduction
Simple Linear Regression

Mathematical models of Regression


Given (Yi , xi ), i = 1, 2, . . . , N
Linear Regression
1 Simple Linear Regression Y = β0 + β1 x
2 Multiple Linear Regression Y = β0 + β1 x1 + β1 x2
3 General Linear Model Y = β0 + β1 x1 + · · · + β1 xk

Non Linear Regression


1 Quadratic Regression Y = β0 + β1 x + β1 x 2 .
2 Polynomial Regression Y = β0 + β1 x + · · · + β1 x k
3 Exponential Regression Y = β0 eβ1 x
4 Power Equation Y = β0 x1β

VRNath, JNTU KAKINADA RM-STATS-2016


Regression
Introduction to R-Software and R-Studio Introduction
Simple Linear Regression

Mathematical models of Regression


Given (Yi , xi ), i = 1, 2, . . . , N
Linear Regression
1 Simple Linear Regression Y = β0 + β1 x
2 Multiple Linear Regression Y = β0 + β1 x1 + β1 x2
3 General Linear Model Y = β0 + β1 x1 + · · · + β1 xk

Non Linear Regression


1 Quadratic Regression Y = β0 + β1 x + β1 x 2 .
2 Polynomial Regression Y = β0 + β1 x + · · · + β1 x k
3 Exponential Regression Y = β0 eβ1 x
4 Power Equation Y = β0 x1β

VRNath, JNTU KAKINADA RM-STATS-2016


Regression
Introduction to R-Software and R-Studio Introduction
Simple Linear Regression

Applications of Regression

Business and Economics


1 Housing prices with the amenities provided.
2 Predicting the sales with the discounts offered.
3 No of visitors to a website with additional apps

Life Sciences
1 Predicting corbon emissions in the environment.
2 Pesticide concentration in the soil.
3 Body temperature vs heart rate.
4 Blood glucose levels with the drug dosage level.

VRNath, JNTU KAKINADA RM-STATS-2016


Regression
Introduction to R-Software and R-Studio Introduction
Simple Linear Regression

Applications of Regression

Business and Economics


1 Housing prices with the amenities provided.
2 Predicting the sales with the discounts offered.
3 No of visitors to a website with additional apps

Life Sciences
1 Predicting corbon emissions in the environment.
2 Pesticide concentration in the soil.
3 Body temperature vs heart rate.
4 Blood glucose levels with the drug dosage level.

VRNath, JNTU KAKINADA RM-STATS-2016


Regression
Introduction to R-Software and R-Studio Introduction
Simple Linear Regression

Applications of Regression

Business and Economics


1 Housing prices with the amenities provided.
2 Predicting the sales with the discounts offered.
3 No of visitors to a website with additional apps

Life Sciences
1 Predicting corbon emissions in the environment.
2 Pesticide concentration in the soil.
3 Body temperature vs heart rate.
4 Blood glucose levels with the drug dosage level.

VRNath, JNTU KAKINADA RM-STATS-2016


Regression
Introduction to R-Software and R-Studio Introduction
Simple Linear Regression

Applications of Regression

Business and Economics


1 Housing prices with the amenities provided.
2 Predicting the sales with the discounts offered.
3 No of visitors to a website with additional apps

Life Sciences
1 Predicting corbon emissions in the environment.
2 Pesticide concentration in the soil.
3 Body temperature vs heart rate.
4 Blood glucose levels with the drug dosage level.

VRNath, JNTU KAKINADA RM-STATS-2016


Regression
Introduction to R-Software and R-Studio Introduction
Simple Linear Regression

Applications of Regression

Business and Economics


1 Housing prices with the amenities provided.
2 Predicting the sales with the discounts offered.
3 No of visitors to a website with additional apps

Life Sciences
1 Predicting corbon emissions in the environment.
2 Pesticide concentration in the soil.
3 Body temperature vs heart rate.
4 Blood glucose levels with the drug dosage level.

VRNath, JNTU KAKINADA RM-STATS-2016


Regression
Introduction to R-Software and R-Studio Introduction
Simple Linear Regression

Applications of Regression

Business and Economics


1 Housing prices with the amenities provided.
2 Predicting the sales with the discounts offered.
3 No of visitors to a website with additional apps

Life Sciences
1 Predicting corbon emissions in the environment.
2 Pesticide concentration in the soil.
3 Body temperature vs heart rate.
4 Blood glucose levels with the drug dosage level.

VRNath, JNTU KAKINADA RM-STATS-2016


Regression
Introduction to R-Software and R-Studio Introduction
Simple Linear Regression

Applications of Regression

Business and Economics


1 Housing prices with the amenities provided.
2 Predicting the sales with the discounts offered.
3 No of visitors to a website with additional apps

Life Sciences
1 Predicting corbon emissions in the environment.
2 Pesticide concentration in the soil.
3 Body temperature vs heart rate.
4 Blood glucose levels with the drug dosage level.

VRNath, JNTU KAKINADA RM-STATS-2016


Regression
Introduction to R-Software and R-Studio Introduction
Simple Linear Regression

Applications of Regression

Business and Economics


1 Housing prices with the amenities provided.
2 Predicting the sales with the discounts offered.
3 No of visitors to a website with additional apps

Life Sciences
1 Predicting corbon emissions in the environment.
2 Pesticide concentration in the soil.
3 Body temperature vs heart rate.
4 Blood glucose levels with the drug dosage level.

VRNath, JNTU KAKINADA RM-STATS-2016


Regression
Introduction to R-Software and R-Studio Introduction
Simple Linear Regression

Applications of Regression

Business and Economics


1 Housing prices with the amenities provided.
2 Predicting the sales with the discounts offered.
3 No of visitors to a website with additional apps

Life Sciences
1 Predicting corbon emissions in the environment.
2 Pesticide concentration in the soil.
3 Body temperature vs heart rate.
4 Blood glucose levels with the drug dosage level.

VRNath, JNTU KAKINADA RM-STATS-2016


Regression
Introduction to R-Software and R-Studio Introduction
Simple Linear Regression

Applications of Regression

Business and Economics


1 Housing prices with the amenities provided.
2 Predicting the sales with the discounts offered.
3 No of visitors to a website with additional apps

Life Sciences
1 Predicting corbon emissions in the environment.
2 Pesticide concentration in the soil.
3 Body temperature vs heart rate.
4 Blood glucose levels with the drug dosage level.

VRNath, JNTU KAKINADA RM-STATS-2016


Regression
Introduction to R-Software and R-Studio Introduction
Simple Linear Regression

Applications of Regression

Business and Economics


1 Housing prices with the amenities provided.
2 Predicting the sales with the discounts offered.
3 No of visitors to a website with additional apps

Life Sciences
1 Predicting corbon emissions in the environment.
2 Pesticide concentration in the soil.
3 Body temperature vs heart rate.
4 Blood glucose levels with the drug dosage level.

VRNath, JNTU KAKINADA RM-STATS-2016


Regression
Introduction to R-Software and R-Studio Introduction
Simple Linear Regression

Applications of Regression

Business and Economics


1 Housing prices with the amenities provided.
2 Predicting the sales with the discounts offered.
3 No of visitors to a website with additional apps

Life Sciences
1 Predicting corbon emissions in the environment.
2 Pesticide concentration in the soil.
3 Body temperature vs heart rate.
4 Blood glucose levels with the drug dosage level.

VRNath, JNTU KAKINADA RM-STATS-2016


Regression
Introduction to R-Software and R-Studio Introduction
Simple Linear Regression

House Prices Data


Predicting the Price of a House

List Price Living Area Floors Bed Rooms Bath Rooms


69.0 6 1 2 1
118.5 10 1 2 2
116.5 10 1 3 2
125.0 11 1 3 2
129.9 13 1 3 1.7
135.0 13 2 3 2.5
139.9 13 1 3 2
147.9 17 2 3 2.5
160.0 19 2 3 2
169.9 18 1 3 2
134.9 13 1 4 2
155.0 18 1 4 2
169.9 17 2 4 3
194.5 20 JNTU KAKINADA2 RM-STATS-2016
VRNath, 4 3
Regression
Introduction to R-Software and R-Studio Introduction
Simple Linear Regression

House Prices Data


Predicting the Price of a House

List Price Living Area Floors Bed Rooms Bath Rooms


69.0 6 1 2 1
118.5 10 1 2 2
116.5 10 1 3 2
125.0 11 1 3 2
129.9 13 1 3 1.7
135.0 13 2 3 2.5
139.9 13 1 3 2
147.9 17 2 3 2.5
160.0 19 2 3 2
169.9 18 1 3 2
134.9 13 1 4 2
155.0 18 1 4 2
169.9 17 2 4 3
194.5 20 JNTU KAKINADA2 RM-STATS-2016
VRNath, 4 3
Windows in R Studio
Regression
Commands in R
Introduction to R-Software and R-Studio
Plotting by using R
Simple Linear Regression
House Prices Problem without Explanatory Variables

Outline

1 Regression
Introduction
2 Introduction to R-Software and R-Studio
Windows in R Studio
Commands in R
Plotting by using R
House Prices Problem without Explanatory Variables
3 Simple Linear Regression
Least Squares Method
Correlation
Testing of the Correlation Coefficient
Linear Regression and ANOVA

VRNath, JNTU KAKINADA RM-STATS-2016


Windows in R Studio
Regression
Commands in R
Introduction to R-Software and R-Studio
Plotting by using R
Simple Linear Regression
House Prices Problem without Explanatory Variables

Introduction to R-Studio
https://cran.r-project.org/, https://www.rstudio.com

VRNath, JNTU KAKINADA RM-STATS-2016


Windows in R Studio
Regression
Commands in R
Introduction to R-Software and R-Studio
Plotting by using R
Simple Linear Regression
House Prices Problem without Explanatory Variables

Introduction to R-Studio
Top Window

VRNath, JNTU KAKINADA RM-STATS-2016


Windows in R Studio
Regression
Commands in R
Introduction to R-Software and R-Studio
Plotting by using R
Simple Linear Regression
House Prices Problem without Explanatory Variables

Introduction to R-Studio
Source Window

VRNath, JNTU KAKINADA RM-STATS-2016


Windows in R Studio
Regression
Commands in R
Introduction to R-Software and R-Studio
Plotting by using R
Simple Linear Regression
House Prices Problem without Explanatory Variables

Introduction to R-Studio
Console Window

VRNath, JNTU KAKINADA RM-STATS-2016


Windows in R Studio
Regression
Commands in R
Introduction to R-Software and R-Studio
Plotting by using R
Simple Linear Regression
House Prices Problem without Explanatory Variables

Introduction to R-Studio
History Window

VRNath, JNTU KAKINADA RM-STATS-2016


Windows in R Studio
Regression
Commands in R
Introduction to R-Software and R-Studio
Plotting by using R
Simple Linear Regression
House Prices Problem without Explanatory Variables

Introduction to R-Studio
Plots Window

VRNath, JNTU KAKINADA RM-STATS-2016


Windows in R Studio
Regression
Commands in R
Introduction to R-Software and R-Studio
Plotting by using R
Simple Linear Regression
House Prices Problem without Explanatory Variables

Outline

1 Regression
Introduction
2 Introduction to R-Software and R-Studio
Windows in R Studio
Commands in R
Plotting by using R
House Prices Problem without Explanatory Variables
3 Simple Linear Regression
Least Squares Method
Correlation
Testing of the Correlation Coefficient
Linear Regression and ANOVA

VRNath, JNTU KAKINADA RM-STATS-2016


Windows in R Studio
Regression
Commands in R
Introduction to R-Software and R-Studio
Plotting by using R
Simple Linear Regression
House Prices Problem without Explanatory Variables

Outline

1 Regression
Introduction
2 Introduction to R-Software and R-Studio
Windows in R Studio
Commands in R
Plotting by using R
House Prices Problem without Explanatory Variables
3 Simple Linear Regression
Least Squares Method
Correlation
Testing of the Correlation Coefficient
Linear Regression and ANOVA

VRNath, JNTU KAKINADA RM-STATS-2016


Windows in R Studio
Regression
Commands in R
Introduction to R-Software and R-Studio
Plotting by using R
Simple Linear Regression
House Prices Problem without Explanatory Variables

Outline

1 Regression
Introduction
2 Introduction to R-Software and R-Studio
Windows in R Studio
Commands in R
Plotting by using R
House Prices Problem without Explanatory Variables
3 Simple Linear Regression
Least Squares Method
Correlation
Testing of the Correlation Coefficient
Linear Regression and ANOVA

VRNath, JNTU KAKINADA RM-STATS-2016


Windows in R Studio
Regression
Commands in R
Introduction to R-Software and R-Studio
Plotting by using R
Simple Linear Regression
House Prices Problem without Explanatory Variables

House Prices Data


Predicting the Price of a House

List Price Living Area Floors Bed Rooms Bath Rooms


69.0 6 1 2 1
118.5 10 1 2 2
116.5 10 1 3 2
125.0 11 1 3 2
129.9 13 1 3 1.7
135.0 13 2 3 2.5
139.9 13 1 3 2
147.9 17 2 3 2.5
160.0 19 2 3 2
169.9 18 1 3 2
134.9 13 1 4 2
155.0 18 1 4 2
169.9 17 2 4 3
194.5 20 JNTU KAKINADA2 RM-STATS-2016
VRNath, 4 3
Windows in R Studio
Regression
Commands in R
Introduction to R-Software and R-Studio
Plotting by using R
Simple Linear Regression
House Prices Problem without Explanatory Variables

Regression without variables


Residual Error

VRNath, JNTU KAKINADA RM-STATS-2016


Windows in R Studio
Regression
Commands in R
Introduction to R-Software and R-Studio
Plotting by using R
Simple Linear Regression
House Prices Problem without Explanatory Variables

Regression without variables


Residual Error

VRNath, JNTU KAKINADA RM-STATS-2016


Windows in R Studio
Regression
Commands in R
Introduction to R-Software and R-Studio
Plotting by using R
Simple Linear Regression
House Prices Problem without Explanatory Variables

Regression without variables


Residual Error

TSS= (y − y )2 =Residual Sum of Squares=16382.18


P

VRNath, JNTU KAKINADA RM-STATS-2016


Least Squares Method
Regression
Correlation
Introduction to R-Software and R-Studio
Testing of the Correlation Coefficient
Simple Linear Regression
Linear Regression and ANOVA

Outline

1 Regression
Introduction
2 Introduction to R-Software and R-Studio
Windows in R Studio
Commands in R
Plotting by using R
House Prices Problem without Explanatory Variables
3 Simple Linear Regression
Least Squares Method
Correlation
Testing of the Correlation Coefficient
Linear Regression and ANOVA

VRNath, JNTU KAKINADA RM-STATS-2016


Least Squares Method
Regression
Correlation
Introduction to R-Software and R-Studio
Testing of the Correlation Coefficient
Simple Linear Regression
Linear Regression and ANOVA

Simple Linear Regression


Y = β0 + β1 x + 

VRNath, JNTU KAKINADA RM-STATS-2016


Least Squares Method
Regression
Correlation
Introduction to R-Software and R-Studio
Testing of the Correlation Coefficient
Simple Linear Regression
Linear Regression and ANOVA

Simple Linear Regression


Y = β0 + β1 x + 

VRNath, JNTU KAKINADA RM-STATS-2016


Least Squares Method
Regression
Correlation
Introduction to R-Software and R-Studio
Testing of the Correlation Coefficient
Simple Linear Regression
Linear Regression and ANOVA

Simple Linear Regression


Better Straight Lines

VRNath, JNTU KAKINADA RM-STATS-2016


Least Squares Method
Regression
Correlation
Introduction to R-Software and R-Studio
Testing of the Correlation Coefficient
Simple Linear Regression
Linear Regression and ANOVA

Simple Linear Regression


Better Straight Lines

VRNath, JNTU KAKINADA RM-STATS-2016


Least Squares Method
Regression
Correlation
Introduction to R-Software and R-Studio
Testing of the Correlation Coefficient
Simple Linear Regression
Linear Regression and ANOVA

Simple Linear Regression


Better Straight Lines

VRNath, JNTU KAKINADA RM-STATS-2016


Least Squares Method
Regression
Correlation
Introduction to R-Software and R-Studio
Testing of the Correlation Coefficient
Simple Linear Regression
Linear Regression and ANOVA

Simple Linear Regression


Better Straight Lines

VRNath, JNTU KAKINADA RM-STATS-2016


Least Squares Method
Regression
Correlation
Introduction to R-Software and R-Studio
Testing of the Correlation Coefficient
Simple Linear Regression
Linear Regression and ANOVA

Simple Linear Regression


Better Straight Lines

VRNath, JNTU KAKINADA RM-STATS-2016


Least Squares Method
Regression
Correlation
Introduction to R-Software and R-Studio
Testing of the Correlation Coefficient
Simple Linear Regression
Linear Regression and ANOVA

Simple Linear Regression


Better Straight Lines

VRNath, JNTU KAKINADA RM-STATS-2016


Least Squares Method
Regression
Correlation
Introduction to R-Software and R-Studio
Testing of the Correlation Coefficient
Simple Linear Regression
Linear Regression and ANOVA

Simple Linear Regression


Better Straight Lines

VRNath, JNTU KAKINADA RM-STATS-2016


Least Squares Method
Regression
Correlation
Introduction to R-Software and R-Studio
Testing of the Correlation Coefficient
Simple Linear Regression
Linear Regression and ANOVA

Simple Linear Regression


Better Straight Lines

VRNath, JNTU KAKINADA RM-STATS-2016


Least Squares Method
Regression
Correlation
Introduction to R-Software and R-Studio
Testing of the Correlation Coefficient
Simple Linear Regression
Linear Regression and ANOVA

Simple Linear Regression


Better Straight Lines

VRNath, JNTU KAKINADA RM-STATS-2016


Least Squares Method
Regression
Correlation
Introduction to R-Software and R-Studio
Testing of the Correlation Coefficient
Simple Linear Regression
Linear Regression and ANOVA

Simple Linear Regression


Better Straight Lines

VRNath, JNTU KAKINADA RM-STATS-2016


Least Squares Method
Regression
Correlation
Introduction to R-Software and R-Studio
Testing of the Correlation Coefficient
Simple Linear Regression
Linear Regression and ANOVA

Simple Linear Regression


Least Squares Method

Procedure
1 Assume Y = β0 + β1 x
2 Compute
P the Normal
P Equations
P Y = β0 N P
+ β1 xP
x Y = β0 x + β1 x2
3 Solve the equations to get β̂0 and β̂1

R Commands and output


>mod<- lm(List.Price Living.Area)
Coefficients:
(Intercept) Living.Area
35.55 7.50
VRNath, JNTU KAKINADA RM-STATS-2016
Least Squares Method
Regression
Correlation
Introduction to R-Software and R-Studio
Testing of the Correlation Coefficient
Simple Linear Regression
Linear Regression and ANOVA

Simple Linear Regression


Least Squares Method

Procedure
1 Assume Y = β0 + β1 x
2 Compute
P the Normal
P Equations
P Y = β0 N P
+ β1 xP
x Y = β0 x + β1 x2
3 Solve the equations to get β̂0 and β̂1

R Commands and output


>mod<- lm(List.Price Living.Area)
Coefficients:
(Intercept) Living.Area
35.55 7.50
VRNath, JNTU KAKINADA RM-STATS-2016
Least Squares Method
Regression
Correlation
Introduction to R-Software and R-Studio
Testing of the Correlation Coefficient
Simple Linear Regression
Linear Regression and ANOVA

Simple Linear Regression


Least Squares Method

Procedure
1 Assume Y = β0 + β1 x
2 Compute
P the Normal
P Equations
P Y = β0 N P
+ β1 xP
x Y = β0 x + β1 x2
3 Solve the equations to get β̂0 and β̂1

R Commands and output


>mod<- lm(List.Price Living.Area)
Coefficients:
(Intercept) Living.Area
35.55 7.50
VRNath, JNTU KAKINADA RM-STATS-2016
Least Squares Method
Regression
Correlation
Introduction to R-Software and R-Studio
Testing of the Correlation Coefficient
Simple Linear Regression
Linear Regression and ANOVA

Simple Linear Regression


Least Squares Method

Procedure
1 Assume Y = β0 + β1 x
2 Compute the Normal
P P Equations
P Y = β0 N P
+ β1 xP
x Y = β0 x + β1 x2
3 Solve the equations to get β̂0 and β̂1

R Commands and output


>mod<- lm(List.Price Living.Area)
Coefficients:
(Intercept) Living.Area
35.55 7.50
VRNath, JNTU KAKINADA RM-STATS-2016
Least Squares Method
Regression
Correlation
Introduction to R-Software and R-Studio
Testing of the Correlation Coefficient
Simple Linear Regression
Linear Regression and ANOVA

Simple Linear Regression


Least Squares Method

Procedure
1 Assume Y = β0 + β1 x
2 Compute the Normal
P P Equations
P Y = β0 N P
+ β1 xP
x Y = β0 x + β1 x2
3 Solve the equations to get β̂0 and β̂1

R Commands and output


>mod<- lm(List.Price Living.Area)
Coefficients:
(Intercept) Living.Area
35.55 7.50
VRNath, JNTU KAKINADA RM-STATS-2016
Least Squares Method
Regression
Correlation
Introduction to R-Software and R-Studio
Testing of the Correlation Coefficient
Simple Linear Regression
Linear Regression and ANOVA

Simple Linear Regression


Least Squares Method

Procedure
1 Assume Y = β0 + β1 x
2 Compute the Normal
P P Equations
P Y = β0 N P
+ β1 xP
x Y = β0 x + β1 x2
3 Solve the equations to get β̂0 and β̂1

R Commands and output


>mod<- lm(List.Price Living.Area)
Coefficients:
(Intercept) Living.Area
35.55 7.50
VRNath, JNTU KAKINADA RM-STATS-2016
Least Squares Method
Regression
Correlation
Introduction to R-Software and R-Studio
Testing of the Correlation Coefficient
Simple Linear Regression
Linear Regression and ANOVA

Simple Linear Regression


Least Squares Method

Procedure
1 Assume Y = β0 + β1 x
2 Compute the Normal
P P Equations
P Y = β0 N P
+ β1 xP
x Y = β0 x + β1 x2
3 Solve the equations to get β̂0 and β̂1

R Commands and output


>mod<- lm(List.Price Living.Area)
Coefficients:
(Intercept) Living.Area
35.55 7.50
VRNath, JNTU KAKINADA RM-STATS-2016
Least Squares Method
Regression
Correlation
Introduction to R-Software and R-Studio
Testing of the Correlation Coefficient
Simple Linear Regression
Linear Regression and ANOVA

Simple Linear Regression


Least Squares Method

Procedure
1 Assume Y = β0 + β1 x
2 Compute the Normal
P P Equations
P Y = β0 N P
+ β1 xP
x Y = β0 x + β1 x2
3 Solve the equations to get β̂0 and β̂1

R Commands and output


>mod<- lm(List.Price Living.Area)
Coefficients:
(Intercept) Living.Area
35.55 7.50
VRNath, JNTU KAKINADA RM-STATS-2016
Least Squares Method
Regression
Correlation
Introduction to R-Software and R-Studio
Testing of the Correlation Coefficient
Simple Linear Regression
Linear Regression and ANOVA

Simple Linear Regression


Least Squares Method

Procedure
1 Assume Y = β0 + β1 x
2 Compute the Normal
P P Equations
P Y = β0 N P
+ β1 xP
x Y = β0 x + β1 x2
3 Solve the equations to get β̂0 and β̂1

R Commands and output


>mod<- lm(List.Price Living.Area)
Coefficients:
(Intercept) Living.Area
35.55 7.50
VRNath, JNTU KAKINADA RM-STATS-2016
Least Squares Method
Regression
Correlation
Introduction to R-Software and R-Studio
Testing of the Correlation Coefficient
Simple Linear Regression
Linear Regression and ANOVA

Simple Linear Regression


Least Squares Method

Procedure
1 Assume Y = β0 + β1 x
2 Compute the Normal
P P Equations
P Y = β0 N P
+ β1 xP
x Y = β0 x + β1 x2
3 Solve the equations to get β̂0 and β̂1

R Commands and output


>mod<- lm(List.Price Living.Area)
Coefficients:
(Intercept) Living.Area
35.55 7.50
VRNath, JNTU KAKINADA RM-STATS-2016
Least Squares Method
Regression
Correlation
Introduction to R-Software and R-Studio
Testing of the Correlation Coefficient
Simple Linear Regression
Linear Regression and ANOVA

Simple Linear Regression


Least Squares Method

Procedure
1 Assume Y = β0 + β1 x
2 Compute the Normal
P P Equations
P Y = β0 N P
+ β1 xP
x Y = β0 x + β1 x2
3 Solve the equations to get β̂0 and β̂1

R Commands and output


>mod<- lm(List.Price Living.Area)
Coefficients:
(Intercept) Living.Area
35.55 7.50
VRNath, JNTU KAKINADA RM-STATS-2016
Least Squares Method
Regression
Correlation
Introduction to R-Software and R-Studio
Testing of the Correlation Coefficient
Simple Linear Regression
Linear Regression and ANOVA

Simple Linear Regression


Least Squares Method

Procedure
1 Assume Y = β0 + β1 x
2 Compute the Normal
P P Equations
P Y = β0 N P
+ β1 xP
x Y = β0 x + β1 x2
3 Solve the equations to get β̂0 and β̂1

R Commands and output


>mod<- lm(List.Price Living.Area)
Coefficients:
(Intercept) Living.Area
35.55 7.50
VRNath, JNTU KAKINADA RM-STATS-2016
Least Squares Method
Regression
Correlation
Introduction to R-Software and R-Studio
Testing of the Correlation Coefficient
Simple Linear Regression
Linear Regression and ANOVA

Simple Linear Regression


Best Fit Straight Line

VRNath, JNTU KAKINADA RM-STATS-2016


Least Squares Method
Regression
Correlation
Introduction to R-Software and R-Studio
Testing of the Correlation Coefficient
Simple Linear Regression
Linear Regression and ANOVA

Simple Linear Regression


Best Fit Straight Line

VRNath, JNTU KAKINADA RM-STATS-2016


Least Squares Method
Regression
Correlation
Introduction to R-Software and R-Studio
Testing of the Correlation Coefficient
Simple Linear Regression
Linear Regression and ANOVA

Simple Linear Regression


Best Fit Straight Line

VRNath, JNTU KAKINADA RM-STATS-2016


Least Squares Method
Regression
Correlation
Introduction to R-Software and R-Studio
Testing of the Correlation Coefficient
Simple Linear Regression
Linear Regression and ANOVA

Simple Linear Regression


Best Fit Straight Line

VRNath, JNTU KAKINADA RM-STATS-2016


Least Squares Method
Regression
Correlation
Introduction to R-Software and R-Studio
Testing of the Correlation Coefficient
Simple Linear Regression
Linear Regression and ANOVA

Simple Linear Regression


Best Fit Straight Line

VRNath, JNTU KAKINADA RM-STATS-2016


Least Squares Method
Regression
Correlation
Introduction to R-Software and R-Studio
Testing of the Correlation Coefficient
Simple Linear Regression
Linear Regression and ANOVA

Simple Linear Regression


Model Errors

Model Fitness
SST-> Total SS in obs Y = (y − y )2 = 16382.18
P
1

SSR-> SS in the model Y =(Ŷ ) = (ŷ − y )2 = 14829.3


P
2

SSE-> SS unexplained by the model = (y − ŷ )2 =


P
3

1552.88
4 SST = SSR + SSE
5 1 = SSR/SST + SSE/SST = 0.9052+0.0948
6 Multiple R 2 =0.9052 or 90.5%

Interpretation of R
Adding one variable reduced the residual error from 100% to
9.5%. Adding good variables improves model efficiency.
VRNath, JNTU KAKINADA RM-STATS-2016
Least Squares Method
Regression
Correlation
Introduction to R-Software and R-Studio
Testing of the Correlation Coefficient
Simple Linear Regression
Linear Regression and ANOVA

Simple Linear Regression


Model Errors

Model Fitness
SST-> Total SS in obs Y = (y − y )2 = 16382.18
P
1

SSR-> SS in the model Y =(Ŷ ) = (ŷ − y )2 = 14829.3


P
2

SSE-> SS unexplained by the model = (y − ŷ )2 =


P
3

1552.88
4 SST = SSR + SSE
5 1 = SSR/SST + SSE/SST = 0.9052+0.0948
6 Multiple R 2 =0.9052 or 90.5%

Interpretation of R
Adding one variable reduced the residual error from 100% to
9.5%. Adding good variables improves model efficiency.
VRNath, JNTU KAKINADA RM-STATS-2016
Least Squares Method
Regression
Correlation
Introduction to R-Software and R-Studio
Testing of the Correlation Coefficient
Simple Linear Regression
Linear Regression and ANOVA

Simple Linear Regression


Model Errors

Model Fitness
SST-> Total SS in obs Y = (y − y )2 = 16382.18
P
1

SSR-> SS in the model Y =(Ŷ ) = (ŷ − y )2 = 14829.3


P
2

SSE-> SS unexplained by the model = (y − ŷ )2 =


P
3

1552.88
4 SST = SSR + SSE
5 1 = SSR/SST + SSE/SST = 0.9052+0.0948
6 Multiple R 2 =0.9052 or 90.5%

Interpretation of R
Adding one variable reduced the residual error from 100% to
9.5%. Adding good variables improves model efficiency.
VRNath, JNTU KAKINADA RM-STATS-2016
Least Squares Method
Regression
Correlation
Introduction to R-Software and R-Studio
Testing of the Correlation Coefficient
Simple Linear Regression
Linear Regression and ANOVA

Simple Linear Regression


Model Errors

Model Fitness
SST-> Total SS in obs Y = (y − y )2 = 16382.18
P
1

SSR-> SS in the model Y =(Ŷ ) = (ŷ − y )2 = 14829.3


P
2

SSE-> SS unexplained by the model = (y − ŷ )2 =


P
3

1552.88
4 SST = SSR + SSE
5 1 = SSR/SST + SSE/SST = 0.9052+0.0948
6 Multiple R 2 =0.9052 or 90.5%

Interpretation of R
Adding one variable reduced the residual error from 100% to
9.5%. Adding good variables improves model efficiency.
VRNath, JNTU KAKINADA RM-STATS-2016
Least Squares Method
Regression
Correlation
Introduction to R-Software and R-Studio
Testing of the Correlation Coefficient
Simple Linear Regression
Linear Regression and ANOVA

Simple Linear Regression


Model Errors

Model Fitness
SST-> Total SS in obs Y = (y − y )2 = 16382.18
P
1

SSR-> SS in the model Y =(Ŷ ) = (ŷ − y )2 = 14829.3


P
2

SSE-> SS unexplained by the model = (y − ŷ )2 =


P
3

1552.88
4 SST = SSR + SSE
5 1 = SSR/SST + SSE/SST = 0.9052+0.0948
6 Multiple R 2 =0.9052 or 90.5%

Interpretation of R
Adding one variable reduced the residual error from 100% to
9.5%. Adding good variables improves model efficiency.
VRNath, JNTU KAKINADA RM-STATS-2016
Least Squares Method
Regression
Correlation
Introduction to R-Software and R-Studio
Testing of the Correlation Coefficient
Simple Linear Regression
Linear Regression and ANOVA

Simple Linear Regression


Model Errors

Model Fitness
SST-> Total SS in obs Y = (y − y )2 = 16382.18
P
1

SSR-> SS in the model Y =(Ŷ ) = (ŷ − y )2 = 14829.3


P
2

SSE-> SS unexplained by the model = (y − ŷ )2 =


P
3

1552.88
4 SST = SSR + SSE
5 1 = SSR/SST + SSE/SST = 0.9052+0.0948
6 Multiple R 2 =0.9052 or 90.5%

Interpretation of R
Adding one variable reduced the residual error from 100% to
9.5%. Adding good variables improves model efficiency.
VRNath, JNTU KAKINADA RM-STATS-2016
Least Squares Method
Regression
Correlation
Introduction to R-Software and R-Studio
Testing of the Correlation Coefficient
Simple Linear Regression
Linear Regression and ANOVA

Simple Linear Regression


Model Errors

Model Fitness
SST-> Total SS in obs Y = (y − y )2 = 16382.18
P
1

SSR-> SS in the model Y =(Ŷ ) = (ŷ − y )2 = 14829.3


P
2

SSE-> SS unexplained by the model = (y − ŷ )2 =


P
3

1552.88
4 SST = SSR + SSE
5 1 = SSR/SST + SSE/SST = 0.9052+0.0948
6 Multiple R 2 =0.9052 or 90.5%

Interpretation of R
Adding one variable reduced the residual error from 100% to
9.5%. Adding good variables improves model efficiency.
VRNath, JNTU KAKINADA RM-STATS-2016
Least Squares Method
Regression
Correlation
Introduction to R-Software and R-Studio
Testing of the Correlation Coefficient
Simple Linear Regression
Linear Regression and ANOVA

Simple Linear Regression


Model Errors

Model Fitness
SST-> Total SS in obs Y = (y − y )2 = 16382.18
P
1

SSR-> SS in the model Y =(Ŷ ) = (ŷ − y )2 = 14829.3


P
2

SSE-> SS unexplained by the model = (y − ŷ )2 =


P
3

1552.88
4 SST = SSR + SSE
5 1 = SSR/SST + SSE/SST = 0.9052+0.0948
6 Multiple R 2 =0.9052 or 90.5%

Interpretation of R
Adding one variable reduced the residual error from 100% to
9.5%. Adding good variables improves model efficiency.
VRNath, JNTU KAKINADA RM-STATS-2016
Least Squares Method
Regression
Correlation
Introduction to R-Software and R-Studio
Testing of the Correlation Coefficient
Simple Linear Regression
Linear Regression and ANOVA

Simple Linear Regression


Model Errors

Model Fitness
SST-> Total SS in obs Y = (y − y )2 = 16382.18
P
1

SSR-> SS in the model Y =(Ŷ ) = (ŷ − y )2 = 14829.3


P
2

SSE-> SS unexplained by the model = (y − ŷ )2 =


P
3

1552.88
4 SST = SSR + SSE
5 1 = SSR/SST + SSE/SST = 0.9052+0.0948
6 Multiple R 2 =0.9052 or 90.5%

Interpretation of R
Adding one variable reduced the residual error from 100% to
9.5%. Adding good variables improves model efficiency.
VRNath, JNTU KAKINADA RM-STATS-2016
Least Squares Method
Regression
Correlation
Introduction to R-Software and R-Studio
Testing of the Correlation Coefficient
Simple Linear Regression
Linear Regression and ANOVA

Simple Linear Regression


Model Errors

Model Fitness
SST-> Total SS in obs Y = (y − y )2 = 16382.18
P
1

SSR-> SS in the model Y =(Ŷ ) = (ŷ − y )2 = 14829.3


P
2

SSE-> SS unexplained by the model = (y − ŷ )2 =


P
3

1552.88
4 SST = SSR + SSE
5 1 = SSR/SST + SSE/SST = 0.9052+0.0948
6 Multiple R 2 =0.9052 or 90.5%

Interpretation of R
Adding one variable reduced the residual error from 100% to
9.5%. Adding good variables improves model efficiency.
VRNath, JNTU KAKINADA RM-STATS-2016
Least Squares Method
Regression
Correlation
Introduction to R-Software and R-Studio
Testing of the Correlation Coefficient
Simple Linear Regression
Linear Regression and ANOVA

Simple Linear Regression


Model Errors

Model Fitness
SST-> Total SS in obs Y = (y − y )2 = 16382.18
P
1

SSR-> SS in the model Y =(Ŷ ) = (ŷ − y )2 = 14829.3


P
2

SSE-> SS unexplained by the model = (y − ŷ )2 =


P
3

1552.88
4 SST = SSR + SSE
5 1 = SSR/SST + SSE/SST = 0.9052+0.0948
6 Multiple R 2 =0.9052 or 90.5%

Interpretation of R
Adding one variable reduced the residual error from 100% to
9.5%. Adding good variables improves model efficiency.
VRNath, JNTU KAKINADA RM-STATS-2016
Least Squares Method
Regression
Correlation
Introduction to R-Software and R-Studio
Testing of the Correlation Coefficient
Simple Linear Regression
Linear Regression and ANOVA

Simple Linear Regression


Model Errors

Model Fitness
SST-> Total SS in obs Y = (y − y )2 = 16382.18
P
1

SSR-> SS in the model Y =(Ŷ ) = (ŷ − y )2 = 14829.3


P
2

SSE-> SS unexplained by the model = (y − ŷ )2 =


P
3

1552.88
4 SST = SSR + SSE
5 1 = SSR/SST + SSE/SST = 0.9052+0.0948
6 Multiple R 2 =0.9052 or 90.5%

Interpretation of R
Adding one variable reduced the residual error from 100% to
9.5%. Adding good variables improves model efficiency.
VRNath, JNTU KAKINADA RM-STATS-2016
Least Squares Method
Regression
Correlation
Introduction to R-Software and R-Studio
Testing of the Correlation Coefficient
Simple Linear Regression
Linear Regression and ANOVA

Simple Linear Regression


Model Errors

Model Fitness
SST-> Total SS in obs Y = (y − y )2 = 16382.18
P
1

SSR-> SS in the model Y =(Ŷ ) = (ŷ − y )2 = 14829.3


P
2

SSE-> SS unexplained by the model = (y − ŷ )2 =


P
3

1552.88
4 SST = SSR + SSE
5 1 = SSR/SST + SSE/SST = 0.9052+0.0948
6 Multiple R 2 =0.9052 or 90.5%

Interpretation of R
Adding one variable reduced the residual error from 100% to
9.5%. Adding good variables improves model efficiency.
VRNath, JNTU KAKINADA RM-STATS-2016
Least Squares Method
Regression
Correlation
Introduction to R-Software and R-Studio
Testing of the Correlation Coefficient
Simple Linear Regression
Linear Regression and ANOVA

Simple Linear Regression


Model Errors

Model Fitness
SST-> Total SS in obs Y = (y − y )2 = 16382.18
P
1

SSR-> SS in the model Y =(Ŷ ) = (ŷ − y )2 = 14829.3


P
2

SSE-> SS unexplained by the model = (y − ŷ )2 =


P
3

1552.88
4 SST = SSR + SSE
5 1 = SSR/SST + SSE/SST = 0.9052+0.0948
6 Multiple R 2 =0.9052 or 90.5%

Interpretation of R
Adding one variable reduced the residual error from 100% to
9.5%. Adding good variables improves model efficiency.
VRNath, JNTU KAKINADA RM-STATS-2016
Least Squares Method
Regression
Correlation
Introduction to R-Software and R-Studio
Testing of the Correlation Coefficient
Simple Linear Regression
Linear Regression and ANOVA

Simple Linear Regression


Model Errors

Model Fitness
SST-> Total SS in obs Y = (y − y )2 = 16382.18
P
1

SSR-> SS in the model Y =(Ŷ ) = (ŷ − y )2 = 14829.3


P
2

SSE-> SS unexplained by the model = (y − ŷ )2 =


P
3

1552.88
4 SST = SSR + SSE
5 1 = SSR/SST + SSE/SST = 0.9052+0.0948
6 Multiple R 2 =0.9052 or 90.5%

Interpretation of R
Adding one variable reduced the residual error from 100% to
9.5%. Adding good variables improves model efficiency.
VRNath, JNTU KAKINADA RM-STATS-2016
Least Squares Method
Regression
Correlation
Introduction to R-Software and R-Studio
Testing of the Correlation Coefficient
Simple Linear Regression
Linear Regression and ANOVA

Simple Linear Regression


Model Errors

Model Fitness
SST-> Total SS in obs Y = (y − y )2 = 16382.18
P
1

SSR-> SS in the model Y =(Ŷ ) = (ŷ − y )2 = 14829.3


P
2

SSE-> SS unexplained by the model = (y − ŷ )2 =


P
3

1552.88
4 SST = SSR + SSE
5 1 = SSR/SST + SSE/SST = 0.9052+0.0948
6 Multiple R 2 =0.9052 or 90.5%

Interpretation of R
Adding one variable reduced the residual error from 100% to
9.5%. Adding good variables improves model efficiency.
VRNath, JNTU KAKINADA RM-STATS-2016
Least Squares Method
Regression
Correlation
Introduction to R-Software and R-Studio
Testing of the Correlation Coefficient
Simple Linear Regression
Linear Regression and ANOVA

Simple Linear Regression


Model Errors

Model Fitness
SST-> Total SS in obs Y = (y − y )2 = 16382.18
P
1

SSR-> SS in the model Y =(Ŷ ) = (ŷ − y )2 = 14829.3


P
2

SSE-> SS unexplained by the model = (y − ŷ )2 =


P
3

1552.88
4 SST = SSR + SSE
5 1 = SSR/SST + SSE/SST = 0.9052+0.0948
6 Multiple R 2 =0.9052 or 90.5%

Interpretation of R
Adding one variable reduced the residual error from 100% to
9.5%. Adding good variables improves model efficiency.
VRNath, JNTU KAKINADA RM-STATS-2016
Least Squares Method
Regression
Correlation
Introduction to R-Software and R-Studio
Testing of the Correlation Coefficient
Simple Linear Regression
Linear Regression and ANOVA

Simple Linear Regression


Model Errors

Model Fitness
SST-> Total SS in obs Y = (y − y )2 = 16382.18
P
1

SSR-> SS in the model Y =(Ŷ ) = (ŷ − y )2 = 14829.3


P
2

SSE-> SS unexplained by the model = (y − ŷ )2 =


P
3

1552.88
4 SST = SSR + SSE
5 1 = SSR/SST + SSE/SST = 0.9052+0.0948
6 Multiple R 2 =0.9052 or 90.5%

Interpretation of R
Adding one variable reduced the residual error from 100% to
9.5%. Adding good variables improves model efficiency.
VRNath, JNTU KAKINADA RM-STATS-2016
Least Squares Method
Regression
Correlation
Introduction to R-Software and R-Studio
Testing of the Correlation Coefficient
Simple Linear Regression
Linear Regression and ANOVA

House Prices Example


Regression Model Plots

VRNath, JNTU KAKINADA RM-STATS-2016


Least Squares Method
Regression
Correlation
Introduction to R-Software and R-Studio
Testing of the Correlation Coefficient
Simple Linear Regression
Linear Regression and ANOVA

House Prices Example


Regression Model Plots

VRNath, JNTU KAKINADA RM-STATS-2016


Least Squares Method
Regression
Correlation
Introduction to R-Software and R-Studio
Testing of the Correlation Coefficient
Simple Linear Regression
Linear Regression and ANOVA

House Prices Example


Regression Model Plots

VRNath, JNTU KAKINADA RM-STATS-2016


Least Squares Method
Regression
Correlation
Introduction to R-Software and R-Studio
Testing of the Correlation Coefficient
Simple Linear Regression
Linear Regression and ANOVA

House Prices Example


Regression Model Plots

VRNath, JNTU KAKINADA RM-STATS-2016


Least Squares Method
Regression
Correlation
Introduction to R-Software and R-Studio
Testing of the Correlation Coefficient
Simple Linear Regression
Linear Regression and ANOVA

House Prices Example


Regression Model Plots

VRNath, JNTU KAKINADA RM-STATS-2016


Least Squares Method
Regression
Correlation
Introduction to R-Software and R-Studio
Testing of the Correlation Coefficient
Simple Linear Regression
Linear Regression and ANOVA

Linear Model Results Summary

> summary(mod) Call: lm(formula = List.Price


Living.Area)
Residuals: Min 1Q Median 3Q Max
-18.055 -7.351 1.947 6.898 16.844
Coeffs: Estimate Std. Error t value Pr(>|t|)
(Intercept) 35.5467 10.2254 3.476 0.0041 **
Living.Area 7.5005 0.6732 11.142 5.06e-08 ***
Signif. codes: 0 ?***? 0.001 ?**? 0.01 ?*?
0.05 ?.? 0.1 ? ? 1 Residual standard error:
10.93 on 13 degrees of freedom Multiple R-squared:
0.9052, Adjusted R-squared: 0.8979 F-statistic:
124.1 on 1 and 13 DF, p-value: 5.061e-08

VRNath, JNTU KAKINADA RM-STATS-2016


Least Squares Method
Regression
Correlation
Introduction to R-Software and R-Studio
Testing of the Correlation Coefficient
Simple Linear Regression
Linear Regression and ANOVA

Linear Model Results Summary

> summary(mod) Call: lm(formula = List.Price


Living.Area)
Residuals: Min 1Q Median 3Q Max
-18.055 -7.351 1.947 6.898 16.844
Coeffs: Estimate Std. Error t value Pr(>|t|)
(Intercept) 35.5467 10.2254 3.476 0.0041 **
Living.Area 7.5005 0.6732 11.142 5.06e-08 ***
Signif. codes: 0 ?***? 0.001 ?**? 0.01 ?*?
0.05 ?.? 0.1 ? ? 1 Residual standard error:
10.93 on 13 degrees of freedom Multiple R-squared:
0.9052, Adjusted R-squared: 0.8979 F-statistic:
124.1 on 1 and 13 DF, p-value: 5.061e-08

VRNath, JNTU KAKINADA RM-STATS-2016


Least Squares Method
Regression
Correlation
Introduction to R-Software and R-Studio
Testing of the Correlation Coefficient
Simple Linear Regression
Linear Regression and ANOVA

Linear Model Results Summary

> summary(mod) Call: lm(formula = List.Price


Living.Area)
Residuals: Min 1Q Median 3Q Max
-18.055 -7.351 1.947 6.898 16.844
Coeffs: Estimate Std. Error t value Pr(>|t|)
(Intercept) 35.5467 10.2254 3.476 0.0041 **
Living.Area 7.5005 0.6732 11.142 5.06e-08 ***
Signif. codes: 0 ?***? 0.001 ?**? 0.01 ?*?
0.05 ?.? 0.1 ? ? 1 Residual standard error:
10.93 on 13 degrees of freedom Multiple R-squared:
0.9052, Adjusted R-squared: 0.8979 F-statistic:
124.1 on 1 and 13 DF, p-value: 5.061e-08

VRNath, JNTU KAKINADA RM-STATS-2016


Least Squares Method
Regression
Correlation
Introduction to R-Software and R-Studio
Testing of the Correlation Coefficient
Simple Linear Regression
Linear Regression and ANOVA

Linear Model Results Summary

> summary(mod) Call: lm(formula = List.Price


Living.Area)
Residuals: Min 1Q Median 3Q Max
-18.055 -7.351 1.947 6.898 16.844
Coeffs: Estimate Std. Error t value Pr(>|t|)
(Intercept) 35.5467 10.2254 3.476 0.0041 **
Living.Area 7.5005 0.6732 11.142 5.06e-08 ***
Signif. codes: 0 ?***? 0.001 ?**? 0.01 ?*?
0.05 ?.? 0.1 ? ? 1 Residual standard error:
10.93 on 13 degrees of freedom Multiple R-squared:
0.9052, Adjusted R-squared: 0.8979 F-statistic:
124.1 on 1 and 13 DF, p-value: 5.061e-08

VRNath, JNTU KAKINADA RM-STATS-2016


Least Squares Method
Regression
Correlation
Introduction to R-Software and R-Studio
Testing of the Correlation Coefficient
Simple Linear Regression
Linear Regression and ANOVA

Linear Model Results Summary

> summary(mod) Call: lm(formula = List.Price


Living.Area)
Residuals: Min 1Q Median 3Q Max
-18.055 -7.351 1.947 6.898 16.844
Coeffs: Estimate Std. Error t value Pr(>|t|)
(Intercept) 35.5467 10.2254 3.476 0.0041 **
Living.Area 7.5005 0.6732 11.142 5.06e-08 ***
Signif. codes: 0 ?***? 0.001 ?**? 0.01 ?*?
0.05 ?.? 0.1 ? ? 1 Residual standard error:
10.93 on 13 degrees of freedom Multiple R-squared:
0.9052, Adjusted R-squared: 0.8979 F-statistic:
124.1 on 1 and 13 DF, p-value: 5.061e-08

VRNath, JNTU KAKINADA RM-STATS-2016


Least Squares Method
Regression
Correlation
Introduction to R-Software and R-Studio
Testing of the Correlation Coefficient
Simple Linear Regression
Linear Regression and ANOVA

Linear Model Results Summary

> summary(mod) Call: lm(formula = List.Price


Living.Area)
Residuals: Min 1Q Median 3Q Max
-18.055 -7.351 1.947 6.898 16.844
Coeffs: Estimate Std. Error t value Pr(>|t|)
(Intercept) 35.5467 10.2254 3.476 0.0041 **
Living.Area 7.5005 0.6732 11.142 5.06e-08 ***
Signif. codes: 0 ?***? 0.001 ?**? 0.01 ?*?
0.05 ?.? 0.1 ? ? 1 Residual standard error:
10.93 on 13 degrees of freedom Multiple R-squared:
0.9052, Adjusted R-squared: 0.8979 F-statistic:
124.1 on 1 and 13 DF, p-value: 5.061e-08

VRNath, JNTU KAKINADA RM-STATS-2016


Least Squares Method
Regression
Correlation
Introduction to R-Software and R-Studio
Testing of the Correlation Coefficient
Simple Linear Regression
Linear Regression and ANOVA

Linear Model Results Summary

> summary(mod) Call: lm(formula = List.Price


Living.Area)
Residuals: Min 1Q Median 3Q Max
-18.055 -7.351 1.947 6.898 16.844
Coeffs: Estimate Std. Error t value Pr(>|t|)
(Intercept) 35.5467 10.2254 3.476 0.0041 **
Living.Area 7.5005 0.6732 11.142 5.06e-08 ***
Signif. codes: 0 ?***? 0.001 ?**? 0.01 ?*?
0.05 ?.? 0.1 ? ? 1 Residual standard error:
10.93 on 13 degrees of freedom Multiple R-squared:
0.9052, Adjusted R-squared: 0.8979 F-statistic:
124.1 on 1 and 13 DF, p-value: 5.061e-08

VRNath, JNTU KAKINADA RM-STATS-2016


Least Squares Method
Regression
Correlation
Introduction to R-Software and R-Studio
Testing of the Correlation Coefficient
Simple Linear Regression
Linear Regression and ANOVA

Linear Model Results Summary

> summary(mod) Call: lm(formula = List.Price


Living.Area)
Residuals: Min 1Q Median 3Q Max
-18.055 -7.351 1.947 6.898 16.844
Coeffs: Estimate Std. Error t value Pr(>|t|)
(Intercept) 35.5467 10.2254 3.476 0.0041 **
Living.Area 7.5005 0.6732 11.142 5.06e-08 ***
Signif. codes: 0 ?***? 0.001 ?**? 0.01 ?*?
0.05 ?.? 0.1 ? ? 1 Residual standard error:
10.93 on 13 degrees of freedom Multiple R-squared:
0.9052, Adjusted R-squared: 0.8979 F-statistic:
124.1 on 1 and 13 DF, p-value: 5.061e-08

VRNath, JNTU KAKINADA RM-STATS-2016


Least Squares Method
Regression
Correlation
Introduction to R-Software and R-Studio
Testing of the Correlation Coefficient
Simple Linear Regression
Linear Regression and ANOVA

Linear Model Results Summary

> summary(mod) Call: lm(formula = List.Price


Living.Area)
Residuals: Min 1Q Median 3Q Max
-18.055 -7.351 1.947 6.898 16.844
Coeffs: Estimate Std. Error t value Pr(>|t|)
(Intercept) 35.5467 10.2254 3.476 0.0041 **
Living.Area 7.5005 0.6732 11.142 5.06e-08 ***
Signif. codes: 0 ?***? 0.001 ?**? 0.01 ?*?
0.05 ?.? 0.1 ? ? 1 Residual standard error:
10.93 on 13 degrees of freedom Multiple R-squared:
0.9052, Adjusted R-squared: 0.8979 F-statistic:
124.1 on 1 and 13 DF, p-value: 5.061e-08

VRNath, JNTU KAKINADA RM-STATS-2016


Least Squares Method
Regression
Correlation
Introduction to R-Software and R-Studio
Testing of the Correlation Coefficient
Simple Linear Regression
Linear Regression and ANOVA

Linear Model Results Summary

> summary(mod) Call: lm(formula = List.Price


Living.Area)
Residuals: Min 1Q Median 3Q Max
-18.055 -7.351 1.947 6.898 16.844
Coeffs: Estimate Std. Error t value Pr(>|t|)
(Intercept) 35.5467 10.2254 3.476 0.0041 **
Living.Area 7.5005 0.6732 11.142 5.06e-08 ***
Signif. codes: 0 ?***? 0.001 ?**? 0.01 ?*?
0.05 ?.? 0.1 ? ? 1 Residual standard error:
10.93 on 13 degrees of freedom Multiple R-squared:
0.9052, Adjusted R-squared: 0.8979 F-statistic:
124.1 on 1 and 13 DF, p-value: 5.061e-08

VRNath, JNTU KAKINADA RM-STATS-2016


Least Squares Method
Regression
Correlation
Introduction to R-Software and R-Studio
Testing of the Correlation Coefficient
Simple Linear Regression
Linear Regression and ANOVA

Linear Model Results Summary

> summary(mod) Call: lm(formula = List.Price


Living.Area)
Residuals: Min 1Q Median 3Q Max
-18.055 -7.351 1.947 6.898 16.844
Coeffs: Estimate Std. Error t value Pr(>|t|)
(Intercept) 35.5467 10.2254 3.476 0.0041 **
Living.Area 7.5005 0.6732 11.142 5.06e-08 ***
Signif. codes: 0 ?***? 0.001 ?**? 0.01 ?*?
0.05 ?.? 0.1 ? ? 1 Residual standard error:
10.93 on 13 degrees of freedom Multiple R-squared:
0.9052, Adjusted R-squared: 0.8979 F-statistic:
124.1 on 1 and 13 DF, p-value: 5.061e-08

VRNath, JNTU KAKINADA RM-STATS-2016


Least Squares Method
Regression
Correlation
Introduction to R-Software and R-Studio
Testing of the Correlation Coefficient
Simple Linear Regression
Linear Regression and ANOVA

Linear Model Results Summary

> summary(mod) Call: lm(formula = List.Price


Living.Area)
Residuals: Min 1Q Median 3Q Max
-18.055 -7.351 1.947 6.898 16.844
Coeffs: Estimate Std. Error t value Pr(>|t|)
(Intercept) 35.5467 10.2254 3.476 0.0041 **
Living.Area 7.5005 0.6732 11.142 5.06e-08 ***
Signif. codes: 0 ?***? 0.001 ?**? 0.01 ?*?
0.05 ?.? 0.1 ? ? 1 Residual standard error:
10.93 on 13 degrees of freedom Multiple R-squared:
0.9052, Adjusted R-squared: 0.8979 F-statistic:
124.1 on 1 and 13 DF, p-value: 5.061e-08

VRNath, JNTU KAKINADA RM-STATS-2016


Least Squares Method
Regression
Correlation
Introduction to R-Software and R-Studio
Testing of the Correlation Coefficient
Simple Linear Regression
Linear Regression and ANOVA

Linear Model Results Summary

> summary(mod) Call: lm(formula = List.Price


Living.Area)
Residuals: Min 1Q Median 3Q Max
-18.055 -7.351 1.947 6.898 16.844
Coeffs: Estimate Std. Error t value Pr(>|t|)
(Intercept) 35.5467 10.2254 3.476 0.0041 **
Living.Area 7.5005 0.6732 11.142 5.06e-08 ***
Signif. codes: 0 ?***? 0.001 ?**? 0.01 ?*?
0.05 ?.? 0.1 ? ? 1 Residual standard error:
10.93 on 13 degrees of freedom Multiple R-squared:
0.9052, Adjusted R-squared: 0.8979 F-statistic:
124.1 on 1 and 13 DF, p-value: 5.061e-08

VRNath, JNTU KAKINADA RM-STATS-2016


Least Squares Method
Regression
Correlation
Introduction to R-Software and R-Studio
Testing of the Correlation Coefficient
Simple Linear Regression
Linear Regression and ANOVA

Linear Model Results Summary

> summary(mod) Call: lm(formula = List.Price


Living.Area)
Residuals: Min 1Q Median 3Q Max
-18.055 -7.351 1.947 6.898 16.844
Coeffs: Estimate Std. Error t value Pr(>|t|)
(Intercept) 35.5467 10.2254 3.476 0.0041 **
Living.Area 7.5005 0.6732 11.142 5.06e-08 ***
Signif. codes: 0 ?***? 0.001 ?**? 0.01 ?*?
0.05 ?.? 0.1 ? ? 1 Residual standard error:
10.93 on 13 degrees of freedom Multiple R-squared:
0.9052, Adjusted R-squared: 0.8979 F-statistic:
124.1 on 1 and 13 DF, p-value: 5.061e-08

VRNath, JNTU KAKINADA RM-STATS-2016


Least Squares Method
Regression
Correlation
Introduction to R-Software and R-Studio
Testing of the Correlation Coefficient
Simple Linear Regression
Linear Regression and ANOVA

Outline

1 Regression
Introduction
2 Introduction to R-Software and R-Studio
Windows in R Studio
Commands in R
Plotting by using R
House Prices Problem without Explanatory Variables
3 Simple Linear Regression
Least Squares Method
Correlation
Testing of the Correlation Coefficient
Linear Regression and ANOVA

VRNath, JNTU KAKINADA RM-STATS-2016


Least Squares Method
Regression
Correlation
Introduction to R-Software and R-Studio
Testing of the Correlation Coefficient
Simple Linear Regression
Linear Regression and ANOVA

Correlation
Introduction

Correlation is association observed among some random


variables which is used to build a predictive model. There are
three types of correlation
1 Positive Correlation
2 Negative Correlation
3 Zero Correlation

Examples
(Height, Weight), (Man Hours, Production), (Training Hours,
Defects)

VRNath, JNTU KAKINADA RM-STATS-2016


Least Squares Method
Regression
Correlation
Introduction to R-Software and R-Studio
Testing of the Correlation Coefficient
Simple Linear Regression
Linear Regression and ANOVA

Types of Correlation

Two variables X and Y are said to be positively correlated if


Negative Correlation
the increase in one variable causes an decrease in the other
variable

or

the decrease in one variable causes a increase in the other


variable

Examples
(training hours, no of errors), (weight of vehicle, speed)

VRNath, JNTU KAKINADA RM-STATS-2016


Least Squares Method
Regression
Correlation
Introduction to R-Software and R-Studio
Testing of the Correlation Coefficient
Simple Linear Regression
Linear Regression and ANOVA

Types of Correlation

Two variables X and Y are said to be positively correlated if


Negative Correlation
the increase in one variable causes an decrease in the other
variable

or

the decrease in one variable causes a increase in the other


variable

Examples
(training hours, no of errors), (weight of vehicle, speed)

VRNath, JNTU KAKINADA RM-STATS-2016


Least Squares Method
Regression
Correlation
Introduction to R-Software and R-Studio
Testing of the Correlation Coefficient
Simple Linear Regression
Linear Regression and ANOVA

Types of Correlation
Scatter Diagram

Two variables X and Y are said to be positively correlated if

Figure: Scatter Plots

VRNath, JNTU KAKINADA RM-STATS-2016


Least Squares Method
Regression
Correlation
Introduction to R-Software and R-Studio
Testing of the Correlation Coefficient
Simple Linear Regression
Linear Regression and ANOVA

Pearson Measure of Correlation


The correlation between X and Y is
2
σxy
Cov (X , Y )
ρ= p =
Var (X )Var (Y ) σx σy

For unclassified Data


P P P
XY− X n Y
q P  P 
n X 2 − ( X )2 n Y 2 − ( Y )2
P P

For Classified Data


PP P
X Y fxy − X fx
n Y fy
q P  P 
n X 2 fx − ( X fx )2 n Y 2 fy − ( Y fy )2
P P

VRNath, JNTU KAKINADA RM-STATS-2016


Least Squares Method
Regression
Correlation
Introduction to R-Software and R-Studio
Testing of the Correlation Coefficient
Simple Linear Regression
Linear Regression and ANOVA

Correlation Coefficient
Properties

Bounded
It is symmetric and bounded by -1 and +1.
1 Near +1 means strong positive correlation
2 Near -1 means strong negative correlation
3 Near +0 means weak positive correlation
4 Near -0 means weak negative correlation

Invariance
If U=a X+b and V=c Y+d then
a.c
Corr (X , Y ) = Corr (U, V )
|a|.|c|

VRNath, JNTU KAKINADA RM-STATS-2016


Least Squares Method
Regression
Correlation
Introduction to R-Software and R-Studio
Testing of the Correlation Coefficient
Simple Linear Regression
Linear Regression and ANOVA

Pearson Coefficient
Doing with R

Solving with R-Software


> height
[1] 150 155 158 160 165 168 170
> weight
[1] 48 58 57 62 67 70 72
> cov(height,weight)
[1] 59.83333
> correlation =
cov(height,weight)/sqrt(var(height)*var(weight))
> correlation
[1] 0.9833692

Conclusion
Strong Positive Correlation
VRNath, JNTU KAKINADA RM-STATS-2016
Least Squares Method
Regression
Correlation
Introduction to R-Software and R-Studio
Testing of the Correlation Coefficient
Simple Linear Regression
Linear Regression and ANOVA

Rank Correlation
Spearman Rank Correlation

The Method
1 Assign ranks from smallest to largest (or otherwise)
2 If there are ties repeat the rank
3
P PP
Rx Ry − Rxn Ry
k = rh i h i
n Rx2 − ( Rx )2 n Ry2 − ( Ry )2
P P P P

For non-repeated ranks


If di is the difference in ranks
P 2
6 di
k =1− 
n n2 − 1
VRNath, JNTU KAKINADA RM-STATS-2016
Least Squares Method
Regression
Correlation
Introduction to R-Software and R-Studio
Testing of the Correlation Coefficient
Simple Linear Regression
Linear Regression and ANOVA

Spearman Rank Correlation


Doing with R

Solving with R-Software


> Rx=rank(height, ties.method= "first");Rx
[1] 1 2 3 4 5 6 7
> Ry=rank(weight, ties.method= "first");Ry
[1] 1 3 2 4 5 6 7
> d=Rx-Ry;d
[1] 0 -1 1 0 0 0 0
> n=length(Rx)
> rankcorr=1-6*sum(d2̂)/(n*(n2̂-1));rankcorr
[1] 0.9642857

Remark
Approximately same as Pearson coeffient. It is simple and
robust.
VRNath, JNTU KAKINADA RM-STATS-2016
Least Squares Method
Regression
Correlation
Introduction to R-Software and R-Studio
Testing of the Correlation Coefficient
Simple Linear Regression
Linear Regression and ANOVA

Outline

1 Regression
Introduction
2 Introduction to R-Software and R-Studio
Windows in R Studio
Commands in R
Plotting by using R
House Prices Problem without Explanatory Variables
3 Simple Linear Regression
Least Squares Method
Correlation
Testing of the Correlation Coefficient
Linear Regression and ANOVA

VRNath, JNTU KAKINADA RM-STATS-2016


Least Squares Method
Regression
Correlation
Introduction to R-Software and R-Studio
Testing of the Correlation Coefficient
Simple Linear Regression
Linear Regression and ANOVA

Test of Correlation Coefficient

t-statistic
1 H0 : ρ = 0, H1 : ρ > 0
2 Compute r
n−2
tc = |r |
1 − r2
3 Reject the hypothesis if tc > tα

VRNath, JNTU KAKINADA RM-STATS-2016


Least Squares Method
Regression
Correlation
Introduction to R-Software and R-Studio
Testing of the Correlation Coefficient
Simple Linear Regression
Linear Regression and ANOVA

Testing Correlation
Doing with R

> height
[1] 150 155 158 160 165 168 170
>n=length(height); weight
[1] 48 58 57 62 67 70 72
>
r=cov(height,weight)/sqrt(var(height)*var(weight));r
[1] 0.9833692
> tc=r*sqrt((n-2)/(1-r2̂));tc
[1] 12.10720
> qt(0.995,n-2)
[1] 4.032143
> if(tc>qt(0.995,n-2))print("Significant")
else print("no correlation")
[1] "Significant Correlation"
VRNath, JNTU KAKINADA RM-STATS-2016
Least Squares Method
Regression
Correlation
Introduction to R-Software and R-Studio
Testing of the Correlation Coefficient
Simple Linear Regression
Linear Regression and ANOVA

Outline

1 Regression
Introduction
2 Introduction to R-Software and R-Studio
Windows in R Studio
Commands in R
Plotting by using R
House Prices Problem without Explanatory Variables
3 Simple Linear Regression
Least Squares Method
Correlation
Testing of the Correlation Coefficient
Linear Regression and ANOVA

VRNath, JNTU KAKINADA RM-STATS-2016


Least Squares Method
Regression
Correlation
Introduction to R-Software and R-Studio
Testing of the Correlation Coefficient
Simple Linear Regression
Linear Regression and ANOVA

The method of Least Squares


Linear Model

Best Fitting Line


ŷ = a + b x, a and b are the estimates of intercept and slope
S
parameters b = Sxy xx
and a = ȳ − b x̄

Doing with R
> mat<-c(39,43,21,64,57,47,28,75,34,52)
> cal<-c(65,78,52,82,92,89,73,98,56,75)
> sxy=cov(mat,cal)
> b=sxy/var(mat);b
[1] 0.7655618
> a=mean(cal)-b*mean(mat);a
[1] 40.78416

VRNath, JNTU KAKINADA RM-STATS-2016


Least Squares Method
Regression
Correlation
Introduction to R-Software and R-Studio
Testing of the Correlation Coefficient
Simple Linear Regression
Linear Regression and ANOVA

Analysis of Variance
One way classification

Salient Points
1 Used to compare the means of several groups
2 Simple when compared to C2k two mean problems
3 Null hypothesis is all means are same
H0 : µ1 = µ2 = · · · = µk
4 Alternate hypothesis is atleast two means are different
H1 : µi 6= µj , i 6= j
5 Groups are formed with factors and levels

VRNath, JNTU KAKINADA RM-STATS-2016


Least Squares Method
Regression
Correlation
Introduction to R-Software and R-Studio
Testing of the Correlation Coefficient
Simple Linear Regression
Linear Regression and ANOVA

Analysis of Variance
One Way

The Method
T= ki=1 nj=1
P P i
1 Xij
2
2 Correction Factor (CF) = Tn
 P 2  P 2
X Xkj
3 SSR= n1 1j + · · · + nk − CF
Pk Pni
i=1 j=1 Xij2
4 TSS= n − CF
5 SSE = TSS-SSE
6 DOF for SSR = k-1
7 DOF for TSS = n-1
SS
8 MS = DOF

VRNath, JNTU KAKINADA RM-STATS-2016


Least Squares Method
Regression
Correlation
Introduction to R-Software and R-Studio
Testing of the Correlation Coefficient
Simple Linear Regression
Linear Regression and ANOVA

Analysis of Variance
One Way Table

One Table
Source SS DOF MS F
Rows SSR r-1 SSR/(r-1) MSR/MSE
Error SSE n-r SSE/(n-r)
Total SST n-1

VRNath, JNTU KAKINADA RM-STATS-2016

You might also like