SlideShare a Scribd company logo
Transformations and Polynomial Regression
One of the first steps in the construction of a regression model is to hypothesize
the form of the regression function. We can dramatically expand the scope of our
model by including specially constructed explanatory variables. These include
indicator variables, interaction terms, transformed variables, and higher order
terms. In this tutorial we discuss the inclusion of transformed variables and
higher order terms in your regression models.
A. Transforming Data
When fitting a linear regression model one assumes that there is a linear
relationship between the response variable and each of the explanatory
variables. However, in many situations there may instead be a non-linear
relationship between the variables. This can sometimes be remedied by applying
a suitable transformation to some (or all) of the variables, such as power
transformations or logarithms. In addition, transformations can be used to correct
violations of model assumptions such as constant error variance and normality.
We apply transformations to the original data prior to performing regression. This
is often sufficient to make linear regression models appropriate for the
transformed data.
Ex. Data was collected on the number of academic journals published on the
Internet during the period 1991-1997.
Year 1 2 3 4 5 6 7
Journals 27 36 45 181 306 1093 2459
Note: The years are re-expressed as (year-1990).
Begin by reading in the data and making a scatter plot of year and number of
journals.
> Year = seq(1,7)
> Journals = c(27,36,45,181,306,1093,2459)
> Internet = data.frame(Year,Journals)
> plot(Year,Journals)
The plot indicates that there is a clear nonlinear relationship between the number
of journals and year. Because of the apparent exponential growth in journals, it
appears that taking the logarithm of number of journals may be appropriate
before fitting a simple linear regression model.
We can perform transformations directly in the call to the regression function lm()
as long as we use the ‘as is’ function I(). This is used to inhibit the interpretation
of operators such as "+", "-", "*" and "^" as formula operators, and insure that
they are used as arithmetical operators.
To fit a simple linear regression model using the logarithm of Journals as the
response variable write:
> attach(Internet)
> results = lm(I(log10(Journals)) ~ Year)
> summary(results)
Call:
lm(formula = I(log10(Journals)) ~ Year)
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 0.87690 0.14270 6.145 0.001659 **
Year 0.34555 0.03191 10.829 0.000117 ***
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Residual standard error: 0.1688 on 5 degrees of freedom
Multiple R-squared: 0.9591, Adjusted R-squared: 0.9509
F-statistic: 117.3 on 1 and 5 DF, p-value: 0.0001165
According to the output, the model is given by . . .xy 0.34550.8769)ˆlog(
To make a scatter plot of year and log journals with the regression line overlayed
and a plot of the residuals against year, type:
> plot(Year,I(log10(Journals)))
> abline(results)
> plot(Year,results$res)
The scatter plot of log(journals) and years appears linear and the residual plot
shows no apparent pattern. It appears that a simple linear regression model is
appropriate for the transformed data.
Next, suppose we want to use the model to predict the number of electronic
journals at the end of 1998 (x = 8). To do so we need to first predict the log
number of journals and thereafter transform the results into number of journals.
> coef(results)
(Intercept) Year
0.8769041 0.3455474
> log.yhat = 0.8769041 + 0.3455474*8
> log.yhat
[1] 3.641283
> yhat = 10^log.yhat
> yhat
[1] 4378.076
The predicted number of journals that will be available on-line by the end of 1998
is 4374.
B. Polynomial Regression
Polynomial regression models are useful when there is reason to believe the
relationship between two variables is curvilinear. In a polynomial regression
model of order p the relationship between the explanatory and response variable
is modeled as a pth
order polynomial function.
Ex. Data was collected on the amount of rainfall and the corn yield at a farm
during the period 1890-1927. The data set consists of 37 observations on the
three variables: Year, Yield and Rain.
To read in the data and make a scatter plot, type:
> dat = read.table("C:/W2024/Corn.txt",header=TRUE)
> plot(Rain,Yield)
There exists a clear curvilinear relationship between the variables which appears
to be quadratic. Hence, we can fit a polynomial regression model of order 2.
> results = lm(Yield ~ Rain + I(Rain^2))
> summary(results)
Call:
lm(formula = Yield ~ Rain + I(Rain^2))
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) -5.01467 11.44158 -0.438 0.66387
Rain 6.00428 2.03895 2.945 0.00571 **
I(Rain^2) -0.22936 0.08864 -2.588 0.01397 *
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Residual standard error: 3.763 on 35 degrees of freedom
Multiple R-squared: 0.2967, Adjusted R-squared: 0.2565
F-statistic: 7.382 on 2 and 35 DF, p-value: 0.002115
The fitted model is given by .
Next we make a scatter plot of year and yield overlaying the regression line.
> beta = coef(results)
> beta
(Intercept) Rain I(Rain^2)
-5.0146670 6.0042835 -0.2293639
To plot the polynomial regression function use the following set of commands:
> plot(Rain,Yield)
%Define a vector (6.0, 6.1, 6.2, …..16.9 17.0) covering the range of the
explanatory variable.
> vec = seq(6, 17, by=0.1)
> lines(vec, beta[1]+beta[2]*vec + beta[3]*vec^2, col='red')
The second order polynomial regression model appears to fit the data well.
2
23.000.601.5ˆ xxy

