SlideShare a Scribd company logo
1 of 1
Download to read offline
## Simple Linear Regression With R ##
#One should have the basic concept in statistics to understand this and the different terms associated with this work
sheet.
# Here we will use an inbuilt data from R called mtcars, you can use external data also
?mtcars # First we understand what the data set is.
data(mtcars) # to import the data set mtcars into R
names(mtcars) #See the names of the variables in the data set mtcars
attach(mtcars) #attach the data set mtcars to current workspace
plot(cyl, hp,main = "Scatterplot of Number of cylinders & Gross horsepower") #scatterplot of the data
cor(cyl, hp) #to find the correlation between two variables
fix(mtcars) #to change the data set if there is any mistake
?lm # Function for fiting linear model
reg1<-lm(hp ~ cyl) # to get the regression equation of a bivariate data i.e. hp and cyl, where we are predicting the
horse power using the variable cylinders, hp=y and cyl=x
reg1 # to see the object reg1
summary(reg1) # gives the whole summary for the regression equation
#We get the summary for residuals or errors i.e the minimum, Q1, Q2 or median, Q3 and Q4 or maximum
#Estimate gives the regression model or equation which is y = -51.054 + 31.958x
#Standard Error of the intercept and slope(the independent variable x1)
#T value is given for hypothesis test that the intercept and slope is zero = 0, test that intercept is 0 is often not
of interest.
#Pr - Probability is given for the intercept and slope is zero = 0, the value for cyl is 3.48e-09, the standard cut
off is .05 which means that Cyl is a good predictor for hp
#Residual standard error - measure of variation of individual observations around the regression line, this is the
same as the square root of the mean squared error or it is e = y - yhat
#R-square is 0.693 which means 69% of the variation in dependent variable (y) is explained or predicted by the
independent variable (x).
#Adjusted R-Square
#F-statistics is the F ratio for hypothesis test that all the coefficents in the model are 0. This test is used to
see if Xi(all the independent variables or variable) is a significant explanatory variable of dependent variable (y).
attributes(reg1) #we can see the list of attributes associated with the object reg1
reg1$rank # we can see each attributes of the object
reg1$coefficients # We ask for the coefficient of the model reg1
abline(reg1, lwd = 3, col = 2) # ploting the regression line on graph
confint(reg1) # to see the confidence interval
confint(reg1, level = 0.99) # to see the confidence interval at 99% significance
predict(reg1) # Prediction of Hp based on no. of cyl
predict(reg1, interval = "prediction") # Confidence interval for predicted values
anova(reg1) #ANOVA table for the regression model
sqrt(1491) # find the square root of Mean square of residuals = residual standard error
rm(list = ls()) # clear all the data set imported in to R
## By Jerome Gomes ##

More Related Content

What's hot

Piecewise and Step Functions
Piecewise and Step FunctionsPiecewise and Step Functions
Piecewise and Step Functionsktini
 
Exponents Rules
Exponents RulesExponents Rules
Exponents RulesBigPassy2
 
Nonlinear Fitting Lecture
Nonlinear Fitting LectureNonlinear Fitting Lecture
Nonlinear Fitting Lectureouopened
 
STACK ( LIFO STRUCTURE) - Data Structure
STACK ( LIFO STRUCTURE) - Data StructureSTACK ( LIFO STRUCTURE) - Data Structure
STACK ( LIFO STRUCTURE) - Data StructureYaksh Jethva
 
Engineering Mechanics categories of equilibrium in three dimensions
Engineering Mechanics categories of equilibrium in three dimensionsEngineering Mechanics categories of equilibrium in three dimensions
Engineering Mechanics categories of equilibrium in three dimensionsRajayogan Palanichamy
 
Engineering Mechanics categories of equilibrium in two dimensions
Engineering Mechanics categories of equilibrium in two dimensionsEngineering Mechanics categories of equilibrium in two dimensions
Engineering Mechanics categories of equilibrium in two dimensionsRajayogan Palanichamy
 
Wk 6 part 2 non linearites and non linearization april 05
Wk 6 part 2 non linearites and non linearization april 05Wk 6 part 2 non linearites and non linearization april 05
Wk 6 part 2 non linearites and non linearization april 05Charlton Inao
 
Gaussseidel
GaussseidelGaussseidel
Gaussseideluis
 

What's hot (13)

Piecewise and Step Functions
Piecewise and Step FunctionsPiecewise and Step Functions
Piecewise and Step Functions
 
