Book Image

Regression Analysis with R

By : Giuseppe Ciaburro
Book Image

Regression Analysis with R

By: Giuseppe Ciaburro

Overview of this book

Regression analysis is a statistical process which enables prediction of relationships between variables. The predictions are based on the casual effect of one variable upon another. Regression techniques for modeling and analyzing are employed on large set of data in order to reveal hidden relationship among the variables. This book will give you a rundown explaining what regression analysis is, explaining you the process from scratch. The first few chapters give an understanding of what the different types of learning are – supervised and unsupervised, how these learnings differ from each other. We then move to covering the supervised learning in details covering the various aspects of regression analysis. The outline of chapters are arranged in a way that gives a feel of all the steps covered in a data science process – loading the training dataset, handling missing values, EDA on the dataset, transformations and feature engineering, model building, assessing the model fitting and performance, and finally making predictions on unseen datasets. Each chapter starts with explaining the theoretical concepts and once the reader gets comfortable with the theory, we move to the practical examples to support the understanding. The practical examples are illustrated using R code including the different packages in R such as R Stats, Caret and so on. Each chapter is a mix of theory and practical examples. By the end of this book you will know all the concepts and pain-points related to regression analysis, and you will be able to implement your learning in your projects.
Table of Contents (15 chapters)
Title Page
Packt Upsell
Contributors
Preface
Index

Modeling a perfect linear association


So far, we have explored several real cases for which we have searched linear associations, and therefore we have built models of simple linear regression. Next, we tried to analyze the results to confirm the goodness of fit in the simulation of the real system. At this point, it is reasonable to wonder what results of a model perfectly fit a linear system. In this way we will know how to distinguish between a model with a good approximation to what is wrong. In this last case, clearly indicating a nonlinear relationship remains the best solution.

Previously, we said that a simple linear relationship is represented by the following formula:

Here, α and β, represent, respectively, the slope and the intercept with the y axis of the regression line. That being said, we build a dummy system by deciding a priori an intercept and a slope:

x<-seq(from = 1, to = 100, by = 0.1)
y<-2.7*x+6

In this way, we first created an integer vector (x) containing numbers...