Regression analysis

From Hidden Wiki
Jump to navigation Jump to search

Template:Regression bar Template:Machine learning bar

File:Normdist regression.png
Regression line for 50 random points in a Gaussian distribution around the line y=1.5x+2 (not shown).

In statistical modeling, regression analysis is a set of statistical processes for estimating the relationships between a dependent variable (often called the 'outcome variable') and one or more independent variables (often called 'predictors', 'covariates', or 'features'). The most common form of regression analysis is linear regression, often using the method of ordinary least squares, which typically estimates the conditional expectation (i.e., the average value in the full population) of the dependent variable when the independent variables are fixed. Less common types of regression estimate different location parameters of the dependent variable given values of the independent variables, for example in quantile regression or Necessary Condition Analysis[1] (NCA). Moreover, variants such as nonparametric regression allow the regression function to lie in a broader set of functions, which may be infinite-dimensional.

Regression analysis is primarily used for two conceptually distinct purposes. First, regression analysis is widely used for prediction and forecasting, where its use has substantial overlap with the field of machine learning. In this context, regression reveals relationships between the dependent variable and the collection of independent variables in a given model. Second, in some situations regression analysis can be used to infer causal relationships between the independent and dependent variables. As documented in ordinary least squares, this interpretation can be easily abused without rigorously stated assumptions and should be pursued with caution, especially in observational data.[2][3]

History

The earliest form of regression was the method of least squares, which was published by Legendre in 1805,[4] and by Gauss in 1809.[5] 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,[6] including a version of the Gauss–Markov theorem.

The term "regression" was coined by Francis Galton in the nineteenth 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 as regression toward the mean).[7][8] For Galton, regression had only this biological meaning,[9][10] but his work was later extended by Udny Yule and Karl Pearson to a more general statistical context.[11][12] In the work of Yule and Pearson, the joint distribution of the response and explanatory variables is assumed to be Gaussian. This assumption was weakened by R.A. Fisher in his works of 1922 and 1925.[13][14][15] Fisher assumed that the conditional 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 used electromechanical desk "calculators" to calculate regressions. Before 1970, it sometimes took up to 24 hours to receive the result from one regression.[16]

Regression methods continue to be an area of active research. In recent decades, new methods have been developed for robust regression, regression involving correlated responses such as time series and growth 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, and causal inference with regression.

Regression Model

Regression models involve the following components:

  • The unknown parameters, often denoted as <math>\beta</math>, which may represent a scalar or a vector.
  • The independent variables, which are observed in data and often denoted as a vector <math>X_i</math> (where <math>i</math> denotes a row of data).
  • The dependent variable, which are observed in data and often denoted using the scalar <math>Y_i</math>.
  • The error terms, which are not directly observed in the data and are often denoted using the scalar <math>e_i</math>.

In various fields of application, different terminologies are used in place of dependent and independent variables.

Most regression models propose that <math>Y_i</math> is a function of <math>X_i</math> and <math> \beta</math>, with <math>e_i</math> representing and additive error term that may stand in for unmodeled determinants of <math>Y_i</math> or random statistical noise:

<math>Y_i = f (X_i, \beta) + e_i</math>

Many common regression models, including ordinary least squares, are designed to model the conditional expectation: <math>f(X_i, \beta) = E(Y_i|X_i)</math>. To carry out regression analysis, the form of the function <math>f</math> must be specified. Sometimes the form of this function is based on knowledge about the relationship between <math>Y_i</math> and <math>X_i</math> that does not rely on the data. If no such knowledge is available, a flexible or convenient form for <math>f</math> is chosen. For example, a simple univariate regression may propose <math>f(X_i, \beta) = \beta_0 + \beta_1 X_i</math>, suggesting that the researcher believes <math>Y_i = \beta_0 + \beta_1 X_i + e_i</math> to be a reasonable approximation for the statistical process generating the data.

Once the researcher determines their preferred statistical model, different forms of regression analysis provide tools to estimate the parameters <math>\beta </math>. For example, least squares (including its most common form, ordinary least squares) finds the value of <math>\beta </math> that minimizes the sum of squared errors (<math>\sum_i e_i^2 = \sum_i (Y_i - f(X_i, \beta))^2</math>). Least squares is widely used because it approximates the conditional expectation <math>E(Y_i|X_i)</math>.[5] However, alternative methods are useful when the researcher wants to model a function <math>f(X_i,\beta) \neq E(Y_i | X_i)</math>, such as least absolute deviations or quantile regression, and the researcher's goal will guide the methods she uses. Regardless, a given regression method will ultimately provide an estimate of <math>\beta</math>, usually denoted <math>\hat{\beta}</math> to distinguish the estimate from the true (unknown) parameter value that generated the data. Using this estimate, the researcher can then use the fitted value <math>\hat{Y_i} = f(X_i,\hat{\beta})</math> for prediction or to assess the accuracy of the model in explaining the data. Whether the researcher is intrinsically interested in the estimate <math>\hat{\beta}</math> or the predicted value <math>\hat{Y_i}</math> will depend on context and her goals.

