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

Association between variables – covariance and correlation


In the previous chapter, we introduced correlation concepts, and it is now necessary to deepen these concepts. This will help us understand how to use this information in advance and find possible relationships between variables. Let's start with a real example: a company at the launch of a new printer model wants to analyze sales at a number of stores to determine the best price. The following table shows the sales of the product in the last month and the sale price for these stores:

Store

SoldItems

Price

Store

SoldItems

Price

Store1

100

60

Store11

145

42

Store2

150

43

Store12

125

47

Store3

130

48

Store13

135

44

Store4

140

45

Store14

105

54

Store5

110

55

Store15

155

39

Store6

160

40

Store16

110

52

Store7

115

53

Store17

130

46

Store8

135

47

Store18

115

51

Store9

120

52

Store19

150

41

Store10

155

42

Store20

159

41

 

So far, we have only introduced the basic concepts without elaborating on them practically. It is now time to process the data in the R environment. The first thing to do is load the data...