More Related Content

What's hot

Data visualization using R
Data visualization using RData visualization using R
Data visualization using R
Ummiya Mohammedi
 
Regression Analysis and model comparison on the Boston Housing Data
Regression Analysis and model comparison on the Boston Housing DataRegression Analysis and model comparison on the Boston Housing Data
Regression Analysis and model comparison on the Boston Housing Data
Shivaram Prakash
 
Regression Study: Boston Housing
Regression Study: Boston HousingRegression Study: Boston Housing
Regression Study: Boston Housing
Ravish Kalra
 
Multivariable Parametric Modeling of a Greenhouse by Minimizing the Quadratic...
Multivariable Parametric Modeling of a Greenhouse by Minimizing the Quadratic...Multivariable Parametric Modeling of a Greenhouse by Minimizing the Quadratic...
Multivariable Parametric Modeling of a Greenhouse by Minimizing the Quadratic...
TELKOMNIKA JOURNAL
 
X Bar R Charts
X Bar R ChartsX Bar R Charts
X Bar R Charts
ahmad bassiouny
 
Line graphs, slope, and interpreting line graphs
Line graphs, slope, and interpreting line graphs Line graphs, slope, and interpreting line graphs
Line graphs, slope, and interpreting line graphs
Charalee
 
Extrapolation
ExtrapolationExtrapolation
Extrapolationjonathan
 
Capital Works Bundling Potential Model_Concept
Capital Works Bundling Potential Model_ConceptCapital Works Bundling Potential Model_Concept
Capital Works Bundling Potential Model_ConceptJung Oh
 
Finding The Volume of a Fishbowl By Integration.pdf
Finding The Volume of a Fishbowl By Integration.pdfFinding The Volume of a Fishbowl By Integration.pdf
Finding The Volume of a Fishbowl By Integration.pdf
Eleora1
 
Cfa amos
Cfa amosCfa amos
Cfa amos
Le Duc Tien
 
Alam afrizal tambahan
Alam afrizal tambahanAlam afrizal tambahan
Alam afrizal tambahan
Alam Afrizal
 
ELEMENTARY ROW OPERATIONS
ELEMENTARY ROW OPERATIONSELEMENTARY ROW OPERATIONS
ELEMENTARY ROW OPERATIONS
SanaullahMemon10
 
Principal component analysis - application in finance
Principal component analysis - application in financePrincipal component analysis - application in finance
Principal component analysis - application in finance
Igor Hlivka
 
linear Algebra least squares
linear Algebra least squareslinear Algebra least squares
linear Algebra least squares
Noreen14
 
Climate Change in Portugal
Climate Change in PortugalClimate Change in Portugal
Climate Change in Portugal
eurosigdoc acm
 
Least Squares method
Least Squares methodLeast Squares method