Introduction To Stack
Introduction To StackIntroduction To Stack
Introduction To Stack
 
Exponents Rules
Exponents RulesExponents Rules
Exponents Rules
 
Nonlinear Fitting Lecture
Nonlinear Fitting LectureNonlinear Fitting Lecture
Nonlinear Fitting Lecture
 
STACK ( LIFO STRUCTURE) - Data Structure
STACK ( LIFO STRUCTURE) - Data StructureSTACK ( LIFO STRUCTURE) - Data Structure
STACK ( LIFO STRUCTURE) - Data Structure
 
M correlation 1
M correlation 1M correlation 1
M correlation 1
 
Engineering Mechanics categories of equilibrium in three dimensions
Engineering Mechanics categories of equilibrium in three dimensionsEngineering Mechanics categories of equilibrium in three dimensions
Engineering Mechanics categories of equilibrium in three dimensions
 
Engineering Mechanics categories of equilibrium in two dimensions
Engineering Mechanics categories of equilibrium in two dimensionsEngineering Mechanics categories of equilibrium in two dimensions
Engineering Mechanics categories of equilibrium in two dimensions
 
Assessment 1
Assessment 1Assessment 1
Assessment 1
 
Stack project
Stack projectStack project
Stack project
 
Wk 6 part 2 non linearites and non linearization april 05
Wk 6 part 2 non linearites and non linearization april 05Wk 6 part 2 non linearites and non linearization april 05
Wk 6 part 2 non linearites and non linearization april 05
 
Stacks
StacksStacks
Stacks
 
Gaussseidel
GaussseidelGaussseidel
Gaussseidel
 

Viewers also liked

Meet Mercy
Meet MercyMeet Mercy
Meet Mercyfranzena
 
Innovation og disruption i 2016
Innovation og disruption i 2016Innovation og disruption i 2016
Innovation og disruption i 2016Jonathan Løw
 
Company overview 2016 february
Company overview 2016 februaryCompany overview 2016 february
Company overview 2016 februaryFactstories
 
Sinaunang bagay,upload
Sinaunang bagay,uploadSinaunang bagay,upload
Sinaunang bagay,uploadAliyah Fajardo
 
ParadigmNEXT Capabilities Deck
ParadigmNEXT Capabilities DeckParadigmNEXT Capabilities Deck
ParadigmNEXT Capabilities DeckAmanda Fernandez
 
презентация к викторине
презентация к викторинепрезентация к викторине
презентация к викторинеziomka
 
описательный лист
описательный листописательный лист
описательный листziomka
 
презентация Microsoft power point
презентация Microsoft power pointпрезентация Microsoft power point
презентация Microsoft power pointziomka
 
Tuberkuloza-Tuberculosis
Tuberkuloza-TuberculosisTuberkuloza-Tuberculosis
Tuberkuloza-TuberculosisDejana Metlar
 
Une communication créative? Découvrez comment vous creuser la tête. Conférenc...
Une communication créative? Découvrez comment vous creuser la tête. Conférenc...Une communication créative? Découvrez comment vous creuser la tête. Conférenc...
Une communication créative? Découvrez comment vous creuser la tête. Conférenc...Sarah Thielens
 
2nd qtr 15 writing a two point outline
2nd qtr 15 writing a two point outline2nd qtr 15 writing a two point outline
2nd qtr 15 writing a two point outlineShirley Sison
 
A.MARWA REVOLT QNET: اسرار النجاح
A.MARWA REVOLT QNET: اسرار النجاح   A.MARWA REVOLT QNET: اسرار النجاح
A.MARWA REVOLT QNET: اسرار النجاح Abidi Marwa Qnet
 
Averting a biodiversity crisis: AmphibiaWeb addresses the new Bsal threat
Averting a biodiversity crisis: AmphibiaWeb addresses the new Bsal threatAverting a biodiversity crisis: AmphibiaWeb addresses the new Bsal threat
Averting a biodiversity crisis: AmphibiaWeb addresses the new Bsal threatmgray11
 

Viewers also liked (16)

Meet Mercy
Meet MercyMeet Mercy
Meet Mercy
 
Innovation og disruption i 2016
Innovation og disruption i 2016Innovation og disruption i 2016
Innovation og disruption i 2016
 
Company overview 2016 february
Company overview 2016 februaryCompany overview 2016 february
Company overview 2016 february
 
Sinaunang bagay,upload
Sinaunang bagay,uploadSinaunang bagay,upload
Sinaunang bagay,upload
 
