Instatistical modeling,regression analysis is a statistical method forestimating the relationship between adependent variable (often called theoutcome orresponse variable, or alabel in machine learning parlance) and one or moreindependent variables (often calledregressors,predictors,covariates,explanatory variables orfeatures).[1][2]
The most common form of regression analysis islinear regression, in which one finds the line (or a more complexlinear combination) that most closely fits the data according to a specific mathematical criterion. For example, the method ofordinary least squares computes the unique line (orhyperplane) that minimizes the sum of squared differences between the true data and that line (or hyperplane). For specific mathematical reasons (seelinear regression), this allows the researcher to estimate theconditional expectation (or populationaverage value) of the dependent variable when the independent variables take on a given set of values. Less common forms of regression use slightly different procedures to estimate alternativelocation parameters (e.g.,quantile regression orNecessary Condition Analysis[3]) or estimate the conditional expectation across a broader collection of non-linear models (e.g.,nonparametric regression).
Regression analysis is primarily used for two conceptually distinct purposes. First, regression analysis is widely used forprediction andforecasting, where its use has substantial overlap with the field ofmachine learning. Second, in some situations regression analysis can be used to infercausal relationships between the independent and dependent variables. Importantly, regressions by themselves only reveal relationships between a dependent variable and a collection of independent variables in a fixed dataset. To use regressions for prediction or to infer causal relationships, respectively, a researcher must carefully justify why existing relationships have predictive power for a new context or why a relationship between two variables has a causal interpretation. The latter is especially important when researchers hope to estimate causal relationships usingobservational data.[4][5]
The earliest regression form was seen inIsaac Newton's work in 1700 while studyingequinoxes, being credited with introducing "an embryonic linear regression analysis" as "Not only did he perform the averaging of a set of data, 50 years beforeTobias Mayer, but by summing the residuals to zero heforced the regression line to pass through the average point. He also distinguished between two inhomogeneous sets of data and might have thought of anoptimal solution in terms of bias, though not in terms of effectiveness." He previously used an averaging method in his 1671 work on Newton's rings, which was unprecedented at the time.[6][7]
Themethod of least squares was published byLegendre in 1805,[8] and byGauss in 1809.[9] Legendre and Gauss both applied the method to the problem of determining, from astronomical observations, the orbits of bodies about the Sun (mostly comets, but also later the then newly discovered minor planets). Gauss published a further development of the theory of least squares in 1821,[10] including a version of theGauss–Markov theorem.
The term "regression" was coined byFrancis Galton in the 19th century to describe a biological phenomenon. The phenomenon was that the heights of descendants of tall ancestors tend to regress down towards a normal average (a phenomenon also known asregression toward the mean).[11][12]For Galton, regression had only this biological meaning,[13][14] but his work was later extended byUdny Yule andKarl Pearson to a more general statistical context.[15][16] In the work of Yule and Pearson, thejoint distribution of the response and explanatory variables is assumed to beGaussian. This assumption was weakened byR.A. Fisher in his works of 1922 and 1925.[17][18][19] Fisher assumed that theconditional distribution of the response variable is Gaussian, but the joint distribution need not be. In this respect, Fisher's assumption is closer to Gauss's formulation of 1821.
In the 1950s and 1960s, economists usedelectromechanical desk calculators to calculate regressions. Before 1970, it sometimes took up to 24 hours to receive the result from one regression.[20]
Regression methods continue to be an area of active research. In recent decades, new methods have been developed forrobust regression, regression involving correlated responses such astime series andgrowth curves, regression in which the predictor (independent variable) or response variables are curves, images, graphs, or other complex data objects, regression methods accommodating various types of missing data,nonparametric regression,Bayesian methods for regression, regression in which the predictor variables are measured with error, regression with more predictor variables than observations, andcausal inference with regression. Modern regression analysis is typically done with statistical andspreadsheet software packages on computers as well as on handheldscientific andgraphing calculators.
In practice, researchers first select a model they would like to estimate and then use their chosen method (e.g.,ordinary least squares) to estimate the parameters of that model. Regression models involve the following components:
Theunknown parameters, often denoted as ascalar orvector.
Theindependent variables, which are observed in data and are often denoted as a vector (where denotes a row of data).
Thedependent variable, which are observed in data and often denoted using the scalar.
Theerror terms, which arenot directly observed in data and are often denoted using the scalar.
Most regression models propose that is afunction (regression function) of and, with representing anadditive error term that may stand in for un-modeled determinants of or random statistical noise:
In the standard regression model, the independent variables are assumed to be free of error. Theerrors-in-variables model can be used if the independent variables are assumed to contain errors. Other modifications to the standard regression model can be made to account for various scenarios, such as situations involvingomitted variables,confounding variables orendogeneity.
The researchers' goal is to estimate the function that most closely fits the data. To carry out regression analysis, the form of the function must be specified. Sometimes the form of this function is based on knowledge about the relationship between and that does not rely on the data. If no such knowledge is available, a flexible or convenient form for is chosen. For example, a simple univariate regression may propose, suggesting that the researcher believes to be a reasonable approximation for the statistical process generating the data.
Once researchers determine their preferredstatistical model, different forms of regression analysis provide tools to estimate the parameters. For example,least squares (including its most common variant,ordinary least squares) finds the value of that minimizes the sum of squared errors. A given regression method will ultimately provide an estimate of, usually denoted to distinguish the estimate from the true (unknown) parameter value that generated the data. Using this estimate, the researcher can then use thefitted value for prediction or to assess the accuracy of the model in explaining the data. Whether the researcher is intrinsically interested in the estimate or the predicted value will depend on context and their goals. As described inordinary least squares, least squares is widely used because the estimated function approximates theconditional expectation.[9] However, alternative variants (e.g.,least absolute deviations orquantile regression) are useful when researchers want to model other functions.
It is important to note that there must be sufficient data to estimate a regression model. For example, suppose that a researcher has access to rows of data with one dependent and two independent variables:. Suppose further that the researcher wants to estimate a bivariate linear model vialeast squares:. If the researcher only has access to data points, then they could find infinitely many combinations that explain the data equally well: any combination can be chosen that satisfies, all of which lead to and are therefore valid solutions that minimize the sum of squaredresiduals. To understand why there are infinitely many options, note that the system of equations is to be solved for 3 unknowns, which makes the systemunderdetermined. Alternatively, one can visualize infinitely many 3-dimensional planes that go through fixed points.
More generally, to estimate aleast squares model with distinct parameters, one must have distinct data points. If, then there does not generally exist a set of parameters that will perfectly fit the data. The quantity appears often in regression analysis, and is referred to as thedegrees of freedom in the model. Moreover, to estimate a least squares model, the independent variables must belinearly independent: one mustnot be able to reconstruct any of the independent variables by adding and multiplying the remaining independent variables. As discussed inordinary least squares, this condition ensures that is aninvertible matrix and therefore that a unique solution exists.
By itself, a regression is just a computation performed on a set of data. In order to interpret the resultant regression as a meaningful statistical model that quantifies real-world relationships, researchers often rely on a number of classicalassumptions. These assumptions often include:
The sample is representative of the population at large.
The independent variables are measured without error.
Deviations from the model have an expected value of zero, conditional on covariates:
The variance of the residuals is constant across observations (homoscedasticity).
A handful of conditions are sufficient for the least-squares estimator to possess desirable properties: in particular, theGauss–Markov assumptions imply that the parameter estimates will beunbiased,consistent, andefficient in the class of linear unbiased estimators. Practitioners have developed a variety of methods to maintain some or all of these desirable properties in real-world settings, because these classical assumptions are unlikely to hold exactly. For example, modelingerrors-in-variables can lead to reasonable estimates independent variables are measured with errors.Heteroscedasticity-consistent standard errors allow the variance of to change across values of. Correlated errors that exist within subsets of the data or follow specific patterns can be handled usingclustered standard errors, geographic weighted regression, orNewey–West standard errors, among other techniques. When rows of data correspond to locations in space, the choice of how to model within geographic units can have important consequences.[21][22] The subfield ofeconometrics is largely focused on developing techniques that allow researchers to make reasonable real-world conclusions in real-world settings, where classical assumptions do not hold exactly.
In linear regression, the model specification is that the dependent variable, is alinear combination of theparameters (but need not be linear in theindependent variables). For example, insimple linear regression for modeling data points there is one independent variable:, and two parameters, and:
straight line:
In multiple linear regression, there are several independent variables or functions of independent variables.
Adding a term in to the preceding regression gives:
parabola:
This is still linear regression; although the expression on the right hand side is quadratic in the independent variable, it is linear in the parameters, and
In both cases, is an error term and the subscript indexes a particular observation.
Returning our attention to the straight line case: Given a random sample from the population, we estimate the population parameters and obtain the sample linear regression model:
Theresidual,, is the difference between the value of the dependent variable predicted by the model,, and the true value of the dependent variable,. One method of estimation isordinary least squares. This method obtains parameter estimates that minimize the sum of squaredresiduals,SSR:
Minimization of this function results in a set ofnormal equations, a set of simultaneous linear equations in the parameters, which are solved to yield the parameter estimators,.
Illustration of linear regression on a data set
In the case of simple regression, the formulas for the least squares estimates are
where is themean (average) of the values and is the mean of the values.
Under the assumption that the population error term has a constant variance, the estimate of that variance is given by:
This is called themean square error (MSE) of the regression. The denominator is the sample size reduced by the number of model parameters estimated from the same data, forregressors or if an intercept is used.[23] In this case, so the denominator is.
Under the further assumption that the population error term is normally distributed, the researcher can use these estimated standard errors to createconfidence intervals and conducthypothesis tests about thepopulation parameters.
In the more general multiple regression model, there are independent variables:
where is the-th observation on the-th independent variable.If the first independent variable takes the value 1 for all,, then is called theregression intercept.
The least squares parameter estimates are obtained from normal equations. The residual can be written as
Thenormal equations are
In matrix notation, the normal equations are written as
where the element of is, the element of the column vector is, and the element of is. Thus is, is, and is. The solution is
Once a regression model has been constructed, it may be important to confirm thegoodness of fit of the model and thestatistical significance of the estimated parameters. Commonly used checks of goodness of fit include theR-squared, analyses of the pattern ofresiduals and hypothesis testing. Statistical significance can be checked by anF-test of the overall fit, followed byt-tests of individual parameters.
Interpretations of these diagnostic tests rest heavily on the model's assumptions. Although examination of the residuals can be used to invalidate a model, the results of at-test orF-test are sometimes more difficult to interpret if the model's assumptions are violated. For example, if the error term does not have a normal distribution, in small samples the estimated parameters will not follow normal distributions and complicate inference. With relatively large samples, however, acentral limit theorem can be invoked such that hypothesis testing may proceed using asymptotic approximations.
The response variable may be non-continuous ("limited" to lie on some subset of the real line). For binary (zero or one) variables, if analysis proceeds with least-squares linear regression, the model is called thelinear probability model. Nonlinear models for binary dependent variables include theprobit andlogit model. Themultivariate probit model is a standard method of estimating a joint relationship between several binary dependent variables and some independent variables. Forcategorical variables with more than two values there is themultinomial logit. Forordinal variables with more than two values, there are theordered logit andordered probit models.Censored regression models may be used when the dependent variable is only sometimes observed, andHeckman correction type models may be used when the sample is not randomly selected from the population of interest.
An alternative to such procedures is linear regression based onpolychoric correlation (or polyserial correlations) between the categorical variables. Such procedures differ in the assumptions made about the distribution of the variables in the population. If the variable is positive with low values and represents the repetition of the occurrence of an event, then count models like thePoisson regression or thenegative binomial model may be used.
When the model function is not linear in the parameters, the sum of squares must be minimized by an iterative procedure. This introduces many complications which are summarized inDifferences between linear and non-linear least squares.
In the middle, the fitted straight line represents the best balance between the points above and below this line. The dotted straight lines represent the two extreme lines, considering only the variation in the slope. The inner curves represent the estimated range of values considering the variation in both slope and intercept. The outer curves represent a prediction for a new measurement.[24]
Regression modelspredict a value of theY variable given known values of theX variables. Predictionwithin the range of values in the dataset used for model-fitting is known informally asinterpolation. Predictionoutside this range of the data is known asextrapolation. Performing extrapolation relies strongly on the regression assumptions. The further the extrapolation goes outside the data, the more room there is for the model to fail due to differences between the assumptions and the sample data or the true values.
Aprediction interval that represents the uncertainty may accompany the point prediction. Such intervals tend to expand rapidly as the values of the independent variable(s) moved outside the range covered by the observed data.
For such reasons and others, some tend to say that it might be unwise to undertake extrapolation.[25]
The assumption of a particular form for the relation betweenY andX is another source of uncertainty. A properly conducted regression analysis will include an assessment of how well the assumed form is matched by the observed data, but it can only do so within the range of values of the independent variables actually available. This means that any extrapolation is particularly reliant on the assumptions being made about the structural form of the regression relationship. If this knowledge includes the fact that the dependent variable cannot go outside a certain range of values, this can be made use of in selecting the model – even if the observed dataset has no values particularly near such bounds. The implications of this step of choosing an appropriate functional form for the regression can be great when extrapolation is considered. At a minimum, it can ensure that any extrapolation arising from a fitted model is "realistic" (or in accord with what is known).
There are no generally agreed methods for relating the number of observations versus the number of independent variables in the model. One method conjectured by Good and Hardin is, where is the sample size, is the number of independent variables and is the number of observations needed to reach the desired precision if the model had only one independent variable.[26] For example, a researcher is building a linear regression model using a dataset that contains 1000 patients (). If the researcher decides that five observations are needed to precisely define a straight line (), then the maximum number of independent variables () the model can support is 4, because
All major statistical software packages performleast squares regression analysis and inference.Simple linear regression and multiple regression using least squares can be done in somespreadsheet applications and on some calculators. While many statistical software packages can perform various types of nonparametric and robust regression, these methods are less standardized. Different software packages implement different methods, and a method with a given name may be implemented differently in different packages. Specialized regression software has been developed for use in fields such as survey analysis and neuroimaging.
^Francis Galton. "Typical laws of heredity", Nature 15 (1877), 492–495, 512–514, 532–533.(Galton uses the term "reversion" in this paper, which discusses the size of peas.)
^Francis Galton. Presidential address, Section H, Anthropology. (1885)(Galton uses the term "regression" in this paper, which discusses the height of humans.)
^Fotheringham, A. Stewart; Brunsdon, Chris; Charlton, Martin (2002).Geographically weighted regression: the analysis of spatially varying relationships (Reprint ed.). Chichester, England: John Wiley.ISBN978-0-471-49616-8.
^Steel, R.G.D, and Torrie, J. H.,Principles and Procedures of Statistics with Special Reference to the Biological Sciences.,McGraw Hill, 1960, page 288.
^Good, P. I.; Hardin, J. W. (2009).Common Errors in Statistics (And How to Avoid Them) (3rd ed.). Hoboken, New Jersey: Wiley. p. 211.ISBN978-0-470-45798-6.
Meade, Nigel; Islam, Towhidul (1995). "Prediction intervals for growth curve forecasts".Journal of Forecasting.14 (5):413–430.doi:10.1002/for.3980140502.
A. Sen, M. Srivastava,Regression Analysis — Theory, Methods, and Applications, Springer-Verlag, Berlin, 2011 (4th printing).
T. Strutz:Data Fitting and Uncertainty (A practical introduction to weighted least squares and beyond). Vieweg+Teubner,ISBN978-3-8348-1022-9.
Stulp, Freek, and Olivier Sigaud.Many Regression Algorithms, One Unified Model: A Review. Neural Networks, vol. 69, Sept. 2015, pp. 60–79.https://doi.org/10.1016/j.neunet.2015.05.005.