Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Regression Analysis with R
Regression Analysis with R

Regression Analysis with R: Design and develop statistical nodes to identify unique relationships within data at scale

Arrow left icon
Profile Icon Giuseppe Ciaburro
Arrow right icon
€18.99 per month
Full star icon Full star icon Full star icon Full star icon Half star icon 4.7 (3 Ratings)
Paperback Jan 2018 422 pages 1st Edition
eBook
€17.99 €26.99
Paperback
€32.99
Subscription
Free Trial
Renews at €18.99p/m
Arrow left icon
Profile Icon Giuseppe Ciaburro
Arrow right icon
€18.99 per month
Full star icon Full star icon Full star icon Full star icon Half star icon 4.7 (3 Ratings)
Paperback Jan 2018 422 pages 1st Edition
eBook
€17.99 €26.99
Paperback
€32.99
Subscription
Free Trial
Renews at €18.99p/m
eBook
€17.99 €26.99
Paperback
€32.99
Subscription
Free Trial
Renews at €18.99p/m

What do you get with a Packt Subscription?

Free for first 7 days. $19.99 p/m after that. Cancel any time!
Product feature icon Unlimited ad-free access to the largest independent learning library in tech. Access this title and thousands more!
Product feature icon 50+ new titles added per month, including many first-to-market concepts and exclusive early access to books as they are being written.
Product feature icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Product feature icon Thousands of reference materials covering every tech concept you need to stay up to date.
Subscribe now
View plans & pricing
Table of content icon View table of contents Preview book icon Preview Book

Regression Analysis with R

Basic Concepts – Simple Linear Regression

In Chapter 1, Getting Started with Regression, we understood the concept of regression through the basic principles that govern its algorithms. Moreover, we were been able to discover the different types of regression that make it a real family of algorithms that can solve the most varied types of problems. In this book, we will learn more about all of them, but for now, let us begin with the basic concepts from the simpler algorithm, as indicated by its name: simple linear regression.

As we will see, simple linear regression is easy to understand but represents the basis of regression techniques; once these concepts are understood, it will be easier for us to address the other types of regression. To begin with, let's take an example of applying linear regression taken from the real world.

Consider some data...

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

Searching linear relationships

In the previous section, we learned that the coefficient of correlation between two quantitative variables X and Y provides information on the existence of a linear relation between the two variables. This index, however, does not allow determining whether it is X that affects Y, if it is Y that affects X, or whether both X and Y are consequences of a phenomenon that affects both of them. Only more knowledge of the problem under study can allow some hypothesis of the dependence of one variable on another.

If a correlation between two variables is not found, it does not necessarily imply that they are independent, because they might have a nonlinear relationship.

Calculating correlation and covariance is a useful way to investigate whether there exists a linear relationship between variables, without the need to assume or fit a specific model...

Least squares regression

In the previous section, we saw an example of simple linear regression, built the model, and now have a brief description of it. Next, we will explain the results in detail. We will get started by introducing the key concepts, with another simple linear regression example; we will just use data in the form of a spreadsheet containing the number of vehicles registered in Italy and the population of the different regions. Using this data we will try to determine the line that best estimates the relationship between the population and number of registered vehicles. We can do this in various different ways; we will begin with the simplest. Previously, we said that a linear relationship is represented by the following formula:

If we have a set of observations in the form (x1, y1), (x2, y2), ... (xn, yn), for each of these pairs we can write an equation of...

Creating a linear regression model

In the previous section, we adopted an algebraic approach to calculating the regression line. More generally, to create a linear regression model, we use the lm() function. This function creates a LinearModel object. The object of class lm has a series of properties that can be immediately viewed by simply clicking on it. These types of objects can be used for residual analysis and regression diagnosis. 

LinearModel is an object comprised of data, model description, diagnostic information, and fitted coefficients for a linear regression.

Models for the lm() function are specified symbolically. In fact, the first argument of the function is an object of class formula. A typical formula object has the following form:

response ~ terms

response represents the (numeric) response vector and terms is a series of terms specifying a linear...

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...

Summary

In this chapter, we introduced regression with the simplest algorithm: simple linear regression. We first described a regression problem and where to fit a regressor, and then provided some intuitions underneath the math formulation. Then, we learned how to tune the model for higher performance, and came to deeply understand every parameter of it. In addition, some tricks were described to lower the complexity and scaling of the approach.