ParadigmNEXT Capabilities Deck
ParadigmNEXT Capabilities DeckParadigmNEXT Capabilities Deck
ParadigmNEXT Capabilities Deck
 
презентация к викторине
презентация к викторинепрезентация к викторине
презентация к викторине
 
описательный лист
описательный листописательный лист
описательный лист
 
презентация Microsoft power point
презентация Microsoft power pointпрезентация Microsoft power point
презентация Microsoft power point
 
Tuberkuloza-Tuberculosis
Tuberkuloza-TuberculosisTuberkuloza-Tuberculosis
Tuberkuloza-Tuberculosis
 
Tobacco use and dependence
Tobacco use and dependenceTobacco use and dependence
Tobacco use and dependence
 
Une communication créative? Découvrez comment vous creuser la tête. Conférenc...
Une communication créative? Découvrez comment vous creuser la tête. Conférenc...Une communication créative? Découvrez comment vous creuser la tête. Conférenc...
Une communication créative? Découvrez comment vous creuser la tête. Conférenc...
 
2nd qtr 15 writing a two point outline
2nd qtr 15 writing a two point outline2nd qtr 15 writing a two point outline
2nd qtr 15 writing a two point outline
 
How To Make An Outline
How To Make An OutlineHow To Make An Outline
How To Make An Outline
 
A.MARWA REVOLT QNET: اسرار النجاح
A.MARWA REVOLT QNET: اسرار النجاح   A.MARWA REVOLT QNET: اسرار النجاح
A.MARWA REVOLT QNET: اسرار النجاح
 
Outlining
OutliningOutlining
Outlining
 
Averting a biodiversity crisis: AmphibiaWeb addresses the new Bsal threat
Averting a biodiversity crisis: AmphibiaWeb addresses the new Bsal threatAverting a biodiversity crisis: AmphibiaWeb addresses the new Bsal threat
Averting a biodiversity crisis: AmphibiaWeb addresses the new Bsal threat
 

Similar to Simple Linear Regression with R

Regression diagnostics - Checking if linear regression assumptions are violat...
Regression diagnostics - Checking if linear regression assumptions are violat...Regression diagnostics - Checking if linear regression assumptions are violat...
Regression diagnostics - Checking if linear regression assumptions are violat...Jerome Gomes
 
Regression kriging
Regression krigingRegression kriging
Regression krigingFAO
 
4.3 Fitting Linear Models to Data
4.3 Fitting Linear Models to Data4.3 Fitting Linear Models to Data
4.3 Fitting Linear Models to Datasmiller5
 
14. Query Optimization in DBMS
14. Query Optimization in DBMS14. Query Optimization in DBMS
14. Query Optimization in DBMSkoolkampus
 
Predicting US house prices using Multiple Linear Regression in R
Predicting US house prices using Multiple Linear Regression in RPredicting US house prices using Multiple Linear Regression in R
Predicting US house prices using Multiple Linear Regression in RSotiris Baratsas
 
Relational operation final
Relational operation finalRelational operation final
Relational operation finalStudent
 
2 data structure in R
2 data structure in R2 data structure in R
2 data structure in Rnaroranisha
 
Relational Algebra Ch6 (Navathe 4th edition)/ Ch7 (Navathe 3rd edition)
Relational Algebra Ch6 (Navathe 4th edition)/ Ch7 (Navathe 3rd edition)Relational Algebra Ch6 (Navathe 4th edition)/ Ch7 (Navathe 3rd edition)
Relational Algebra Ch6 (Navathe 4th edition)/ Ch7 (Navathe 3rd edition)Raj vardhan
 
Prediction of house price using multiple regression
Prediction of house price using multiple regressionPrediction of house price using multiple regression
Prediction of house price using multiple regressionvinovk
 
Linear Regression
Linear Regression Linear Regression
Linear Regression Rupak Roy
 
Module 2-2.ppt
Module 2-2.pptModule 2-2.ppt
Module 2-2.pptShylaja40
 

Similar to Simple Linear Regression with R (20)

Regression diagnostics - Checking if linear regression assumptions are violat...
Regression diagnostics - Checking if linear regression assumptions are violat...Regression diagnostics - Checking if linear regression assumptions are violat...
Regression diagnostics - Checking if linear regression assumptions are violat...
 
Regression kriging
Regression krigingRegression kriging
Regression kriging
 
1. linear model, inference, prediction
1. linear model, inference, prediction1. linear model, inference, prediction
1. linear model, inference, prediction
 
