Search This Blog

Sunday, March 10, 2019

Curvilinear regression in R: a parabolic-model example

Simple linear regression (SLR) and multiple linear regression (MLR) analysis is frequently applied when modeling data. If your visual or statistical analysis during model building suggests
a relationship that is non-linear, you may want to try curvilinear modeling (polynomial modeling).
R programming for SLRMLR and curvilinear regression (CLR) analysis is very similar. CLR model building in R is done in four basis steps:
  1. Structure your data in a data frame, for example, via import from a CSV file.
  2. Calculate the desired powers for the independent variable(s) and add them to the data frame. 
  3. Derive the curvilinear model by using the lm() function.
  4. Review the results displayed with the summary() function.
In the case of a parabolic model (quadratic model), only square values need to be calculated and included in the data frame at step 2.

The derived model—if found to satisfactorily fit the data—can then be applied to estimate new values for the dependent variable (response values) by calling the predict() function, which needs to receive a data frame object with new values for the independent variables.

Find the tutorial-style documents and associated CSV files with example data for SLR, MLR and CLR modeling (parabolic modeling) with R in the following.

SLR modeling

Document: www.axeleratio.com/math/comp/linreg/linregways.pdf   
Data: www.axeleratio.com/math/comp/linreg/csv/woodward71.csv
 

MLR modeling

Document: www.axeleratio.com/math/comp/linreg/multilinreg.pdf   
Data: www.axeleratio.com/math/comp/linreg/csv/woodward82.csv

CLR modeling (parabolic modeling example)

Document: www.axeleratio.com/math/comp/linreg/curvilinreg.pdf   
Data:www.axeleratio.com/math/comp/linreg/csv/woodward83.csv



Example of curvilinear model building in R: details are given in my document “How to perform curvilinear regression analysis with R


Keywords: statictical analysis, linear modeling, non-linear modeling, machine learning, testing relationships, model building, R programming.

Tuesday, March 5, 2019

Multiple linear regression in the R software environment

Carrying out multiple linear regression (MLR) in the freely available R software environment is not very different from performing simple linear regression (SLR) in R. The same basic steps can be followed when working on a MLR problem:
  1. Structure your data in a data frame, for example, via import from a CSV file.
  2. Derive the linear model by using the lm() function.
  3. Review the results displayed with the summary() function.
The derived model can then be applied to estimate new values for the dependent variable (response values) by calling the predict() function, which needs to receive a data frame object with new values for the independent variables.

Data and code to get started with MLR in R:


CSV file with sample dataset at
www.axeleratio.com/math/comp/linreg/csv/woodward82.csv.

Tutorial-style document with title “How to perform multiple linear regression analysis with R” at
www.axeleratio.com/math/comp/linreg/multilinreg.pdf.

MLR in R using the woodward82.csv dataset as explained in the articleHow to perform multiple linear regression analysis