# Force a line through the origin

What does it mean: to force a line through the origin?

I interpret this to be making (forcing) the intercept as (0,0) in the regression procedure of an x-y scatterplot, but am not sure.

• Can you provide more context, for example regarding where someone may have used this expression? – Wolfgang Bangerth Feb 11 '16 at 6:20

I think that what you are trying to do is to find a line passing through a set of data which is able to best fit that set of data. A Least Square approach, for instance, could be used for this purpose. Force a line to pass through the origin means that if you have the general affine equation for the line as

$$y = mx +q$$

than the affine term $q$ is null, $q=0$.

Let assume that you have a set of data $Y \in \mathbb{R}^{N}$ evaluated in $X \in \mathbb{R}^{N}$. You want to find a relation between these dataset using a linear relation. You can describe this relation using a linear regression of the form

$$Y = \Phi \Theta$$

where in general $\Theta \in \mathbb{R}^{N+1}$ is the set of unknowns parameters able to desribe the relation between $X$ and $Y$ while $\Phi \in \mathbb{R}^{N \times N+1}$ is a suitable matrix build starting from $X$.

Let assume that $X$ is defined as follows:

$$X = [ x_1\ x_2\ \cdots\ x_N]$$

and the matrix $\Phi$ as

$$\Phi = \left[ \begin{matrix} x_1 & x_2 & \cdots & x_N & 1 \\ x_1 & x_2 & \cdots & x_N & 1 \\ \vdots & \cdots & \cdots & \ddots & \vdots \\ x_1 & x_2 & \cdots & x_N & 1 \\ \end{matrix} \right]$$

as it is possible to see, the last column of $\Phi$ multiplies the last element of the unknowns $\Theta$, which is considered as an affine term (beacause of the $1$ value).

If you want to force the regression line to pass through the origin, just set to zero the last column or neglect it while building the $\Phi$ matrix (be careful because if you remove the last column of $\Phi$ then you have also to reduce the size of $\Theta$).

Once you have your $\Phi$ matrix you can solve a linear regression problem (for instance) with the Least Square approach. The objective is to find $\Theta$ able to minimize the following fitness function $$\|Y-\Phi \Theta\|_2^2$$ where the operator $\| \cdot \|_2$ represents the two-norm operator of an array.

If no constraints are set, the analytical solution of $\Theta$ is:

$$\Theta = (\Phi^{T}\Phi)^{-1}\Phi^{T} Y$$