How can you do regression when two groups of variables sum to each other? Suppose I have a model like this:
$$
y = \beta_1x_1 + \beta_2x_2 + \beta_3z_1 +\beta_4z_2 + \epsilon
$$
where $\epsilon$ is noise.
It so happens that
$$x_1 + x_2 = z_1 + z_2$$
but there is no other relationship between the individual variables. The values are numeric, not binary indicators. 
How can I estimate the $\beta$ coefficients?
 A: Under the assumption that the constraint holds strictly, i.e.
$$
x_1 + x_2 = z_1 + z_2
$$
You could now transform your model to operate on 3 random variables. 
$$
z_2 = x_1 + x_2 - z_1
$$ 
So your new model becomes
$$
y = (\beta_1 + \beta_4)x_1 + (\beta_2 + \beta_4)x_2 + (\beta_3 - \beta_4)z_1 + \epsilon
$$
$$
y = \beta_1'x_1 + \beta_2'x_2 + \beta_3'z_1 + \epsilon
$$
You can now just find the regression coefficients for this new model.
The constraint essentially reduces the number of degrees of freedom that your system has. Because of the constraint, one of the 4 variables $(x_1, x_2, z_1, z_2)$ doesn't contribute any information to the model and hence can be removed. 
To find the regression coefficients, if your data set is small enough, you could use the analytical solution derived which minimises the squared L2 Norm.
$$
\min_{\mathbf{b}} \|\mathbf{Y} - \mathbf{Xb}\|_2^2
$$
Where, $\mathbf{b}$ is the vector of coefficients, $\mathbf{b}$ is the vector regression coefficients, $\mathbf{y}$ is the vector of sample y values and $\mathbf{X}$ is the data matrix of sample values for variables $x_1, x_2, z_1$
If you have $m$ samples, 
$$
\mathbf{b} = \begin{bmatrix}
\beta_1'\\
\beta_2'\\
\beta_3'
\end{bmatrix}
$$
$$
\mathbf{y} = \begin{bmatrix}
y^{(1)}\\
y^{(2)}\\
y^{(3)}\\
.\\
y^{(m)}\\
\end{bmatrix}
$$
where $y^{(i)}$ is the $y$ sample value for the $i$th sample. and
$$
\mathbf{X} = \begin{bmatrix}
x_1^{(1)} & x_2^{(1)} & z_1^{(1)}\\
x_1^{(2)} & x_2^{(2)} & z_1^{(2)}\\
x_1^{(3)} & x_2^{(3)} & z_1^{(3)}\\
. & . & . &\\
x_1^{(m)} & x_2^{(m)} & z_1^{(m)}\\ 
\end{bmatrix}
$$
Where $(x_1^{(i)}, x_2^{(i)}, z_1^{(i)})$ are the sample values for the $ith sample. 
Analytically, the linear regression coefficients are given by 
$$
\mathbf{b} = (\mathbf{X'X})^{-1}\mathbf{X'y}
$$
I put the analytical solution up in case the blog article gets taken down, but this solution is available everywhere, Wikipedia included.
Blog Link - click here 
If the dataset isn't very small, you can alternatively employ mini-batch gradient descent. 