4.3 Fitting Linear Models to Data
4.3 Fitting Linear Models to Data4.3 Fitting Linear Models to Data
4.3 Fitting Linear Models to Data
 
working with python
working with pythonworking with python
working with python
 
NCCU: Statistics in the Criminal Justice System, R basics and Simulation - Pr...
NCCU: Statistics in the Criminal Justice System, R basics and Simulation - Pr...NCCU: Statistics in the Criminal Justice System, R basics and Simulation - Pr...
NCCU: Statistics in the Criminal Justice System, R basics and Simulation - Pr...
 
14. Query Optimization in DBMS
14. Query Optimization in DBMS14. Query Optimization in DBMS
14. Query Optimization in DBMS
 
R9
R9R9
R9
 
Predicting US house prices using Multiple Linear Regression in R
Predicting US house prices using Multiple Linear Regression in RPredicting US house prices using Multiple Linear Regression in R
Predicting US house prices using Multiple Linear Regression in R
 
Linear Regression.pptx
Linear Regression.pptxLinear Regression.pptx
Linear Regression.pptx
 
354 ch6
354 ch6354 ch6
354 ch6
 
Relational operation final
Relational operation finalRelational operation final
Relational operation final
 
Assignment in regression1
Assignment in regression1Assignment in regression1
Assignment in regression1
 
2 data structure in R
2 data structure in R2 data structure in R
2 data structure in R
 
Relational Algebra Ch6 (Navathe 4th edition)/ Ch7 (Navathe 3rd edition)
Relational Algebra Ch6 (Navathe 4th edition)/ Ch7 (Navathe 3rd edition)Relational Algebra Ch6 (Navathe 4th edition)/ Ch7 (Navathe 3rd edition)
Relational Algebra Ch6 (Navathe 4th edition)/ Ch7 (Navathe 3rd edition)
 
Prediction of house price using multiple regression
Prediction of house price using multiple regressionPrediction of house price using multiple regression
Prediction of house price using multiple regression
 
Curvefitting
CurvefittingCurvefitting
Curvefitting
 
Linear Regression
Linear Regression Linear Regression
Linear Regression
 
Module 2-2.ppt
Module 2-2.pptModule 2-2.ppt
Module 2-2.ppt
 
Linear Regression
Linear RegressionLinear Regression
Linear Regression
 

Recently uploaded

How is Real-Time Analytics Different from Traditional OLAP?
How is Real-Time Analytics Different from Traditional OLAP?How is Real-Time Analytics Different from Traditional OLAP?
How is Real-Time Analytics Different from Traditional OLAP?sonikadigital1
 
Strategic CX: A Deep Dive into Voice of the Customer Insights for Clarity
Strategic CX: A Deep Dive into Voice of the Customer Insights for ClarityStrategic CX: A Deep Dive into Voice of the Customer Insights for Clarity
Strategic CX: A Deep Dive into Voice of the Customer Insights for ClarityAggregage
 
The Universal GTM - how we design GTM and dataLayer
The Universal GTM - how we design GTM and dataLayerThe Universal GTM - how we design GTM and dataLayer
The Universal GTM - how we design GTM and dataLayerPavel Šabatka
 
AI for Sustainable Development Goals (SDGs)
AI for Sustainable Development Goals (SDGs)AI for Sustainable Development Goals (SDGs)
AI for Sustainable Development Goals (SDGs)Data & Analytics Magazin
 
SFBA Splunk Usergroup meeting March 13, 2024
SFBA Splunk Usergroup meeting March 13, 2024SFBA Splunk Usergroup meeting March 13, 2024
SFBA Splunk Usergroup meeting March 13, 2024Becky Burwell
 
Mapping the pubmed data under different suptopics using NLP.pptx
Mapping the pubmed data under different suptopics using NLP.pptxMapping the pubmed data under different suptopics using NLP.pptx
Mapping the pubmed data under different suptopics using NLP.pptxVenkatasubramani13
 
ChistaDATA Real-Time DATA Analytics Infrastructure
ChistaDATA Real-Time DATA Analytics InfrastructureChistaDATA Real-Time DATA Analytics Infrastructure
ChistaDATA Real-Time DATA Analytics Infrastructuresonikadigital1
 
Persuasive E-commerce, Our Biased Brain @ Bikkeldag 2024
Persuasive E-commerce, Our Biased Brain @ Bikkeldag 2024Persuasive E-commerce, Our Biased Brain @ Bikkeldag 2024
Persuasive E-commerce, Our Biased Brain @ Bikkeldag 2024Guido X Jansen
 
