Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases now! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
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

eBook
€17.99 €26.99
Paperback
€32.99
Subscription
Free Trial
Renews at €18.99p/m

What do you get with Print?

Product feature icon Instant access to your digital eBook copy whilst your Print order is Shipped
Product feature icon Paperback book shipped to your preferred address
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
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.
Estimated delivery fee Deliver to Italy

Premium delivery 7 - 10 business days

€17.95
(Includes tracking information)

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 Print?

Product feature icon Instant access to your digital eBook copy whilst your Print order is Shipped
Product feature icon Paperback book shipped to your preferred address
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
Estimated delivery fee Deliver to Italy

Premium delivery 7 - 10 business days

€17.95
(Includes tracking information)

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%
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
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
Get free access to Packt library with over 7500+ books and video courses for 7 days!
Start Free Trial

FAQs

What is the delivery time and cost of print book? Chevron down icon Chevron up icon

Shipping Details

USA:

'

Economy: Delivery to most addresses in the US within 10-15 business days

Premium: Trackable Delivery to most addresses in the US within 3-8 business days

UK:

Economy: Delivery to most addresses in the U.K. within 7-9 business days.
Shipments are not trackable

Premium: Trackable delivery to most addresses in the U.K. within 3-4 business days!
Add one extra business day for deliveries to Northern Ireland and Scottish Highlands and islands

EU:

Premium: Trackable delivery to most EU destinations within 4-9 business days.

Australia:

Economy: Can deliver to P. O. Boxes and private residences.
Trackable service with delivery to addresses in Australia only.
Delivery time ranges from 7-9 business days for VIC and 8-10 business days for Interstate metro
Delivery time is up to 15 business days for remote areas of WA, NT & QLD.

Premium: Delivery to addresses in Australia only
Trackable delivery to most P. O. Boxes and private residences in Australia within 4-5 days based on the distance to a destination following dispatch.

India:

Premium: Delivery to most Indian addresses within 5-6 business days

Rest of the World:

Premium: Countries in the American continent: Trackable delivery to most countries within 4-7 business days

Asia:

Premium: Delivery to most Asian addresses within 5-9 business days

Disclaimer:
All orders received before 5 PM U.K time would start printing from the next business day. So the estimated delivery times start from the next day as well. Orders received after 5 PM U.K time (in our internal systems) on a business day or anytime on the weekend will begin printing the second to next business day. For example, an order placed at 11 AM today will begin printing tomorrow, whereas an order placed at 9 PM tonight will begin printing the day after tomorrow.


Unfortunately, due to several restrictions, we are unable to ship to the following countries:

  1. Afghanistan
  2. American Samoa
  3. Belarus
  4. Brunei Darussalam
  5. Central African Republic
  6. The Democratic Republic of Congo
  7. Eritrea
  8. Guinea-bissau
  9. Iran
  10. Lebanon
  11. Libiya Arab Jamahriya
  12. Somalia
  13. Sudan
  14. Russian Federation
  15. Syrian Arab Republic
  16. Ukraine
  17. Venezuela
What is custom duty/charge? Chevron down icon Chevron up icon

Customs duty are charges levied on goods when they cross international borders. It is a tax that is imposed on imported goods. These duties are charged by special authorities and bodies created by local governments and are meant to protect local industries, economies, and businesses.

Do I have to pay customs charges for the print book order? Chevron down icon Chevron up icon

The orders shipped to the countries that are listed under EU27 will not bear custom charges. They are paid by Packt as part of the order.

List of EU27 countries: www.gov.uk/eu-eea:

A custom duty or localized taxes may be applicable on the shipment and would be charged by the recipient country outside of the EU27 which should be paid by the customer and these duties are not included in the shipping charges been charged on the order.

How do I know my custom duty charges? Chevron down icon Chevron up icon

The amount of duty payable varies greatly depending on the imported goods, the country of origin and several other factors like the total invoice amount or dimensions like weight, and other such criteria applicable in your country.

For example:

  • If you live in Mexico, and the declared value of your ordered items is over $ 50, for you to receive a package, you will have to pay additional import tax of 19% which will be $ 9.50 to the courier service.
  • Whereas if you live in Turkey, and the declared value of your ordered items is over € 22, for you to receive a package, you will have to pay additional import tax of 18% which will be € 3.96 to the courier service.
How can I cancel my order? Chevron down icon Chevron up icon

Cancellation Policy for Published Printed Books:

You can cancel any order within 1 hour of placing the order. Simply contact customercare@packt.com with your order details or payment transaction id. If your order has already started the shipment process, we will do our best to stop it. However, if it is already on the way to you then when you receive it, you can contact us at customercare@packt.com using the returns and refund process.

Please understand that Packt Publishing cannot provide refunds or cancel any order except for the cases described in our Return Policy (i.e. Packt Publishing agrees to replace your printed book because it arrives damaged or material defect in book), Packt Publishing will not accept returns.

What is your returns and refunds policy? Chevron down icon Chevron up icon

Return Policy:

We want you to be happy with your purchase from Packtpub.com. We will not hassle you with returning print books to us. If the print book you receive from us is incorrect, damaged, doesn't work or is unacceptably late, please contact Customer Relations Team on customercare@packt.com with the order number and issue details as explained below:

  1. If you ordered (eBook, Video or Print Book) incorrectly or accidentally, please contact Customer Relations Team on customercare@packt.com within one hour of placing the order and we will replace/refund you the item cost.
  2. Sadly, if your eBook or Video file is faulty or a fault occurs during the eBook or Video being made available to you, i.e. during download then you should contact Customer Relations Team within 14 days of purchase on customercare@packt.com who will be able to resolve this issue for you.
  3. You will have a choice of replacement or refund of the problem items.(damaged, defective or incorrect)
  4. Once Customer Care Team confirms that you will be refunded, you should receive the refund within 10 to 12 working days.
  5. If you are only requesting a refund of one book from a multiple order, then we will refund you the appropriate single item.
  6. Where the items were shipped under a free shipping offer, there will be no shipping costs to refund.

On the off chance your printed book arrives damaged, with book material defect, contact our Customer Relation Team on customercare@packt.com within 14 days of receipt of the book with appropriate evidence of damage and we will work with you to secure a replacement copy, if necessary. Please note that each printed book you order from us is individually made by Packt's professional book-printing partner which is on a print-on-demand basis.

What tax is charged? Chevron down icon Chevron up icon

Currently, no tax is charged on the purchase of any print book (subject to change based on the laws and regulations). A localized VAT fee is charged only to our European and UK customers on eBooks, Video and subscriptions that they buy. GST is charged to Indian customers for eBooks and video purchases.

What payment methods can I use? Chevron down icon Chevron up icon

You can pay with the following card types:

  1. Visa Debit
  2. Visa Credit
  3. MasterCard
  4. PayPal
What is the delivery time and cost of print books? Chevron down icon Chevron up icon

Shipping Details

USA:

'

Economy: Delivery to most addresses in the US within 10-15 business days

Premium: Trackable Delivery to most addresses in the US within 3-8 business days

UK:

Economy: Delivery to most addresses in the U.K. within 7-9 business days.
Shipments are not trackable

Premium: Trackable delivery to most addresses in the U.K. within 3-4 business days!
Add one extra business day for deliveries to Northern Ireland and Scottish Highlands and islands

EU:

Premium: Trackable delivery to most EU destinations within 4-9 business days.

Australia:

Economy: Can deliver to P. O. Boxes and private residences.
Trackable service with delivery to addresses in Australia only.
Delivery time ranges from 7-9 business days for VIC and 8-10 business days for Interstate metro
Delivery time is up to 15 business days for remote areas of WA, NT & QLD.

Premium: Delivery to addresses in Australia only
Trackable delivery to most P. O. Boxes and private residences in Australia within 4-5 days based on the distance to a destination following dispatch.

India:

Premium: Delivery to most Indian addresses within 5-6 business days

Rest of the World:

Premium: Countries in the American continent: Trackable delivery to most countries within 4-7 business days

Asia:

Premium: Delivery to most Asian addresses within 5-9 business days

Disclaimer:
All orders received before 5 PM U.K time would start printing from the next business day. So the estimated delivery times start from the next day as well. Orders received after 5 PM U.K time (in our internal systems) on a business day or anytime on the weekend will begin printing the second to next business day. For example, an order placed at 11 AM today will begin printing tomorrow, whereas an order placed at 9 PM tonight will begin printing the day after tomorrow.


Unfortunately, due to several restrictions, we are unable to ship to the following countries:

  1. Afghanistan
  2. American Samoa
  3. Belarus
  4. Brunei Darussalam
  5. Central African Republic
  6. The Democratic Republic of Congo
  7. Eritrea
  8. Guinea-bissau
  9. Iran
  10. Lebanon
  11. Libiya Arab Jamahriya
  12. Somalia
  13. Sudan
  14. Russian Federation
  15. Syrian Arab Republic
  16. Ukraine
  17. Venezuela