Linear regression, while a useful tool, has significant limits. As its name implies, it cant easily match any data set that is non-linear. It can only be used to make predictions that fit within the range of the training data set. And, most importantly for our purposes, linear regression can only be fit to data sets with a single dependent variable and a single independent variable.
This is where multiple regression comes in. While it cant overcome all of linear regressions weaknesses, its specifically designed to create regressions on models with a single dependent variable and multiple independent variables.
Multiple regression is an extension of linear regression models that allow predictions of systems with multiple independent variables.
To start, lets look at the general form of the equation for linear regression:
y = B * x + A
Here, y is the dependent variable, x is the independent variable, and A and B are coefficients dictating the equation. The difference between the equation for linear regression and the equation for multiple regression is that the equation for multiple regression must be able to handle several inputs, instead of only the single input of linear regression. To account for this change, the equation for multiple regression looks like this:
y = B_1 * x_1 + B_2 * x_2 + + B_n * x_n + A
In this equation, the subscripts denote the different independent variables. For example, x_1 is the value of the first independent variable, x_2 is the value of the second independent variable, and so on. It keeps going as we add more independent variables until we finally add the last independent variable, x_n, to the equation. (Note that this model allows you to have any number, n, independent variables and more terms are added as needed.) The B coefficients employ the same subscripts, indicating they are the coefficients linked to each independent variable. A, as before, is simply a constant stating the value of the dependent variable, y, when all of the independent variables, the xs, are zero.
As an example, imagine that youre a traffic planner in your city and need to estimate the average commute time of drivers going from the east side of the city to the west. You dont know how long it takes on average, but you do know that it will depend on a number of factors like the distance driven, the number of stoplights on the route, and the number of other cars on the road. In that case you could create a linear multiple regression equation like the following:
y = B_1 * Distance + B_2 * Stoplights + B_3 * Cars + A
Here y is the average commute time, Distance is the distance between the starting and ending destinations, Stoplights is the number of stoplights on the route, and A is a constant representing other time consumers (e.g. putting on your seat belt, starting the car, maybe stopping at a coffee shop).
Now that you have your commute time prediction model, you need to fit your model to your training data set to minimize errors.
Similarly to how we minimize the sum of squared errors to find B in linear regression, we minimize the sum of squared errors to find all of the B terms in multiple regression. The difference here is that since there are multiple terms, and an unspecified number of terms until you create the model, there isnt a simple algebraic solution to find A and B. This means we need to use stochastic gradient descent. You can find a good description of stochastic gradient descent in Data Science from Scratch by Joel Gros or use tools in the Python scikit-learn package. Fortunately, we can still present the equations needed to implement this solution before reading about the details.
The first step is summing the squared errors on each point. This takes the form:
Error_Point = (Actual Prediction)
In this instance, Error is the error in the model when predicting a persons commute time, Actual is the actual value (or that persons actual commute time), and Prediction is the value predicted by the model (or that persons commute time predicted by the model). Actual Prediction yields the error for a point, then squaring it yields the squared error for a point. Remember that squaring the error is important because some errors will be positive while others will be negative and if not squared these errors will cancel each other out making the total error of the model look far smaller than it really is.
To find the error in the model, the error from each point must be summed across the entire data set. This essentially means that you use the model to predict the commute time for each data point that you have, subtract that value from the actual commute time in the data point to find the error, square that error, then sum all of the squared errors together. In other words, the error of the model is:
Error_Model = sum(Actual_i Prediction_i)
Here i is an index iterating through all points in the data set.
Once the error function is determined, you need to put the model and error function through a stochastic gradient descent algorithm to minimize the error. The stochastic gradient descent algorithm will do this by minimizing the B terms in the equation.
Once youve fit the model to your training data, the next step is to ensure that the model fits your full data set well.
To make sure your model fits the data use the same r value that you use for linear regression. The r value (also called the coefficient of determination) states the portion of change in the data set predicted by the model. The value will range from 0 to 1, with 0 stating that the model has no ability to predict the result and 1 stating that the model predicts the result perfectly. You should expect the r value of any model you create to be between those two values. If it isnt, retrace your steps because youve made a mistake somewhere.
You can calculate the coefficient of determination for a model using the following equations:
r = 1 (Sum of squared errors) / (Total sum of squares)
(Total sum of squares) = Sum(y_i mean(y))
(Sum of squared errors) = sum((Actual_i Prediction_i))
Heres where testing the fit of a multiple regression model gets complicated. Adding more terms to the multiple regression inherently improves the fit. Additional terms give the model more flexibility and new coefficients that can be tweaked to create a better fit. Additional terms will always yield a better fit to the training data whether the new term adds value to the model or not. Adding new variables which do not realistically have an impact on the dependent variable will yield a better fit to the training data, while creating an erroneous term in the model. An example of this would be adding a term describing the position of Saturn in the night sky to the driving time model. The regression equations will create a coefficient for that term, and it will cause the model to more closely fit the data set, but we all know that Saturns location doesnt impact commute times. The Saturn location term will add noise to future predictions, leading to less accurate estimates of commute times even though it made the model more closely fit the training data set. This issue is referred to as overfitting the model.
Additional terms will always improve the model whether the new term adds significant value to the model or not.
This fact has important implications when developing multiple regression models. Yes, you could keep adding more terms to the equation until you either get a perfect match or run out variables to add. But then youd end up with a very large, complex model thats full of terms which arent actually relevant to the case youre predicting.
One way to determine which parameters are most important is to calculate the standard error of each coefficient. The standard error states how confident the model is about each coefficient, with larger values indicating that the model is less sure of that parameter. We can intuit this even without seeing the underlying equations. If the error associated with a term is typically high, that implies the term is not having a very strong impact on matching the model to the data set.
Calculating the standard error is an involved statistical process, and cant be succinctly described in a short article. Fortunately there are Python packages available that you can use to do it for you. The question has been asked and answered on StackOverflow at least once. Those tools should get you started.
After calculating the standard error of each coefficient, you can use the results to identify which coefficients are highest and which are lowest. Since high values indicate that those terms add less predictive value to the model, you can know those terms are the least important to keep. At this point you can start choosing which terms in the model can be removed to reduce the number of terms in the equation without dramatically reducing the predictive power of the model.
Another method is to use a technique called regularization. Regularization works by adding a new term to the error calculation that is based on the number of terms in the multiple regression equation. More terms in the equation will inherently lead to a higher regularization error, while fewer terms inherently lead to a lower regularization error. Additionally, the penalty for adding terms in the regularization equation can be increased or decreased as desired. Increasing the penalty will also lead to a higher regularization error, while decreasing it will lead to a lower regularization error.
With a regularization term added to the error equation, minimizing the error means not just minimizing the error in the model but also minimizing the number of terms in the equation. This will inherently lead to a model with a worse fit to the training data, but will also inherently lead to a model with fewer terms in the equation. Higher penalty/term values in the regularization error create more pressure on the model to have fewer terms.
Read More From Our ExpertsWhat is Linear Regression? Explaining Concepts and Applications With Tensorflow 2.0
The model youve created is not just an equation with a bunch of numbers in it. Each one of the coefficients you derived states the impact an independent variable has on the dependent variable assuming all others are held equal. For instance, our commute time example says the average commute will take B_2 minutes longer for each stoplight in a persons commute path. If the model development process returns 2.32 for B_2, that means each stoplight in a persons path adds 2.32 minutes to the drive.
This is another reason its important to keep the number of terms in the equation low. As we add more terms it gets harder to keep track of the physical significance (and justify the presence) of each term. Anybody counting on the commute time predicting model would accept a term for commute distance but will be less understanding of a term for the location of Saturn in the night sky.
Note that this model doesnt say anything about how parameters might affect each other. In looking at the equation, theres no way that it could. The different coefficients are all connected to only a single physical parameter. If you believe two terms are related, you could create a new term based on the combination of those two. For instance, the number of stoplights on the commute could be a function of the distance of the commute. A potential equation for that could be:
Stoplights = C_1 * Distance + D
In this case, C_1 and D are regression coefficients similar to B and A in the commute distance regression equation. This term for stoplights could then be substituted into the commute distance regression equation, enabling the model to capture this relationship.
Another possible modification includes adding non-linear inputs. The multiple regression model itself is only capable of being linear, which is a limitation. You can however create non-linear terms in the model. For instance, say that one stoplight backing up can prevent traffic from passing through a prior stoplight. This could lead to an exponential impact from stoplights on the commute time. You could create a new term to capture this, and modify your commute distance algorithm accordingly. That would look something like:
Stoplights_Squared = Stoplights
y = B_1 * Distance + B_2 * Stoplights + B_3 * Cars + B_4 * Stoplights_Squared + C
These two equations combine to create a linear regression term for your non linear Stoplights_Squared input.
Multiple regression is an extension of linear regression models that allow predictions of systems with multiple independent variables. We do this by adding more terms to the linear regression equation, with each term representing the impact of a different physical parameter. When used with care, multiple regression models can simultaneously describe the physical principles acting on a data set and provide a powerful tool to predict the impacts of changes in the system described by the data.
This article was originally published on Towards Data Science.
Read the original:
What is Multiple Regression? - Built In
- Global Data Science Platform Market Report 2020 Industry Trends, Share and Size, Complete Data Analysis across the Region and Globe, Opportunities and... [Last Updated On: November 11th, 2020] [Originally Added On: November 11th, 2020]
- Data Science and Machine-Learning Platforms Market Size, Drivers, Potential Growth Opportunities, Competitive Landscape, Trends And Forecast To 2027 -... [Last Updated On: November 11th, 2020] [Originally Added On: November 11th, 2020]
- Industrial Access Control Market 2020-28 use of data science in agriculture to maximize yields and efficiency with top key players - TechnoWeekly [Last Updated On: November 11th, 2020] [Originally Added On: November 11th, 2020]
- IPG Unveils New-And-Improved Copy For Data: It's Not Your Father's 'Targeting' 11/11/2020 - MediaPost Communications [Last Updated On: November 11th, 2020] [Originally Added On: November 11th, 2020]
- Risks and benefits of an AI revolution in medicine - Harvard Gazette [Last Updated On: November 11th, 2020] [Originally Added On: November 11th, 2020]
- UTSA to break ground on $90 million School of Data Science and National Security Collaboration Center - Construction Review [Last Updated On: November 11th, 2020] [Originally Added On: November 11th, 2020]
- Addressing the skills shortage in data science and analytics - IT-Online [Last Updated On: November 11th, 2020] [Originally Added On: November 11th, 2020]
- Data Science Platform Market Research Growth by Manufacturers, Regions, Type and Application, Forecast Analysis to 2026 - Eurowire [Last Updated On: November 11th, 2020] [Originally Added On: November 11th, 2020]
- 2020 AI and Data Science in Retail Industry Ongoing Market Situation with Manufacturing Opportunities: Amazon Web Services, Baidu Inc., BloomReach... [Last Updated On: November 11th, 2020] [Originally Added On: November 11th, 2020]
- Endowed Chair of Data Science job with Baylor University | 299439 - The Chronicle of Higher Education [Last Updated On: November 11th, 2020] [Originally Added On: November 11th, 2020]
- Data scientists gather 'chaos into something organized' - University of Miami [Last Updated On: November 11th, 2020] [Originally Added On: November 11th, 2020]
- AI Update: Provisions in the National Defense Authorization Act Signal the Importance of AI to American Competitiveness - Lexology [Last Updated On: January 12th, 2021] [Originally Added On: January 12th, 2021]
- Healthcare Innovations: Predictions for 2021 Based on the Viewpoints of Analytics Thought Leaders and Industry Experts | Quantzig - Business Wire [Last Updated On: January 12th, 2021] [Originally Added On: January 12th, 2021]
- Poor data flows hampered governments Covid-19 response, says the Science and Technology Committee - ComputerWeekly.com [Last Updated On: January 12th, 2021] [Originally Added On: January 12th, 2021]
- Ilia Dub and Jasper Yip join Oliver Wyman's Asia partnership - Consultancy.asia [Last Updated On: January 12th, 2021] [Originally Added On: January 12th, 2021]
- Save 98% off the Complete Excel, VBA, and Data Science Certification Training Bundle - Neowin [Last Updated On: January 12th, 2021] [Originally Added On: January 12th, 2021]
- Data Science for Social Good Programme helps Ofsted and World Bank - India Education Diary [Last Updated On: January 12th, 2021] [Originally Added On: January 12th, 2021]
- Associate Professor of Fisheries Oceanography named a Cooperative Institute for the North Atlantic Region (CINAR) Fellow - UMass Dartmouth [Last Updated On: January 12th, 2021] [Originally Added On: January 12th, 2021]
- Rapid Insight To Host Free Webinar, Building on Data: From Raw Piles to Data Science - PR Web [Last Updated On: January 12th, 2021] [Originally Added On: January 12th, 2021]
- This Is the Best Place to Buy Groceries, New Data Finds | Eat This Not That - Eat This, Not That [Last Updated On: January 12th, 2021] [Originally Added On: January 12th, 2021]
- Which Technology Jobs Will Require AI and Machine Learning Skills? - Dice Insights [Last Updated On: January 12th, 2021] [Originally Added On: January 12th, 2021]
- Companies hiring data scientists in NYC and how much they pay - Business Insider [Last Updated On: January 12th, 2021] [Originally Added On: January 12th, 2021]
- Calling all rock stars: hire the right data scientist talent for your business - IDG Connect [Last Updated On: January 12th, 2021] [Originally Added On: January 12th, 2021]
- How Professors Can Use AI to Improve Their Teaching In Real Time - EdSurge [Last Updated On: January 12th, 2021] [Originally Added On: January 12th, 2021]
- BCG GAMMA, in Collaboration with Scikit-Learn, Launches FACET, Its New Open-Source Library for Human-Explainable Artificial Intelligence - PRNewswire [Last Updated On: January 12th, 2021] [Originally Added On: January 12th, 2021]
- Data Science Platform Market Insights, Industry Outlook, Growing Trends and Demands 2020 to 2025 The Courier - The Courier [Last Updated On: January 31st, 2021] [Originally Added On: January 31st, 2021]
- UBIX and ORS GROUP announce partnership to democratize advanced analytics and AI for small and midmarket organizations - PR Web [Last Updated On: January 31st, 2021] [Originally Added On: January 31st, 2021]
- Praxis Business School is launching its Post Graduate Program in Data Engineering in association with Knowledge Partners - Genpact and LatentView... [Last Updated On: January 31st, 2021] [Originally Added On: January 31st, 2021]
- What's So Trendy about Knowledge Management Solutions Market That Everyone Went Crazy over It? | Bloomfire, CSC (American Productivity & Quality... [Last Updated On: January 31st, 2021] [Originally Added On: January 31st, 2021]
- Want to work in data? Here are 6 skills you'll need Just now - Siliconrepublic.com [Last Updated On: January 31st, 2021] [Originally Added On: January 31st, 2021]
- Data, AI and babies - BusinessLine [Last Updated On: January 31st, 2021] [Originally Added On: January 31st, 2021]
- Here's how much Amazon pays its Boston-based employees - Business Insider [Last Updated On: January 31st, 2021] [Originally Added On: January 31st, 2021]
- Datavant and Kythera Increase the Value Of Healthcare Data Through Expanded Data Science Platform Partnership - GlobeNewswire [Last Updated On: January 31st, 2021] [Originally Added On: January 31st, 2021]
- O'Reilly Analysis Unveils Python's Growing Demand as Searches for Data Science, Cloud, and ITOps Topics Accelerate - Business Wire [Last Updated On: January 31st, 2021] [Originally Added On: January 31st, 2021]
- Book Review: Hands-On Exploratory Data Analysis with Python - insideBIGDATA [Last Updated On: January 31st, 2021] [Originally Added On: January 31st, 2021]
- The 12 Best R Courses and Online Training to Consider for 2021 - Solutions Review [Last Updated On: January 31st, 2021] [Originally Added On: January 31st, 2021]
- Software AG's TrendMiner 2021.R1 Release Puts Data Science in the Hands of Operational Experts - Yahoo Finance [Last Updated On: January 31st, 2021] [Originally Added On: January 31st, 2021]
- The chief data scientist: Who they are and what they do - Siliconrepublic.com [Last Updated On: January 31st, 2021] [Originally Added On: January 31st, 2021]
- Berkeley's data science leader dedicated to advancing diversity in computing - UC Berkeley [Last Updated On: January 31st, 2021] [Originally Added On: January 31st, 2021]
- Awful Earnings Aside, the Dip in Alteryx Stock Is Worth Buying - InvestorPlace [Last Updated On: February 12th, 2021] [Originally Added On: February 12th, 2021]
- Why Artificial Intelligence May Not Offer The Business Value You Think - CMSWire [Last Updated On: February 12th, 2021] [Originally Added On: February 12th, 2021]
- Getting Prices Right in 2021 - Progressive Grocer [Last Updated On: February 12th, 2021] [Originally Added On: February 12th, 2021]
- Labelbox raises $40 million for its data labeling and annotation tools - VentureBeat [Last Updated On: February 12th, 2021] [Originally Added On: February 12th, 2021]
- How researchers are using data science to map wage theft - SmartCompany.com.au [Last Updated On: February 12th, 2021] [Originally Added On: February 12th, 2021]
- Ready to start coding? What you need to know about Python - TechRepublic [Last Updated On: February 12th, 2021] [Originally Added On: February 12th, 2021]
- Women changing the face of science in the Middle East and North Africa - The Jerusalem Post [Last Updated On: February 12th, 2021] [Originally Added On: February 12th, 2021]
- Mapping wage theft with data science - The Mandarin [Last Updated On: February 12th, 2021] [Originally Added On: February 12th, 2021]
- Data Science Platform Market 2021 Analysis Report with Highest CAGR and Major Players like || Dataiku, Bridgei2i Analytics, Feature Labs and More KSU... [Last Updated On: February 12th, 2021] [Originally Added On: February 12th, 2021]
- Data Science Impacting the Pharmaceutical Industry, 2020 Report: Focus on Clinical Trials - Data Science-driven Patient Selection & FDA... [Last Updated On: February 12th, 2021] [Originally Added On: February 12th, 2021]
- App Annie Sets New Bar for Mobile Analytics with Data Science Innovations - PRNewswire [Last Updated On: February 12th, 2021] [Originally Added On: February 12th, 2021]
- Data Science and Analytics Market 2021 to Showing Impressive Growth by 2028 | Industry Trends, Share, Size, Top Key Players Analysis and Forecast... [Last Updated On: February 12th, 2021] [Originally Added On: February 12th, 2021]
- How Can We Fix the Data Science Talent Shortage? Machine Learning Times - The Predictive Analytics Times [Last Updated On: February 14th, 2021] [Originally Added On: February 14th, 2021]
- Opinion: How to secure the best tech talent | Human Capital - Business Chief [Last Updated On: February 14th, 2021] [Originally Added On: February 14th, 2021]
- Following the COVID science: what the data say about the vaccine, social gatherings and travel - Chicago Sun-Times [Last Updated On: February 14th, 2021] [Originally Added On: February 14th, 2021]
- Automated Data Science and Machine Learning Platforms Market Technological Growth and Precise Outlook 2021- Microsoft, MathWorks, SAS, Databricks,... [Last Updated On: February 14th, 2021] [Originally Added On: February 14th, 2021]
- 9 investors discuss hurdles, opportunities and the impact of cloud vendors in enterprise data lakes - TechCrunch [Last Updated On: February 14th, 2021] [Originally Added On: February 14th, 2021]
- Rapid Insight to Present at Data Science Salon's Healthcare, Finance, and Technology Virtual Event - PR Web [Last Updated On: February 14th, 2021] [Originally Added On: February 14th, 2021]
- Aunalytics Acquires Naveego to Expand Capabilities of its End-to-End Cloud-Native Data Platform to Enable True Digital Transformation for Customers -... [Last Updated On: February 22nd, 2021] [Originally Added On: February 22nd, 2021]
- Tech Careers: In-demand Courses to watch out for a Lucrative Future - Big Easy Magazine [Last Updated On: February 22nd, 2021] [Originally Added On: February 22nd, 2021]
- Willis Towers Watson enhances its human capital data science capabilities globally with the addition of the Jobable team - GlobeNewswire [Last Updated On: February 22nd, 2021] [Originally Added On: February 22nd, 2021]
- Global Data Science Platform Market 2021 Industry Insights, Drivers, Top Trends, Global Analysis And Forecast to 2027 KSU | The Sentinel Newspaper -... [Last Updated On: February 22nd, 2021] [Originally Added On: February 22nd, 2021]
- A Comprehensive Guide to Scikit-Learn - Built In [Last Updated On: February 22nd, 2021] [Originally Added On: February 22nd, 2021]
- Industry VoicesBuilding ethical algorithms to confront biases: Lessons from Aotearoa New Zealand - FierceHealthcare [Last Updated On: February 22nd, 2021] [Originally Added On: February 22nd, 2021]
- How Intel Employees Volunteered Their Data Science Expertise To Help Costa Rica Save Lives During the Pandemic - CSRwire.com [Last Updated On: February 22nd, 2021] [Originally Added On: February 22nd, 2021]
- Learn About Innovations in Data Science and Analytic Automation on an Upcoming Episode of the Advancements Series - Yahoo Finance [Last Updated On: February 22nd, 2021] [Originally Added On: February 22nd, 2021]
- Symposium aimed at leveraging the power of data science for promoting diversity - Penn State News [Last Updated On: February 22nd, 2021] [Originally Added On: February 22nd, 2021]
- Rochester to advance research in biological imaging through new grant - University of Rochester [Last Updated On: February 22nd, 2021] [Originally Added On: February 22nd, 2021]
- SoftBank Joins Initiative to Train Diverse Talent in Data Science and AI - Entrepreneur [Last Updated On: February 22nd, 2021] [Originally Added On: February 22nd, 2021]
- Participating in SoftBank/ Correlation One Initiative - Miami - City of Miami [Last Updated On: February 22nd, 2021] [Originally Added On: February 22nd, 2021]
- Increasing Access to Care with the Help of Big Data | Research Blog - Duke Today [Last Updated On: February 22nd, 2021] [Originally Added On: February 22nd, 2021]
- Heres how Data Science & Business Analytics expertise can put you on the career expressway - Times of India [Last Updated On: March 14th, 2021] [Originally Added On: March 14th, 2021]
- Yelp data shows almost half a million new businesses opened during the pandemic - CNBC [Last Updated On: March 14th, 2021] [Originally Added On: March 14th, 2021]
- Postdoctoral Position in Transient and Multi-messenger Astronomy Data Science in Greenbelt, MD for University of MD Baltimore County/CRESST II -... [Last Updated On: March 14th, 2021] [Originally Added On: March 14th, 2021]
- DefinedCrowd CEO Daniela Braga on the future of AI, training data, and women in tech - GeekWire [Last Updated On: March 14th, 2021] [Originally Added On: March 14th, 2021]
- Gartner: AI and data science to drive investment decisions rather than "gut feel" by mid-decade - TechRepublic [Last Updated On: March 14th, 2021] [Originally Added On: March 14th, 2021]
- Jupyter has revolutionized data science, and it started with a chance meeting between two students - TechRepublic [Last Updated On: March 14th, 2021] [Originally Added On: March 14th, 2021]
- Working at the intersection of data science and public policy | Penn Today - Penn Today [Last Updated On: March 14th, 2021] [Originally Added On: March 14th, 2021]
- The Future of AI: Careers in Machine Learning - Southern New Hampshire University [Last Updated On: April 4th, 2021] [Originally Added On: April 4th, 2021]
- SMU meets the opportunities of the data-driven world with cutting-edge research and data science programs - The Dallas Morning News [Last Updated On: April 4th, 2021] [Originally Added On: April 4th, 2021]
- Data, Science, and Journalism in the Age of COVID - Pulitzer Center on Crisis Reporting [Last Updated On: April 4th, 2021] [Originally Added On: April 4th, 2021]