It it important to note that there must be sufficient data to estimate a regression model. For example, suppose that a researcher has access to <math>N</math> rows of data with three independent variables: <math>(Y_i, X_{1i}, X_{2i})</math>. Suppose further that the researcher wants to estimate a linear model via least squares: <math>Y_i = \beta_0 + \beta_1 X_{1i} + \beta_2 X_{2i} + e_i</math>. If she only has access to <math>N=2</math> data points, then she could find infinitely many combinations <math>(\beta_0, \beta_1, \beta_2)</math> that minimize the sum of squares errors equally well: she can choose any combination that satisfies <math>Y_i = \beta_0 + \beta_1 X_{1i} + \beta_2 X_{2i}</math>, all of which lead to <math>\sum_i e_i = 0</math> and (equivalently) fit the data perfectly. To understand why she has infinitely many options, note that she is facing a system of <math>N=2</math> equations and wants to solve for 3 unknowns, which makes the system underdetermined in the jargon of linear algebra. Visually, one can find infinitely many 3-dimensional planes that go through <math>N=2</math> fixed points... More generally, to estimate a least squares model with <math>k</math> distinct parameters, one must have <math>N \geq k</math> distinct data points. If <math>N > k</math>, then there does not generally exist a set of parameters that will perfectly fit the data. The quantity <math>(N-k)</math> appears often in regression analysis, and is referred to as the degrees of freedom in the model. Moreover, the independent variables <math>(X_{1i}, X_{2i}, ..., X_{ki})</math> must be linear independent, meaning that one cannot construct any of the variables by adding and multiplying the remaining variables. As discussed in ordinary least squares, this condition ensures that <math>(X^T X)</math> is an Invertible matrix and therefore a solution <math>\hat{\beta}</math> exists.

Underlying Assumptions

Classical assumptions for regression analysis include:

  • The sample is representative of the population for the inference prediction.
  • The independent variables are measured with no error.
  • The independent variables are linearly independent.
  • The error is a random variable with a mean of zero conditional on the explanatory variables.
  • The variance of the error is constant across observations (homoscedasticity).
  • The errors are uncorrelated, that is, the variance–covariance matrix of the errors is diagonal and each non-zero element is the variance of the error.

These are sufficient conditions for the least-squares estimator to possess desirable properties: in particular, the Gauss–Markov assumptions imply that the parameter estimates will be unbiased, consistent, and efficient 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, since these modeling assumptions are unlikely to hold exactly. For example, modeling errors-in-variables can lead to reasonable estimates independent variables are measured with errors. Heteroscedasticity-consistent standard errors allow the variance of <math>e_i</math> to change across values of <math>X_i</math>. Correlated errors that exist within subsets of the data or follow specific patterns can be handled using clustered standard errors, geographic weighted regression, or Newey–West standard errors, among other techniques. When rows of data correspond to locations in space, the choice of how to model <math>e_i</math> within geographic units can have important consequences.[17][18]

Linear regression

Template:Main Template:Hatnote In linear regression, the model specification is that the dependent variable, <math> y_i </math> is a linear combination of the parameters (but need not be linear in the independent variables). For example, in simple linear regression for modeling <math> n </math> data points there is one independent variable: <math> x_i </math>, and two parameters, <math>\beta_0</math> and <math>\beta_1</math>:

straight line: <math>y_i=\beta_0 +\beta_1 x_i +\varepsilon_i,\quad i=1,\dots,n.\!</math>

In multiple linear regression, there are several independent variables or functions of independent variables.

Adding a term in <math>x_i^2</math> to the preceding regression gives:

parabola: <math>y_i=\beta_0 +\beta_1 x_i +\beta_2 x_i^2+\varepsilon_i,\ i=1,\dots,n.\!</math>

This is still linear regression; although the expression on the right hand side is quadratic in the independent variable <math>x_i</math>, it is linear in the parameters <math>\beta_0</math>, <math>\beta_1</math> and <math>\beta_2.</math>

In both cases, <math>\varepsilon_i</math> is an error term and the subscript <math>i</math> 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:

<math> \widehat{y}_i = \widehat{\beta}_0 + \widehat{\beta}_1 x_i. </math>

The residual, <math> e_i = y_i - \widehat{y}_i </math>, is the difference between the value of the dependent variable predicted by the model, <math> \widehat{y}_i</math>, and the true value of the dependent variable, <math>y_i</math>. One method of estimation is ordinary least squares. This method obtains parameter estimates that minimize the sum of squared residuals, SSR:

