Is there any explanation if running without intercept caused the change in coefficients of other variables ?
I am talking about a panel data regression.
xtreg y x
and
xtreg y x, nocons
Economics Stack Exchange is a question and answer site for those who study, teach, research and apply economics and econometrics. It only takes a minute to sign up.
Sign up to join this communityRunning an (OLS) regression with or without intercept will not change the other coefficients of the other covariates if the means of (all) these covariates are zero.
For simplicity, consider the case of one covariate. We have two regressions, the first with and the second without an intercept. $$ \begin{align*} &y_i = \alpha + \beta x_{i} + \varepsilon_i, \tag{1}\\ &y_i = \gamma x_i + \delta_i \tag{2} \end{align*} $$ For the first regression, you will estimate the coefficients by setting the following sample moment conditions: $$ \begin{align*} &\frac{1}{n} \sum_i \varepsilon_i = 0,\\ &\frac{1}{n} \sum_i \varepsilon_i x_i = 0 \end{align*} $$ So: $$ \begin{align*} &\frac{1}{n} \sum_i y_i = \hat \alpha + \hat \beta \left(\frac{1}{n} \sum_i x_i\right),\\ &\frac{1}{n} \sum_i y_ix_i = \hat \alpha \left(\frac{1}{n} \sum_i x_i\right) + \hat \beta \left(\frac{1}{n} \sum_i (x_i)^2\right) \end{align*} $$ Then: $$ \begin{align*} &\hat \alpha = \left(\frac{1}{n} \sum_i y_i\right) - \hat \beta \left(\frac{1}{n} \sum_i x_i\right),\\ &\frac{1}{n} \sum_i y_i x_i = \left(\frac{1}{n} \sum_i y_i\right) \left( \frac{1}{n} \sum_i x_i\right) - \hat \beta \left(\frac{1}{n} \sum_i x_i\right)^2 + \hat \beta \left(\frac{1}{n} \sum_i (x_i)^2\right), \end{align*} $$ So using $\widehat{cov}(y_i, x_i) = \left(\frac{1}{n} \sum_i y_i x_i\right) - \left(\frac{1}{n} \sum_i y_i\right) \left( \frac{1}{n} \sum_i x_i\right)$ and $\widehat{var}(x_i) = \left(\frac{1}{n} \sum_i (x_i)^2\right) - \left(\frac{1}{n} \sum_i x_i\right)^2$: $$ \hat \beta = \frac{\widehat{cov}(y_i, x_i)}{\widehat{var}(x_i)}. \tag{3} $$ For the regression $(2)$ without intercept, we only have the second moment condition: $$ \begin{align*} &\frac{1}{n} \sum_i \delta_i x_i = 0,\\ \to &\frac{1}{n} \sum_i y_i x_i = \hat \gamma \left(\frac{1}{n} \sum_i (x_i)^2\right) \end{align*} $$ So: $$ \hat \gamma = \frac{\frac{1}{n} \sum_i y_i x_i}{\frac{1}{n} \sum_i (x_i)^2} \tag{4} $$ Comparing $(3)$ and $(4)$, we see that they are the same if the mean of $x$ is zero: $\frac{1}{n} \sum_i x_i = 0$.
The figure below demonstrates. We have 5 data points with $\frac{1}{n} \sum_i x_i = 0$. We see that the two regression lines, the black with intercept and the red without intercept have the same slope.
While the previous answer was very instructive, the correct answer for Stata is that xtreg y x, nocons
will result in error r(198) option noconstant not allowed
. I don't know why Stata programmers did not allow noconstant option for random effects model, but that's a different question.