Does anyone know the specific equations for the three parameters in a least-squares quadratic regression? I'm looking for something like $\beta_1=,\beta_2=,\beta_3=$ for each of $y=\beta_1+\beta_2x+\beta_3x^2$. To be clear, the right side of each of these equations should be evaluateable, using the data, to find the parameter. I was able to find the equations for linear regression on line, but google hasn't turned anything up for this.

• It is more likely to be numerically efficient and less prone to round-off error if you solve the appropriate linear system, rather than search for explicit formulae for the coefficients. – Daryl Dec 31 '12 at 12:45
• as a note - there is a stats-specific SE too stats.stackexchange.com, you can try there as well – galois Jan 20 '16 at 3:19

For $y =\beta_1 +\beta_2 x +\beta_3 x^2$, let's define $$x_1 = x$$ and $$x_2= x^2.$$ Now we can use the equations of multiple linear regression: $$S_{11}= \sum_{n=1}^N x_1^2- \frac{(\sum_{n=1}^N x_1)^2}{N}$$ $$S_{12}= \sum_{n=1}^N x_1x_2- \frac{(\sum_{n=1}^N x_1\sum_{n=1}^N x_2)}{N}$$ $$S_{22}= \sum_{n=1}^N x_2^2- \frac{(\sum_{n=1}^N x_2)^2}{N}$$ $$S_{y1}= \sum_{n=1}^N y x_1- \frac{(\sum_{n=1}^N y\sum_{n=1}^N x_1)}{N}$$ $$S_{y2}= \sum_{n=1}^N y x_2- \frac{(\sum_{n=1}^N y\sum_{n=1}^N x_2)}{N}$$ $$\overline{x}_1 = \frac{(\sum_{n=1}^N x_1)}{N}$$ $$\overline{x}_2 = \frac{(\sum_{n=1}^N x_2)}{N}$$ $$\overline{y} = \frac{(\sum_{n=1}^N y)}{N}$$ $$\beta_2=\frac{S_{y1}S_{22}-S_{y2}S_{12}}{S_{22}S_{11}-S_{12}^2}$$ $$\beta_3=\frac{S_{y2}S_{11}-S_{y1}S_{12}}{S_{22}S_{11}-S_{12}^2}$$ $$\beta_1=\overline{y}-\beta_2\overline{x}_1-\beta_3\overline{x}_2$$

Assuming $$y_j =\beta_1 +\beta_2 x_j +\beta_3 x_j^2 + \epsilon_j$$ for $$j = 1\dots n$$, we can write the matrix equation

$$\mathbf{Y}= \mathbf{XB} + \mathbf{E}$$

where

$$\mathbf Y = [y_1 \ y_2 \ \dots \ y_n]^T,$$

$$\mathbf X = \left[ \begin{array}{c} 1 & x_1 & x_1^2 \\ 1 & x_2 & x_2^2 \\ \vdots & \vdots & \vdots \\ 1 & x_n & x_n^2 \\ \end{array} \right],$$

$$\mathbf B = [\beta_1 \ \beta_2 \ \beta_3]^T,$$

and

$$\mathbf E = [e_1 \ e_2 \ \dots \ e_n]^T$$

We seek the vector $$\mathbf B$$ that minimizes

$$e_1^2 + 3_2^2 + \cdots + e_n^2 = \mathbf E^T \mathbf E$$

Assuming that $$\mathbf X^T \mathbf X$$ is nonsingular (usually a safe assumption), we find that

$$\mathbf B = (\mathbf X^T \mathbf X)^{-1} \mathbf X^T \mathbf Y$$