Virtuosoft SmartSync Product Introduction
Virtuosoft SmartSync Product IntroductionVirtuosoft SmartSync Product Introduction
Virtuosoft SmartSync Product Introductionsanjaymuralee1
 
MEASURES OF DISPERSION I BSc Botany .ppt
MEASURES OF DISPERSION I BSc Botany .pptMEASURES OF DISPERSION I BSc Botany .ppt
MEASURES OF DISPERSION I BSc Botany .pptaigil2
 
Master's Thesis - Data Science - Presentation
Master's Thesis - Data Science - PresentationMaster's Thesis - Data Science - Presentation
Master's Thesis - Data Science - PresentationGiorgio Carbone
 
CI, CD -Tools to integrate without manual intervention
CI, CD -Tools to integrate without manual interventionCI, CD -Tools to integrate without manual intervention
CI, CD -Tools to integrate without manual interventionajayrajaganeshkayala
 
TINJUAN PEMROSESAN TRANSAKSI DAN ERP.pptx
TINJUAN PEMROSESAN TRANSAKSI DAN ERP.pptxTINJUAN PEMROSESAN TRANSAKSI DAN ERP.pptx
TINJUAN PEMROSESAN TRANSAKSI DAN ERP.pptxDwiAyuSitiHartinah
 
Cash Is Still King: ATM market research '2023
Cash Is Still King: ATM market research '2023Cash Is Still King: ATM market research '2023
Cash Is Still King: ATM market research '2023Vladislav Solodkiy
 
YourView Panel Book.pptx YourView Panel Book.
YourView Panel Book.pptx YourView Panel Book.YourView Panel Book.pptx YourView Panel Book.
YourView Panel Book.pptx YourView Panel Book.JasonViviers2
 
5 Ds to Define Data Archiving Best Practices
5 Ds to Define Data Archiving Best Practices5 Ds to Define Data Archiving Best Practices
5 Ds to Define Data Archiving Best PracticesDataArchiva
 
Elements of language learning - an analysis of how different elements of lang...
Elements of language learning - an analysis of how different elements of lang...Elements of language learning - an analysis of how different elements of lang...
Elements of language learning - an analysis of how different elements of lang...PrithaVashisht1
 

Recently uploaded (17)

How is Real-Time Analytics Different from Traditional OLAP?
How is Real-Time Analytics Different from Traditional OLAP?How is Real-Time Analytics Different from Traditional OLAP?
How is Real-Time Analytics Different from Traditional OLAP?
 
Strategic CX: A Deep Dive into Voice of the Customer Insights for Clarity
Strategic CX: A Deep Dive into Voice of the Customer Insights for ClarityStrategic CX: A Deep Dive into Voice of the Customer Insights for Clarity
Strategic CX: A Deep Dive into Voice of the Customer Insights for Clarity
 
The Universal GTM - how we design GTM and dataLayer
The Universal GTM - how we design GTM and dataLayerThe Universal GTM - how we design GTM and dataLayer
The Universal GTM - how we design GTM and dataLayer
 
AI for Sustainable Development Goals (SDGs)
AI for Sustainable Development Goals (SDGs)AI for Sustainable Development Goals (SDGs)
AI for Sustainable Development Goals (SDGs)
 
SFBA Splunk Usergroup meeting March 13, 2024
SFBA Splunk Usergroup meeting March 13, 2024SFBA Splunk Usergroup meeting March 13, 2024
SFBA Splunk Usergroup meeting March 13, 2024
 
Mapping the pubmed data under different suptopics using NLP.pptx
Mapping the pubmed data under different suptopics using NLP.pptxMapping the pubmed data under different suptopics using NLP.pptx
Mapping the pubmed data under different suptopics using NLP.pptx
 
ChistaDATA Real-Time DATA Analytics Infrastructure
ChistaDATA Real-Time DATA Analytics InfrastructureChistaDATA Real-Time DATA Analytics Infrastructure
ChistaDATA Real-Time DATA Analytics Infrastructure
 
Persuasive E-commerce, Our Biased Brain @ Bikkeldag 2024
Persuasive E-commerce, Our Biased Brain @ Bikkeldag 2024Persuasive E-commerce, Our Biased Brain @ Bikkeldag 2024
Persuasive E-commerce, Our Biased Brain @ Bikkeldag 2024
 
Virtuosoft SmartSync Product Introduction
Virtuosoft SmartSync Product IntroductionVirtuosoft SmartSync Product Introduction
Virtuosoft SmartSync Product Introduction
 