What's hot (20)

Extrapolation
ExtrapolationExtrapolation
Extrapolation
 
Isam2_v1_2
Isam2_v1_2Isam2_v1_2
Isam2_v1_2
 
Data visualization using R
Data visualization using RData visualization using R
Data visualization using R
 
Regression Analysis and model comparison on the Boston Housing Data
Regression Analysis and model comparison on the Boston Housing DataRegression Analysis and model comparison on the Boston Housing Data
Regression Analysis and model comparison on the Boston Housing Data
 
Regression Study: Boston Housing
Regression Study: Boston HousingRegression Study: Boston Housing
Regression Study: Boston Housing
 
Multivariable Parametric Modeling of a Greenhouse by Minimizing the Quadratic...
Multivariable Parametric Modeling of a Greenhouse by Minimizing the Quadratic...Multivariable Parametric Modeling of a Greenhouse by Minimizing the Quadratic...
Multivariable Parametric Modeling of a Greenhouse by Minimizing the Quadratic...
 
X Bar R Charts
X Bar R ChartsX Bar R Charts
X Bar R Charts
 
Line graphs, slope, and interpreting line graphs
Line graphs, slope, and interpreting line graphs Line graphs, slope, and interpreting line graphs
Line graphs, slope, and interpreting line graphs
 
Extrapolation
ExtrapolationExtrapolation
Extrapolation
 
Extrapolation
ExtrapolationExtrapolation
Extrapolation
 
Capital Works Bundling Potential Model_Concept
Capital Works Bundling Potential Model_ConceptCapital Works Bundling Potential Model_Concept
Capital Works Bundling Potential Model_Concept
 
Finding The Volume of a Fishbowl By Integration.pdf
Finding The Volume of a Fishbowl By Integration.pdfFinding The Volume of a Fishbowl By Integration.pdf
Finding The Volume of a Fishbowl By Integration.pdf
 
Cfa amos
Cfa amosCfa amos
Cfa amos
 
Alam afrizal tambahan
Alam afrizal tambahanAlam afrizal tambahan
Alam afrizal tambahan
 
ELEMENTARY ROW OPERATIONS
ELEMENTARY ROW OPERATIONSELEMENTARY ROW OPERATIONS
ELEMENTARY ROW OPERATIONS
 
Principal component analysis - application in finance
Principal component analysis - application in financePrincipal component analysis - application in finance
Principal component analysis - application in finance
 
linear Algebra least squares
linear Algebra least squareslinear Algebra least squares
linear Algebra least squares
 
visual aids
visual aidsvisual aids
visual aids
 
Climate Change in Portugal
Climate Change in PortugalClimate Change in Portugal
Climate Change in Portugal
 
Least Squares method
Least Squares methodLeast Squares method
Least Squares method
 

Similar to R9

Exploring Support Vector Regression - Signals and Systems Project
Exploring Support Vector Regression - Signals and Systems ProjectExploring Support Vector Regression - Signals and Systems Project
Exploring Support Vector Regression - Signals and Systems Project
Surya Chandra
 
SupportVectorRegression
SupportVectorRegressionSupportVectorRegression
SupportVectorRegressionDaniel K
 
Six sigma pedagogy
Six sigma pedagogySix sigma pedagogy
Six sigma pedagogy
MallikarjunRaoPanaba
 
Six sigma
Six sigma Six sigma
Regression analysis in excel
Regression analysis in excelRegression analysis in excel
Regression analysis in excel
Awais Salman
 
ARIMA Models - [Lab 3]
ARIMA Models - [Lab 3]ARIMA Models - [Lab 3]
ARIMA Models - [Lab 3]
Theodore Grammatikopoulos
 
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
smiller5
 
The Short-term Swap Rate Models in China
The Short-term Swap Rate Models in ChinaThe Short-term Swap Rate Models in China
Curve_Fitting.pdf
Curve_Fitting.pdfCurve_Fitting.pdf
Curve_Fitting.pdf
Irfan Khan
 
