In statistics and in machine learning, a linear predictor function is a linear function (linear combination) of a set of coefficients and explanatory variables (independent variables), whose value is used to predict the outcome of a dependent variable.[1] This sort of function usually comes in linear regression, where the coefficients are called regression coefficients. However, they also occur in various types of linear classifiers (e.g. logistic regression,[2] perceptrons,[3] support vector machines,[4] and linear discriminant analysis[5]), as well as in various other models, such as principal component analysis[6] and factor analysis. In many of these models, the coefficients are referred to as "weights".
The basic form of a linear predictor function
f(i)
f(i)=\beta0+\beta1xi1+ … +\betapxip,
where
xik
\beta0,\ldots,\betap
It is common to write the predictor function in a more compact form as follows:
This makes it possible to write the linear predictor function as follows:
f(i)=\boldsymbol\beta ⋅ xi
using the notation for a dot product between two vectors.
An equivalent form using matrix notation is as follows:
f(i)=\boldsymbol\betaTxi=
T | |
x | |
i |
\boldsymbol\beta
where
\boldsymbol\beta
xi
\boldsymbol\betaT
\boldsymbol\beta
\boldsymbol\betaT
\boldsymbol\betaTxi
An example of the usage of a linear predictor function is in linear regression, where each data point is associated with a continuous outcome yi, and the relationship written
yi=f(i)+\varepsiloni=\boldsymbol\betaTxi +\varepsiloni,
where
\varepsiloni
In some models (standard linear regression, in particular), the equations for each of the data points i = 1, ..., n are stacked together and written in vector form as
y=X\boldsymbol\beta+\boldsymbol\varepsilon,
y=\begin{pmatrix}y1\ y2\ \vdots\ yn\end{pmatrix}, X=\begin{pmatrix}x'1\ x'2\ \vdots\ x'n\end{pmatrix} =\begin{pmatrix}x11& … &x1p\\ x21& … &x2p\\ \vdots&\ddots&\vdots\\ xn1& … &xnp\end{pmatrix}, \boldsymbol\beta=\begin{pmatrix}\beta1\ \vdots\ \betap\end{pmatrix}, \boldsymbol\varepsilon=\begin{pmatrix}\varepsilon1\ \varepsilon2\ \vdots\ \varepsilonn\end{pmatrix}.
The matrix X is known as the design matrix and encodes all known information about the independent variables. The variables
\varepsiloni
This makes it possible to find optimal coefficients through the method of least squares using simple matrix operations. In particular, the optimal coefficients
\boldsymbol{\hat\beta}
\boldsymbol{\hat\beta}=(XTX)-1XTy.
The matrix
(XTX)-1XT
When a fixed set of nonlinear functions are used to transform the value(s) of a data point, these functions are known as basis functions. An example is polynomial regression, which uses a linear predictor function to fit an arbitrary degree polynomial relationship (up to a given order) between two sets of data points (i.e. a single real-valued explanatory variable and a related real-valued dependent variable), by adding multiple explanatory variables corresponding to various powers of the existing explanatory variable. Mathematically, the form looks like this:
yi=\beta0+\beta1xi+\beta2
2 | |
x | |
i |
+ … +\betap
p. | |
x | |
i |
In this case, for each data point i, a set of explanatory variables is created as follows:
(xi1=xi, xi2=
2, | |
x | |
i |
\ldots, xip=
p) | |
x | |
i |
and then standard linear regression is run. The basis functions in this example would be
\boldsymbol\phi(x)=(\phi1(x),\phi2(x),\ldots,\phip(x))=(x,x2,\ldots,xp).
This example shows that a linear predictor function can actually be much more powerful than it first appears: It only really needs to be linear in the coefficients. All sorts of non-linear functions of the explanatory variables can be fit by the model.
There is no particular need for the inputs to basis functions to be univariate or single-dimensional (or their outputs, for that matter, although in such a case, a K-dimensional output value is likely to be treated as K separate scalar-output basis functions). An example of this is radial basis functions (RBF's), which compute some transformed version of the distance to some fixed point:
\phi(x;c)=\phi(||x-c||)=\phi(\sqrt{(x1-
2 | |
c | |
1) |
+\ldots+(xK-
2}) | |
c | |
K) |
An example is the Gaussian RBF, which has the same functional form as the normal distribution:
\phi(x;c)=
-b||x-c||2 | |
e |
which drops off rapidly as the distance from c increases.
A possible usage of RBF's is to create one for every observed data point. This means that the result of an RBF applied to a new data point will be close to 0 unless the new point is near to the point around which the RBF was applied. That is, the application of the radial basis functions will pick out the nearest point, and its regression coefficient will dominate. The result will be a form of nearest neighbor interpolation, where predictions are made by simply using the prediction of the nearest observed data point, possibly interpolating between multiple nearby data points when they are all similar distances away. This type of nearest neighbor method for prediction is often considered diametrically opposed to the type of prediction used in standard linear regression: But in fact, the transformations that can be applied to the explanatory variables in a linear predictor function are so powerful that even the nearest neighbor method can be implemented as a type of linear regression.
It is even possible to fit some functions that appear non-linear in the coefficients by transforming the coefficients into new coefficients that do appear linear. For example, a function of the form
a+
2x | |
b | |
i1 |
+\sqrt{c}xi2
a,b,c
b'=b2,c'=\sqrt{c},
a+b'xi1+c'xi2,
The explanatory variables may be of any type: real-valued, binary, categorical, etc. The main distinction is between continuous variables (e.g. income, age, blood pressure, etc.) and discrete variables (e.g. sex, race, political party, etc.). Discrete variables referring to more than two possible choices are typically coded using dummy variables (or indicator variables), i.e. separate explanatory variables taking the value 0 or 1 are created for each possible value of the discrete variable, with a 1 meaning "variable does have the given value" and a 0 meaning "variable does not have the given value". For example, a four-way discrete variable of blood type with the possible values "A, B, AB, O" would be converted to separate two-way dummy variables, "is-A, is-B, is-AB, is-O", where only one of them has the value 1 and all the rest have the value 0. This allows for separate regression coefficients to be matched for each possible value of the discrete variable.
Note that, for K categories, not all K dummy variables are independent of each other. For example, in the above blood type example, only three of the four dummy variables are independent, in the sense that once the values of three of the variables are known, the fourth is automatically determined. Thus, it's really only necessary to encode three of the four possibilities as dummy variables, and in fact if all four possibilities are encoded, the overall model becomes non-identifiable. This causes problems for a number of methods, such as the simple closed-form solution used in linear regression. The solution is either to avoid such cases by eliminating one of the dummy variables, and/or introduce a regularization constraint (which necessitates a more powerful, typically iterative, method for finding the optimal coefficients).[7]