MEASURES OF DISPERSION I BSc Botany .ppt
MEASURES OF DISPERSION I BSc Botany .pptMEASURES OF DISPERSION I BSc Botany .ppt
MEASURES OF DISPERSION I BSc Botany .ppt
 
Master's Thesis - Data Science - Presentation
Master's Thesis - Data Science - PresentationMaster's Thesis - Data Science - Presentation
Master's Thesis - Data Science - Presentation
 
CI, CD -Tools to integrate without manual intervention
CI, CD -Tools to integrate without manual interventionCI, CD -Tools to integrate without manual intervention
CI, CD -Tools to integrate without manual intervention
 
TINJUAN PEMROSESAN TRANSAKSI DAN ERP.pptx
TINJUAN PEMROSESAN TRANSAKSI DAN ERP.pptxTINJUAN PEMROSESAN TRANSAKSI DAN ERP.pptx
TINJUAN PEMROSESAN TRANSAKSI DAN ERP.pptx
 
Cash Is Still King: ATM market research '2023
Cash Is Still King: ATM market research '2023Cash Is Still King: ATM market research '2023
Cash Is Still King: ATM market research '2023
 
YourView Panel Book.pptx YourView Panel Book.
YourView Panel Book.pptx YourView Panel Book.YourView Panel Book.pptx YourView Panel Book.
YourView Panel Book.pptx YourView Panel Book.
 
5 Ds to Define Data Archiving Best Practices
5 Ds to Define Data Archiving Best Practices5 Ds to Define Data Archiving Best Practices
5 Ds to Define Data Archiving Best Practices
 
Elements of language learning - an analysis of how different elements of lang...
Elements of language learning - an analysis of how different elements of lang...Elements of language learning - an analysis of how different elements of lang...
Elements of language learning - an analysis of how different elements of lang...
 

Simple Linear Regression with R

  • 1. ## Simple Linear Regression With R ## #One should have the basic concept in statistics to understand this and the different terms associated with this work sheet. # Here we will use an inbuilt data from R called mtcars, you can use external data also ?mtcars # First we understand what the data set is. data(mtcars) # to import the data set mtcars into R names(mtcars) #See the names of the variables in the data set mtcars attach(mtcars) #attach the data set mtcars to current workspace plot(cyl, hp,main = "Scatterplot of Number of cylinders & Gross horsepower") #scatterplot of the data cor(cyl, hp) #to find the correlation between two variables fix(mtcars) #to change the data set if there is any mistake ?lm # Function for fiting linear model reg1<-lm(hp ~ cyl) # to get the regression equation of a bivariate data i.e. hp and cyl, where we are predicting the horse power using the variable cylinders, hp=y and cyl=x reg1 # to see the object reg1 summary(reg1) # gives the whole summary for the regression equation #We get the summary for residuals or errors i.e the minimum, Q1, Q2 or median, Q3 and Q4 or maximum #Estimate gives the regression model or equation which is y = -51.054 + 31.958x #Standard Error of the intercept and slope(the independent variable x1) #T value is given for hypothesis test that the intercept and slope is zero = 0, test that intercept is 0 is often not of interest. #Pr - Probability is given for the intercept and slope is zero = 0, the value for cyl is 3.48e-09, the standard cut off is .05 which means that Cyl is a good predictor for hp #Residual standard error - measure of variation of individual observations around the regression line, this is the same as the square root of the mean squared error or it is e = y - yhat #R-square is 0.693 which means 69% of the variation in dependent variable (y) is explained or predicted by the independent variable (x). #Adjusted R-Square #F-statistics is the F ratio for hypothesis test that all the coefficents in the model are 0. This test is used to see if Xi(all the independent variables or variable) is a significant explanatory variable of dependent variable (y). attributes(reg1) #we can see the list of attributes associated with the object reg1 reg1$rank # we can see each attributes of the object reg1$coefficients # We ask for the coefficient of the model reg1 abline(reg1, lwd = 3, col = 2) # ploting the regression line on graph confint(reg1) # to see the confidence interval confint(reg1, level = 0.99) # to see the confidence interval at 99% significance predict(reg1) # Prediction of Hp based on no. of cyl predict(reg1, interval = "prediction") # Confidence interval for predicted values anova(reg1) #ANOVA table for the regression model sqrt(1491) # find the square root of Mean square of residuals = residual standard error rm(list = ls()) # clear all the data set imported in to R ## By Jerome Gomes ##