<math>SSR=\sum_{i=1}^n e_i^2. \, </math>

Minimization of this function results in a set of normal equations, a set of simultaneous linear equations in the parameters, which are solved to yield the parameter estimators, <math>\widehat{\beta}_0, \widehat{\beta}_1</math>.

File:Linear regression.svg
Illustration of linear regression on a data set.

In the case of simple regression, the formulas for the least squares estimates are

<math>\widehat{\beta}_1=\frac{\sum(x_i-\bar{x})(y_i-\bar{y})}{\sum(x_i-\bar{x})^2}</math>
<math>\widehat{\beta}_0=\bar{y}-\widehat{\beta}_1\bar{x}</math>

where <math>\bar{x}</math> is the mean (average) of the <math>x</math> values and <math>\bar{y}</math> is the mean of the <math>y</math> values.

Under the assumption that the population error term has a constant variance, the estimate of that variance is given by:

<math> \hat{\sigma}^2_\varepsilon = \frac{SSR}{n-2}.\,</math>

This is called the mean square error (MSE) of the regression. The denominator is the sample size reduced by the number of model parameters estimated from the same data, <math>(n-p)</math> for <math>p</math> regressors or <math>(n-p-1)</math> if an intercept is used.[19] In this case, <math>p=1</math> so the denominator is <math>n-2</math>.

The standard errors of the parameter estimates are given by

<math>\hat\sigma_{\beta_1}=\hat\sigma_{\varepsilon} \sqrt{\frac{1}{\sum(x_i-\bar x)^2}}</math>
<math>\hat\sigma_{\beta_0}=\hat\sigma_\varepsilon \sqrt{\frac{1}{n} + \frac{\bar{x}^2}{\sum(x_i-\bar x)^2}}=\hat\sigma_{\beta_1} \sqrt{\frac{\sum x_i^2}{n}}. </math>

Under the further assumption that the population error term is normally distributed, the researcher can use these estimated standard errors to create confidence intervals and conduct hypothesis tests about the population parameters.

General linear model

Template:Hatnote Template:Hatnote In the more general multiple regression model, there are <math>p</math> independent variables:

<math> y_i = \beta_1 x_{i1} + \beta_2 x_{i2} + \cdots + \beta_p x_{ip} + \varepsilon_i, \, </math>

where <math>x_{ij}</math> is the <math>i</math>-th observation on the <math>j</math>-th independent variable. If the first independent variable takes the value 1 for all <math>i</math>, <math>x_{i1} = 1</math>, then <math>\beta_1</math> is called the regression intercept.

The least squares parameter estimates are obtained from <math>p</math> normal equations. The residual can be written as

<math>\varepsilon_i=y_i - \hat\beta_1 x_{i1} - \cdots - \hat\beta_p x_{ip}.</math>

The normal equations are

<math>\sum_{i=1}^n \sum_{k=1}^p x_{ij}x_{ik}\hat \beta_k=\sum_{i=1}^n x_{ij}y_i,\ j=1,\dots,p.\,</math>

In matrix notation, the normal equations are written as

<math>\mathbf{(X^\top X )\hat{\boldsymbol{\beta}}= {}X^\top Y},\,</math>

where the <math>ij</math> element of <math>\mathbf X</math> is <math>x_{ij}</math>, the <math>i</math> element of the column vector <math>Y</math> is <math>y_i</math>, and the <math>j</math> element of <math>\hat \boldsymbol \beta</math> is <math>\hat \beta_j</math>. Thus <math>\mathbf X</math> is <math>n \times p</math>, <math>Y</math> is <math>n \times 1</math>, and <math>\hat \boldsymbol \beta</math> is <math>p \times 1</math>. The solution is

<math>\mathbf{\hat{\boldsymbol{\beta}}= (X^\top X )^{-1}X^\top Y}.\,</math>

Diagnostics

Template:Main Template:Category see also Once a regression model has been constructed, it may be important to confirm the goodness of fit of the model and the statistical significance of the estimated parameters. Commonly used checks of goodness of fit include the R-squared, analyses of the pattern of residuals and hypothesis testing. Statistical significance can be checked by an F-test of the overall fit, followed by t-tests of individual parameters.

Interpretations of these diagnostic tests rest heavily on the model assumptions. Although examination of the residuals can be used to invalidate a model, the results of a t-test or F-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, a central limit theorem can be invoked such that hypothesis testing may proceed using asymptotic approximations.

Limited dependent variables

Limited dependent variables, which are response variables that are categorical variables or are variables constrained to fall only in a certain range, often arise in econometrics.

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 the linear probability model. Nonlinear models for binary dependent variables include the probit and logit model. The multivariate probit model is a standard method of estimating a joint relationship between several binary dependent variables and some independent variables. For categorical variables with more than two values there is the multinomial logit. For ordinal variables with more than two values, there are the ordered logit and ordered probit models. Censored regression models may be used when the dependent variable is only sometimes observed, and Heckman 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 on polychoric 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 the Poisson regression or the negative binomial model may be used.