Multiple Regression.ppt
Multiple Regression.pptMultiple Regression.ppt
Multiple Regression.ppt
TanyaWadhwani4
 
Environmental Engineering Assignment Help
Environmental Engineering Assignment HelpEnvironmental Engineering Assignment Help
Environmental Engineering Assignment Help
Matlab Assignment Experts
 
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
 
Regression kriging
Regression krigingRegression kriging
Regression kriging
FAO
 
IEOR 265 Final Paper_Minchao Lin
IEOR 265 Final Paper_Minchao LinIEOR 265 Final Paper_Minchao Lin
IEOR 265 Final Paper_Minchao LinMinchao Lin
 
1 s2.0-0272696386900197-main
1 s2.0-0272696386900197-main1 s2.0-0272696386900197-main
1 s2.0-0272696386900197-main
Zulyy Astutik
 
1 s2.0-0272696386900197-main
1 s2.0-0272696386900197-main1 s2.0-0272696386900197-main
1 s2.0-0272696386900197-main
Zulyy Astutik
 
Exploring Variable Relationships with Scatter Diagram Analysis
Exploring Variable Relationships with Scatter Diagram AnalysisExploring Variable Relationships with Scatter Diagram Analysis
Exploring Variable Relationships with Scatter Diagram Analysis
CIToolkit
 
R programming intro with examples
R programming intro with examplesR programming intro with examples
R programming intro with examples
Dennis
 