To start, we explored the coefficient of correlation between two quantitative variables X and Y, which provides information on the existence of a linear relation between the two variables. We understood that this coefficient does not allow us to determine whether it is X that affects Y, of whether it is Y that affects X, or whether both X and Y are consequences of a phenomenon that affects both of them. Only more knowledge of the problem...

Left arrow icon Right arrow icon
Download code icon Download Code

Key benefits

  • Implement different regression analysis techniques to solve common problems in data science - from data exploration to dealing with missing values
  • From Simple Linear Regression to Logistic Regression - this book covers all regression techniques and their implementation in R
  • A complete guide to building effective regression models in R and interpreting results from them to make valuable predictions

Description

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.

Who is this book for?

This book is intended for budding data scientists and data analysts who want to implement regression analysis techniques using R. If you are interested in statistics, data science, machine learning and wants to get an easy introduction to the topic, then this book is what you need! Basic understanding of statistics and math will help you to get the most out of the book. Some programming experience with R will also be helpful

What you will learn

  • Get started with the journey of data science using Simple linear regression
  • Deal with interaction, collinearity and other problems using multiple linear regression
  • Understand diagnostics and what to do if the assumptions fail with proper analysis
  • Load your dataset, treat missing values, and plot relationships with exploratory data analysis
  • Develop a perfect model keeping overfitting, under-fitting, and cross-validation into consideration
  • Deal with classification problems by applying Logistic regression
  • Explore other regression techniques – Decision trees, Bagging, and Boosting techniques
  • Learn by getting it all in action with the help of a real world case study.

Product Details

Country selected
Publication date, Length, Edition, Language, ISBN-13
Publication date : Jan 31, 2018
Length: 422 pages
Edition : 1st
Language : English
ISBN-13 : 9781788627306
Category :
Languages :
Concepts :

What do you get with a Packt Subscription?

Free for first 7 days. $19.99 p/m after that. Cancel any time!
Product feature icon Unlimited ad-free access to the largest independent learning library in tech. Access this title and thousands more!
Product feature icon 50+ new titles added per month, including many first-to-market concepts and exclusive early access to books as they are being written.
Product feature icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Product feature icon Thousands of reference materials covering every tech concept you need to stay up to date.
Subscribe now
View plans & pricing

Product Details

Publication date : Jan 31, 2018
Length: 422 pages
Edition : 1st
Language : English
ISBN-13 : 9781788627306
Category :
Languages :
Concepts :

Packt Subscriptions

See our plans and pricing
Modal Close icon
€18.99 billed monthly
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Simple pricing, no contract
€189.99 billed annually
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just €5 each
Feature tick icon Exclusive print discounts
€264.99 billed in 18 months
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just €5 each
Feature tick icon Exclusive print discounts

Frequently bought together


Stars icon
Total 102.97
Data Analysis with R, Second Edition
€32.99
R Data Mining
€36.99
Regression Analysis with R
€32.99
Total 102.97 Stars icon

Table of Contents

10 Chapters
Getting Started with Regression Chevron down icon Chevron up icon
Basic Concepts – Simple Linear Regression Chevron down icon Chevron up icon
More Than Just One Predictor – MLR Chevron down icon Chevron up icon
When the Response Falls into Two Categories – Logistic Regression Chevron down icon Chevron up icon
Data Preparation Using R Tools Chevron down icon Chevron up icon
Avoiding Overfitting Problems - Achieving Generalization Chevron down icon Chevron up icon
Going Further with Regression Models Chevron down icon Chevron up icon
Beyond Linearity – When Curving Is Much Better Chevron down icon Chevron up icon
Regression Analysis in Practice Chevron down icon Chevron up icon
Other Books You May Enjoy Chevron down icon Chevron up icon

Customer reviews

Rating distribution
Full star icon Full star icon Full star icon Full star icon Half star icon 4.7
(3 Ratings)
5 star 66.7%
4 star 33.3%
3 star 0%
2 star 0%
1 star 0%
Vincenzo Ferraro Mar 13, 2018
Full star icon Full star icon Full star icon Full star icon Full star icon 5
This book has a lot to offer both in terms of theory and code. It is a simple book that does not require a great deal of knowledge of R. The most widespread statistical techniques are treated in a simple way. There are also many examples available to immediately apply the concepts learned.
Amazon Verified review Amazon
TR Mar 13, 2018
Full star icon Full star icon Full star icon Full star icon Full star icon 5
I ordered this book to prepare for a university exams and I found it really interesting and very clear. For those who want to have a base I highly recommend it. In addition to explaining the concepts well is full of examples that seriously help to understand the operation of various algorithms.
Amazon Verified review Amazon
Hitomi Cranford Oct 27, 2018
Full star icon Full star icon Full star icon Full star icon Empty star icon 4
I was hoping for more in terms of multicollinearity. Discussion of the tidyverse library to build amazing multiple linear regressions would have been awesome but that doesn't take away from the fact that this book is a really good start!
Amazon Verified review Amazon
Get free access to Packt library with over 7500+ books and video courses for 7 days!
Start Free Trial

