# Is detrending a variable equivalent to including a time trend in the regression?

Suppose that I have determined that one or more of the variables in my linear model is trend stationary. Does it suffice to then simply include the trend terms in my model, or do I have to detrend (by explicity subtrating out the trend)?

My hand-wavy argument is as follows. Suppose that I wish to regress $$y_t$$ on $$x_t$$ but discover that $$y_t$$ is linear-trend stationary ($$x_t$$ is already stationary, say). If I fit the model $$y_t = \beta_0 + \beta_1 x_t + \beta_2 t + \epsilon_t\ ,$$ I can rearrange this to obtain $$y_t - \beta_0 - \beta_2 t = \beta_1 x_t + \epsilon_t\ ;$$ is it true that the LHS "equals" (this is the hand-wavy part) the residuals $$\delta_t$$ of the model $$y_t = \gamma_0 + \gamma_1 t + \delta_t\ ?$$ If this were to be the case, I would think that one could detrend $$y_t$$ by simply including time terms of the desired order.

Does this argument work? (The upside would be easy interpretability of my regression coefficients. The model would also be easier to work with in a VAR context etc.)

If my argument does not work, similarly to this question then, I would like to understand how one might go about interpreting the coefficients of a linear regression of $$\hat{y_t}$$ on $$\hat{x_t}$$ when I have detrended one or both of the variables. (It must be said here that one possible benefit of this method is when my sample is extremely small; detrending before fitting allows me to save a crucial few df's.)

• It isn't clear what your re-arrangement does, because you don't distinguish parameters from their estimates. Your question looks like what is discussed at stats.stackexchange.com/questions/46185 -- perhaps that helps?
– whuber
Aug 18 '21 at 17:18
• @whuber All parameters above were meant to be estimates. I am given the data $x_t$ and $y_t$ and nothing else. Hence all claims about stationarity or lack thereof are made with recourse to statistical tests. Aug 19 '21 at 8:21
• The post you linked to is extremely insightful, thank you! If I have understood correctly, my hand-wavy argument would work if the third equation above were not an estimate but rather a "matcher" equation in your terminology. Is this right? Aug 19 '21 at 8:27

As @whuber points out in the comments, this question is in fact similar to an existing post. For anyone interested in reference that explicitly deals with time trends, the argument can be found in Woolridge's, "Introductory Econometrics", Ch. 10, in the section entitled "A detrending interpretation of regressions with a time trend". The argument is the same "partialling out interpretation of OLS" that @whuber discusses in the above post.

In sum, the answer to the posted question is yes: including a time trend (or trends, of desired order) is equivalent to detrending. More precisely, the estimate $$\hat{\beta_1}$$ obtained by regressing $$y_t$$ on $$x_t$$ is exactly the same as that obtained by regressing $$\dot{y_t}$$ on $$\dot{x_t}$$, where $$\dot{y_t}$$ and $$\dot{x_t}$$ are the residuals obtained by regressing $$y_t$$ and $$x_t$$ on $$t$$ respectively.

As @Anthony's answer correctly points out, Wooldridge indeed contains this statement, but unfortunately gives no proof. As I was unable to find it elsewhere too, here is my attempt.

Let $$\mathbf{y}$$ be our dependent variable and $$\mathbf{x}_1$$ be the predictor. Let's call $$\mathbf{X}=\begin{bmatrix} \mathbf{1} & \mathbf{t}\end{bmatrix}$$, where $$\mathbf{1}$$ is the vector of all ones and $$\mathbf{t}$$ contains the sequence of integers from $$1$$ to $$T$$ (with $$T$$ being the length of the time series). Vectors are considered column vectors by default.

De-trending approach. We regress both the dependent and the predictor on $$\mathbf{t}$$ (and intercept), take the residuals, and then regress the residuals of the dependent on the residuals of the predictor. (As the residuals are the de-trended values.) We take the coefficient of the de-trended predictor as the result. Residuals have zero mean by definition, so we don't need an intercept in this latter regression.

Both of the regressions in the first step have an intercept and the $$\mathbf{t}$$ as predictors, i.e., the design matrix is $$\mathbf{X}$$ in both cases. Lets denote the residual maker matrix with $$\mathbf{M}=\mathbf{I}-\mathbf{X}\left(\mathbf{X}\mathbf{X}^T\right)^{-1}\mathbf{X}^T$$, thus the residuals (de-trended values) of the dependent are $$\mathbf{M}\mathbf{y}$$, while the predictor's is $$\mathbf{M}\mathbf{x}_1$$. We now regress the former with the latter (without intercept). The OLS estimates for the coefficients are ''$$\left(\mathbf{X}^T\mathbf{X}\right)^{-1}\mathbf{X}^T\mathbf{y}$$'', here $$\mathbf{M}\mathbf{y}$$ plays the role of $$\mathbf{y}$$ and $$\mathbf{M}\mathbf{x}_1$$ plays the role of $$\mathbf{X}$$. Thus the estimates are $$\left(\mathbf{x}_1^T\mathbf{M}^T\mathbf{M}\mathbf{x}_1\right)^{-1}\mathbf{x}_1^T\mathbf{M}^T\mathbf{M}\mathbf{y}=\left(\mathbf{x}_1^T\mathbf{M}\mathbf{x}_1\right)^{-1}\mathbf{x}_1^T\mathbf{M}\mathbf{y} = \widehat{\beta}_{\text{de-trending}},$$ where we used the fact that $$\mathbf{M}$$ is symmetric ($$\mathbf{M}^T=\mathbf{M}$$) and idempotent ($$\mathbf{M}\mathbf{M}=\mathbf{M}$$).

Regression approach. We regress $$\mathbf{y}$$ on $$\mathbf{t}$$ and $$\mathbf{x}_1$$ (with intercept) and take the coefficient of $$\mathbf{x}_1$$ as the result.

The design matrix in this regression is $$\begin{bmatrix} \mathbf{1} & \mathbf{t} & \mathbf{x}_1\end{bmatrix} = \begin{bmatrix} \mathbf{X} & \mathbf{x}_1\end{bmatrix}$$, so the ''$$\mathbf{X}^T\mathbf{X}$$'' matrix is $$\begin{bmatrix}\mathbf{X}^T\mathbf{X} & \mathbf{X}^T \mathbf{x}_1 \\ \mathbf{x}_1^T \mathbf{X} & \mathbf{x}_1^T\mathbf{x}_1\end{bmatrix}.$$ To invert this, we use the block matrix inversion formula. The Schur-complement (''$$D-CA^{-1}B$$'') is $$\mathbf{x}_1^T\mathbf{x}_1-\mathbf{x}_1^T \mathbf{X}\left(\mathbf{X}^T\mathbf{X}\right)^{-1}\mathbf{X}^T \mathbf{x}_1 = \mathbf{x}_1^T \left[\mathbf{I}-\mathbf{X}\left(\mathbf{X}^T\mathbf{X}\right)^{-1}\mathbf{X}^T\right]\mathbf{x}_1 = \mathbf{x}_1^T \mathbf{M} \mathbf{x}_1,$$ therefore the bottom row of the inverse is $$\begin{bmatrix}-\left(\mathbf{x}_1^T \mathbf{M} \mathbf{x}_1\right)^{-1}\mathbf{x}_1^T \mathbf{X}\left(\mathbf{X}^T\mathbf{X}\right)^{-1} & \left(\mathbf{x}_1^T \mathbf{M} \mathbf{x}_1\right)^{-1}\end{bmatrix}.$$ Luckily, we will need only this row, as we only have to extract the last coefficient (that'll pertain to $$\mathbf{x}_1$$, that we'll need). We multiply ''$$\left(\mathbf{X}^T\mathbf{X}\right)^{-1}$$'' with ''$$\mathbf{X}^T\mathbf{y}$$'', so, to obtain the last coefficient, we multiply this above last row with ''$$\mathbf{X}^T\mathbf{y}$$'': $$-\left(\mathbf{x}_1^T \mathbf{M} \mathbf{x}_1\right)^{-1}\mathbf{x}_1^T \mathbf{X}\left(\mathbf{X}^T\mathbf{X}\right)^{-1}\mathbf{X}^T\mathbf{y} + \left(\mathbf{x}_1^T \mathbf{M} \mathbf{x}_1\right)^{-1}\mathbf{X}^T\mathbf{x}_1\mathbf{y} = \left(\mathbf{x}_1^T \mathbf{M} \mathbf{x}_1\right)^{-1}\mathbf{x}_1^T \left[\mathbf{I}-\mathbf{X}\left(\mathbf{X}^T\mathbf{X}\right)^{-1}\mathbf{X}^T\right]\mathbf{y} = \left(\mathbf{x}_1^T \mathbf{M} \mathbf{x}_1\right)^{-1}\mathbf{x}_1^T\mathbf{M}\mathbf{y} = \widehat{\beta}_{\text{regression}}.$$

Thus, we see that $$\widehat{\beta}_{\text{de-trending}}=\widehat{\beta}_{\text{regression}}$$, QED.

(I am not aware of a literature reference for this proof, although surely there is; I'd be also interested in this. Also, it is entirely possible that there is an easier way to prove the statement.)

• This is just a special case of the Frisch-Waugh(-Lovell) theorem. You can find proofs in many econometrics books (e.g., Davidson & MacKinnon, 2003). Dec 20 '21 at 8:05
• @statmerkur Aaaaaaah, I knew I was overlooking something trivial... I think you should transform this comment to an answer, this is the best - and most direct - answer to the question. Dec 20 '21 at 10:14