IRJET- An Efficient Reverse Converter for the Three Non-Coprime Moduli Set {4...
IRJET- An Efficient Reverse Converter for the Three Non-Coprime Moduli Set {4...IRJET- An Efficient Reverse Converter for the Three Non-Coprime Moduli Set {4...
IRJET- An Efficient Reverse Converter for the Three Non-Coprime Moduli Set {4...
IRJET Journal
 

Similar to R9 (20)

Exploring Support Vector Regression - Signals and Systems Project
Exploring Support Vector Regression - Signals and Systems ProjectExploring Support Vector Regression - Signals and Systems Project
Exploring Support Vector Regression - Signals and Systems Project
 
SupportVectorRegression
SupportVectorRegressionSupportVectorRegression
SupportVectorRegression
 
Six sigma pedagogy
Six sigma pedagogySix sigma pedagogy
Six sigma pedagogy
 
Six sigma
Six sigma Six sigma
Six sigma
 
Regression analysis in excel
Regression analysis in excelRegression analysis in excel
Regression analysis in excel
 
ARIMA Models - [Lab 3]
ARIMA Models - [Lab 3]ARIMA Models - [Lab 3]
ARIMA Models - [Lab 3]
 
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
 
The Short-term Swap Rate Models in China
The Short-term Swap Rate Models in ChinaThe Short-term Swap Rate Models in China
The Short-term Swap Rate Models in China
 
Curve_Fitting.pdf
Curve_Fitting.pdfCurve_Fitting.pdf
Curve_Fitting.pdf
 
Multiple Regression.ppt
Multiple Regression.pptMultiple Regression.ppt
Multiple Regression.ppt
 
Environmental Engineering Assignment Help
Environmental Engineering Assignment HelpEnvironmental Engineering Assignment Help
Environmental Engineering Assignment Help
 
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)
 
Regression kriging
Regression krigingRegression kriging
Regression kriging
 
IEOR 265 Final Paper_Minchao Lin
IEOR 265 Final Paper_Minchao LinIEOR 265 Final Paper_Minchao Lin
IEOR 265 Final Paper_Minchao Lin
 
1 s2.0-0272696386900197-main
1 s2.0-0272696386900197-main1 s2.0-0272696386900197-main
1 s2.0-0272696386900197-main
 
1 s2.0-0272696386900197-main
1 s2.0-0272696386900197-main1 s2.0-0272696386900197-main
1 s2.0-0272696386900197-main
 
Exploring Variable Relationships with Scatter Diagram Analysis
Exploring Variable Relationships with Scatter Diagram AnalysisExploring Variable Relationships with Scatter Diagram Analysis
Exploring Variable Relationships with Scatter Diagram Analysis
 
10.1.1.118.8129
10.1.1.118.812910.1.1.118.8129
10.1.1.118.8129
 
R programming intro with examples
R programming intro with examplesR programming intro with examples
R programming intro with examples
 
IRJET- An Efficient Reverse Converter for the Three Non-Coprime Moduli Set {4...
IRJET- An Efficient Reverse Converter for the Three Non-Coprime Moduli Set {4...IRJET- An Efficient Reverse Converter for the Three Non-Coprime Moduli Set {4...
IRJET- An Efficient Reverse Converter for the Three Non-Coprime Moduli Set {4...
 

More from Pakistan Gum Industries Pvt. Ltd (20)

Transportation management
Transportation  managementTransportation  management
Transportation management
 
Anum alam initial pages. 090
Anum alam initial pages. 090Anum alam initial pages. 090
Anum alam initial pages. 090
 
Airlineres
AirlineresAirlineres
Airlineres
 
Farehalet
FarehaletFarehalet
Farehalet
 
Cv ali final
Cv ali finalCv ali final
Cv ali final
 
Ali hasan
Ali hasanAli hasan
Ali hasan
 
(Resume) tariq pervez
(Resume) tariq pervez(Resume) tariq pervez
(Resume) tariq pervez
 
Graded businessvocabularylist
Graded businessvocabularylistGraded businessvocabularylist
Graded businessvocabularylist
 
Vacation accrued
Vacation accruedVacation accrued
Vacation accrued
 
Sick time
Sick timeSick time
Sick time
 
Blank employee letter
Blank employee letterBlank employee letter
Blank employee letter
 
Mobile advertising final
Mobile advertising finalMobile advertising final
Mobile advertising final
 
Introduction
IntroductionIntroduction
Introduction
 
Final iran
Final iranFinal iran
Final iran
 
Saudi arabia
Saudi arabiaSaudi arabia
Saudi arabia
 
The united nations security council
The united nations security councilThe united nations security council
The united nations security council
 
Presentation 6
Presentation 6Presentation 6
Presentation 6
 
Paper saad niazi
Paper saad niaziPaper saad niazi
Paper saad niazi
 
History of e bay in china
History of e bay in chinaHistory of e bay in china
History of e bay in china
 
Case 1
Case 1Case 1
Case 1
 

Recently uploaded

ESC Beyond Borders _From EU to You_ InfoPack general.pdf
ESC Beyond Borders _From EU to You_ InfoPack general.pdfESC Beyond Borders _From EU to You_ InfoPack general.pdf
ESC Beyond Borders _From EU to You_ InfoPack general.pdf
Fundacja Rozwoju Społeczeństwa Przedsiębiorczego
 
Overview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with MechanismOverview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with Mechanism
DeeptiGupta154
 
1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx
JosvitaDsouza2
 
The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
Delapenabediema
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
siemaillard
 
2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...
Sandy Millin
 
Palestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptxPalestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptx
RaedMohamed3
 
Fish and Chips - have they had their chips
Fish and Chips - have they had their chipsFish and Chips - have they had their chips
Fish and Chips - have they had their chips
GeoBlogs
 
Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345
beazzy04
 
Cambridge International AS A Level Biology Coursebook - EBook (MaryFosbery J...
Cambridge International AS  A Level Biology Coursebook - EBook (MaryFosbery J...Cambridge International AS  A Level Biology Coursebook - EBook (MaryFosbery J...
Cambridge International AS A Level Biology Coursebook - EBook (MaryFosbery J...
AzmatAli747758
 
Operation Blue Star - Saka Neela Tara
Operation Blue Star   -  Saka Neela TaraOperation Blue Star   -  Saka Neela Tara
Operation Blue Star - Saka Neela Tara
Balvir Singh
 
Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
EverAndrsGuerraGuerr
 
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXXPhrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
MIRIAMSALINAS13
 
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup   New Member Orientation and Q&A (May 2024).pdfWelcome to TechSoup   New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
TechSoup
 
Model Attribute Check Company Auto Property
Model Attribute  Check Company Auto PropertyModel Attribute  Check Company Auto Property
Model Attribute Check Company Auto Property
Celine George
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
siemaillard
 
How to Break the cycle of negative Thoughts
How to Break the cycle of negative ThoughtsHow to Break the cycle of negative Thoughts
How to Break the cycle of negative Thoughts
Col Mukteshwar Prasad
 
Chapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptxChapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptx
Mohd Adib Abd Muin, Senior Lecturer at Universiti Utara Malaysia
 
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
EugeneSaldivar
 
The Art Pastor's Guide to Sabbath | Steve Thomason
The Art Pastor's Guide to Sabbath | Steve ThomasonThe Art Pastor's Guide to Sabbath | Steve Thomason
The Art Pastor's Guide to Sabbath | Steve Thomason
Steve Thomason
 

Recently uploaded (20)

ESC Beyond Borders _From EU to You_ InfoPack general.pdf
ESC Beyond Borders _From EU to You_ InfoPack general.pdfESC Beyond Borders _From EU to You_ InfoPack general.pdf
ESC Beyond Borders _From EU to You_ InfoPack general.pdf
 
Overview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with MechanismOverview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with Mechanism
 
1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx
 
The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
 
2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...
 
Palestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptxPalestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptx
 
Fish and Chips - have they had their chips
Fish and Chips - have they had their chipsFish and Chips - have they had their chips
Fish and Chips - have they had their chips
 
Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345
 
Cambridge International AS A Level Biology Coursebook - EBook (MaryFosbery J...
Cambridge International AS  A Level Biology Coursebook - EBook (MaryFosbery J...Cambridge International AS  A Level Biology Coursebook - EBook (MaryFosbery J...
Cambridge International AS A Level Biology Coursebook - EBook (MaryFosbery J...
 
Operation Blue Star - Saka Neela Tara
Operation Blue Star   -  Saka Neela TaraOperation Blue Star   -  Saka Neela Tara
Operation Blue Star - Saka Neela Tara
 
Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
 
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXXPhrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
 
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup   New Member Orientation and Q&A (May 2024).pdfWelcome to TechSoup   New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
 
Model Attribute Check Company Auto Property
Model Attribute  Check Company Auto PropertyModel Attribute  Check Company Auto Property
Model Attribute Check Company Auto Property
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
 
How to Break the cycle of negative Thoughts
How to Break the cycle of negative ThoughtsHow to Break the cycle of negative Thoughts
How to Break the cycle of negative Thoughts
 
Chapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptxChapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptx
 
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
 
The Art Pastor's Guide to Sabbath | Steve Thomason
The Art Pastor's Guide to Sabbath | Steve ThomasonThe Art Pastor's Guide to Sabbath | Steve Thomason
The Art Pastor's Guide to Sabbath | Steve Thomason
 

R9

  • 1. Transformations and Polynomial Regression One of the first steps in the construction of a regression model is to hypothesize the form of the regression function. We can dramatically expand the scope of our model by including specially constructed explanatory variables. These include indicator variables, interaction terms, transformed variables, and higher order terms. In this tutorial we discuss the inclusion of transformed variables and higher order terms in your regression models. A. Transforming Data When fitting a linear regression model one assumes that there is a linear relationship between the response variable and each of the explanatory variables. However, in many situations there may instead be a non-linear relationship between the variables. This can sometimes be remedied by applying a suitable transformation to some (or all) of the variables, such as power transformations or logarithms. In addition, transformations can be used to correct violations of model assumptions such as constant error variance and normality. We apply transformations to the original data prior to performing regression. This is often sufficient to make linear regression models appropriate for the transformed data. Ex. Data was collected on the number of academic journals published on the Internet during the period 1991-1997. Year 1 2 3 4 5 6 7 Journals 27 36 45 181 306 1093 2459 Note: The years are re-expressed as (year-1990). Begin by reading in the data and making a scatter plot of year and number of journals. > Year = seq(1,7) > Journals = c(27,36,45,181,306,1093,2459) > Internet = data.frame(Year,Journals) > plot(Year,Journals)
  • 2. The plot indicates that there is a clear nonlinear relationship between the number of journals and year. Because of the apparent exponential growth in journals, it appears that taking the logarithm of number of journals may be appropriate before fitting a simple linear regression model. We can perform transformations directly in the call to the regression function lm() as long as we use the ‘as is’ function I(). This is used to inhibit the interpretation of operators such as "+", "-", "*" and "^" as formula operators, and insure that they are used as arithmetical operators. To fit a simple linear regression model using the logarithm of Journals as the response variable write: > attach(Internet) > results = lm(I(log10(Journals)) ~ Year) > summary(results) Call: lm(formula = I(log10(Journals)) ~ Year) Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 0.87690 0.14270 6.145 0.001659 ** Year 0.34555 0.03191 10.829 0.000117 *** --- Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 Residual standard error: 0.1688 on 5 degrees of freedom Multiple R-squared: 0.9591, Adjusted R-squared: 0.9509 F-statistic: 117.3 on 1 and 5 DF, p-value: 0.0001165 According to the output, the model is given by . . .xy 0.34550.8769)ˆlog(
  • 3. To make a scatter plot of year and log journals with the regression line overlayed and a plot of the residuals against year, type: > plot(Year,I(log10(Journals))) > abline(results) > plot(Year,results$res) The scatter plot of log(journals) and years appears linear and the residual plot shows no apparent pattern. It appears that a simple linear regression model is appropriate for the transformed data. Next, suppose we want to use the model to predict the number of electronic journals at the end of 1998 (x = 8). To do so we need to first predict the log number of journals and thereafter transform the results into number of journals. > coef(results) (Intercept) Year 0.8769041 0.3455474 > log.yhat = 0.8769041 + 0.3455474*8 > log.yhat [1] 3.641283 > yhat = 10^log.yhat > yhat [1] 4378.076 The predicted number of journals that will be available on-line by the end of 1998 is 4374.
  • 4. B. Polynomial Regression Polynomial regression models are useful when there is reason to believe the relationship between two variables is curvilinear. In a polynomial regression model of order p the relationship between the explanatory and response variable is modeled as a pth order polynomial function. Ex. Data was collected on the amount of rainfall and the corn yield at a farm during the period 1890-1927. The data set consists of 37 observations on the three variables: Year, Yield and Rain. To read in the data and make a scatter plot, type: > dat = read.table("C:/W2024/Corn.txt",header=TRUE) > plot(Rain,Yield) There exists a clear curvilinear relationship between the variables which appears to be quadratic. Hence, we can fit a polynomial regression model of order 2. > results = lm(Yield ~ Rain + I(Rain^2)) > summary(results) Call: lm(formula = Yield ~ Rain + I(Rain^2)) Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) -5.01467 11.44158 -0.438 0.66387 Rain 6.00428 2.03895 2.945 0.00571 ** I(Rain^2) -0.22936 0.08864 -2.588 0.01397 * --- Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
  • 5. Residual standard error: 3.763 on 35 degrees of freedom Multiple R-squared: 0.2967, Adjusted R-squared: 0.2565 F-statistic: 7.382 on 2 and 35 DF, p-value: 0.002115 The fitted model is given by . Next we make a scatter plot of year and yield overlaying the regression line. > beta = coef(results) > beta (Intercept) Rain I(Rain^2) -5.0146670 6.0042835 -0.2293639 To plot the polynomial regression function use the following set of commands: > plot(Rain,Yield) %Define a vector (6.0, 6.1, 6.2, …..16.9 17.0) covering the range of the explanatory variable. > vec = seq(6, 17, by=0.1) > lines(vec, beta[1]+beta[2]*vec + beta[3]*vec^2, col='red') The second order polynomial regression model appears to fit the data well. 2 23.000.601.5ˆ xxy