FAQs

What is included in a Packt subscription? Chevron down icon Chevron up icon

A subscription provides you with full access to view all Packt and licnesed content online, this includes exclusive access to Early Access titles. Depending on the tier chosen you can also earn credits and discounts to use for owning content

How can I cancel my subscription? Chevron down icon Chevron up icon

To cancel your subscription with us simply go to the account page - found in the top right of the page or at https://subscription.packtpub.com/my-account/subscription - From here you will see the ‘cancel subscription’ button in the grey box with your subscription information in.

What are credits? Chevron down icon Chevron up icon

Credits can be earned from reading 40 section of any title within the payment cycle - a month starting from the day of subscription payment. You also earn a Credit every month if you subscribe to our annual or 18 month plans. Credits can be used to buy books DRM free, the same way that you would pay for a book. Your credits can be found in the subscription homepage - subscription.packtpub.com - clicking on ‘the my’ library dropdown and selecting ‘credits’.

What happens if an Early Access Course is cancelled? Chevron down icon Chevron up icon

Projects are rarely cancelled, but sometimes it's unavoidable. If an Early Access course is cancelled or excessively delayed, you can exchange your purchase for another course. For further details, please contact us here.

Where can I send feedback about an Early Access title? Chevron down icon Chevron up icon

If you have any feedback about the product you're reading, or Early Access in general, then please fill out a contact form here and we'll make sure the feedback gets to the right team. 

Can I download the code files for Early Access titles? Chevron down icon Chevron up icon

We try to ensure that all books in Early Access have code available to use, download, and fork on GitHub. This helps us be more agile in the development of the book, and helps keep the often changing code base of new versions and new technologies as up to date as possible. Unfortunately, however, there will be rare cases when it is not possible for us to have downloadable code samples available until publication.

When we publish the book, the code files will also be available to download from the Packt website.

How accurate is the publication date? Chevron down icon Chevron up icon

The publication date is as accurate as we can be at any point in the project. Unfortunately, delays can happen. Often those delays are out of our control, such as changes to the technology code base or delays in the tech release. We do our best to give you an accurate estimate of the publication date at any given time, and as more chapters are delivered, the more accurate the delivery date will become.

How will I know when new chapters are ready? Chevron down icon Chevron up icon

We'll let you know every time there has been an update to a course that you've bought in Early Access. You'll get an email to let you know there has been a new chapter, or a change to a previous chapter. The new chapters are automatically added to your account, so you can also check back there any time you're ready and download or read them online.

I am a Packt subscriber, do I get Early Access? Chevron down icon Chevron up icon

Yes, all Early Access content is fully available through your subscription. You will need to have a paid for or active trial subscription in order to access all titles.

How is Early Access delivered? Chevron down icon Chevron up icon

Early Access is currently only available as a PDF or through our online reader. As we make changes or add new chapters, the files in your Packt account will be updated so you can download them again or view them online immediately.

How do I buy Early Access content? Chevron down icon Chevron up icon

Early Access is a way of us getting our content to you quicker, but the method of buying the Early Access course is still the same. Just find the course you want to buy, go through the check-out steps, and you’ll get a confirmation email from us with information and a link to the relevant Early Access courses.

What is Early Access? Chevron down icon Chevron up icon

Keeping up to date with the latest technology is difficult; new versions, new frameworks, new techniques. This feature gives you a head-start to our content, as it's being created. With Early Access you'll receive each chapter as it's written, and get regular updates throughout the product's development, as well as the final course as soon as it's ready.We created Early Access as a means of giving you the information you need, as soon as it's available. As we go through the process of developing a course, 99% of it can be ready but we can't publish until that last 1% falls in to place. Early Access helps to unlock the potential of our content early, to help you start your learning when you need it most. You not only get access to every chapter as it's delivered, edited, and updated, but you'll also get the finalized, DRM-free product to download in any format you want when it's published. As a member of Packt, you'll also be eligible for our exclusive offers, including a free course every day, and discounts on new and popular titles.