Nonlinear regression

Template:Main

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 in Differences between linear and non-linear least squares.

Interpolation and extrapolation

File:CurveWeightHeight.png
In the middle, the interpolated straight line represents the best balance between the points above and below this line. The dotted lines represent the two extreme lines. The first curves represent the estimated values. The outer curves represent a prediction for a new measurement.[20]

Regression models predict a value of the Y variable given known values of the X variables. Prediction within the range of values in the dataset used for model-fitting is known informally as interpolation. Prediction outside this range of the data is known as extrapolation. 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.

It is generally advised Template:Citation needed that when performing extrapolation, one should accompany the estimated value of the dependent variable with a prediction interval that represents the uncertainty. 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.[21]

However, this does not cover the full set of modeling errors that may be made: in particular, the assumption of a particular form for the relation between Y and X. 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. Best-practice advice hereTemplate:Citation needed is that a linear-in-variables and linear-in-parameters relationship should not be chosen simply for computational convenience, but that all available knowledge should be deployed in constructing a regression model. 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).

Power and sample size calculations

There are no generally agreed methods for relating the number of observations versus the number of independent variables in the model. One rule of thumb conjectured by Good and Hardin is <math>N=m^n</math>, where <math>N</math> is the sample size, <math>n</math> is the number of independent variables and <math>m</math> is the number of observations needed to reach the desired precision if the model had only one independent variable.[22] For example, a researcher is building a linear regression model using a dataset that contains 1000 patients (<math>N</math>). If the researcher decides that five observations are needed to precisely define a straight line (<math>m</math>), then the maximum number of independent variables the model can support is 4, because

<math>\frac{\log 1000}{\log5}=4.29. </math>

Other methods

Although the parameters of a regression model are usually estimated using the method of least squares, other methods which have been used include:

Software

Template:Main list

All major statistical software packages perform least squares regression analysis and inference. Simple linear regression and multiple regression using least squares can be done in some spreadsheet 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.

See also

Template:Portal Template:Div col

Template:Div col end

References

1 }}
     | references-column-width 
     | references-column-count references-column-count-{{#if:1|{{{1}}}}} }}
   | {{#if: 
     | references-column-width }} }}" style="{{#if: 
   | {{#iferror: {{#ifexpr: 1 > 1 }}
     | Template:Column-width
     | Template:Column-count }}
   | {{#if: 
     | Template:Column-width }} }} list-style-type: {{#switch: 
   | upper-alpha
   | upper-roman
   | lower-alpha
   | lower-greek
   | lower-roman = {{{group}}}
   | #default = decimal}};">
  1. Necessary Condition Analysis
  2. Template:Cite book
  3. R. Dennis Cook; Sanford Weisberg Criticism and Influence Analysis in Regression, Sociological Methodology, Vol. 13. (1982), pp. 313–361
  4. A.M. Legendre. Nouvelles méthodes pour la détermination des orbites des comètes, Firmin Didot, Paris, 1805. “Sur la Méthode des moindres quarrés” appears as an appendix.
  5. 5.0 5.1 Chapter 1 of: Angrist, J. D., & Pischke, J. S. (2008). Mostly Harmless Econometrics: An Empiricist's Companion. Princeton University Press.
  6. C.F. Gauss. Theoria combinationis observationum erroribus minimis obnoxiae. (1821/1823)
  7. Template:Cite book
  8. Template:Cite journal
  9. 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.)
  10. Francis Galton. Presidential address, Section H, Anthropology. (1885) (Galton uses the term "regression" in this paper, which discusses the height of humans.)
  11. Template:Cite journal
  12. Template:Cite journal
  13. Template:Cite journal
  14. Template:Cite book
  15. Template:Cite journal
  16. Rodney Ramcharan. Regressions: Why Are Economists Obessessed with Them? March 2006. Accessed 2011-12-03.
  17. Template:Cite book
  18. Template:Cite journal
  19. 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.
  20. Template:Cite book
  21. Chiang, C.L, (2003) Statistical methods of analysis, World Scientific. Template:Isbn - page 274 section 9.7.4 "interpolation vs extrapolation"
  22. Template:Cite book
  23. Template:Cite journal
  24. Template:Cite journal

Further reading

Evan J. Williams, "I. Regression," pp. 523–41.
Julian C. Stanley, "II. Analysis of Variance," pp. 541–554.

External links

Template:Commons category

Template:Least squares and regression analysis Template:Statistics Template:Quantitative forecasting methods Template:Public health

Template:Authority control