<p>When you have a time invariant variable distance, then you can run a random effect model. If you use the fixed effect model the time invariant variable cannot be estimated.</p>

CC BY-SA 4.0
2021-11-14T10:42:22.670Z
2021-11-14T10:42:22.670Z
Macosso
<p>I think You should be able to run the following type of regression:
<span class="math-container">$$
\ln X_{i,j,t} = C + F^X_i + F^M_j + \delta_t + \alpha \ln D_{i,j}.
$$</span>
Where <span class="math-container">$X_{i,j}$</span> is the trade flow from <span class="math-container">$i$</span> to <span class="math-container">$j$</span> at time <span class="math-container">$t$</span>, <span class="math-container">$F^X_i$</span> and <span class="math-container">$F^M_j$</span> are exporter and importer fixed effects, <span class="math-container">$\delta_t$</span> is a time fixed effect and <span class="math-container">$D_{i,j}$</span> is the distance.</p>
<ul>
<li>You cannot add a country pair FE, <span class="math-container">$F_{i,j}$</span> as this will eat up the distance variable <span class="math-container">$D_{i,j}$</span>.</li>
<li>If you only have one destination <span class="math-container">$j$</span>, you cannot add the desitnation fixed effect <span class="math-container">$F^M_j$</span> as this will be eaten up by the constant <span class="math-container">$C$</span>. Also you cannot add both destination fixed effects <span class="math-container">$F^X_i$</span> and <span class="math-container">$D_{i,j}$</span> as they will be colinear.</li>
<li>If you only have one origin <span class="math-container">$i$</span>, you cannot add an origin fixed effect <span class="math-container">$F^X_i$</span> as it is colinear with the intercept. Also, you cannot add both <span class="math-container">$F^M_j$</span> and <span class="math-container">$D_{i,j}$</span> as these are also colinear.</li>
<li>If you have only one origin and one destination, you cannot add <span class="math-container">$F^X_i$</span>, <span class="math-container">$F^M_j$</span> nor <span class="math-container">$D_{i,j}$</span> as all of them are swallowed up by the constant term <span class="math-container">$C$</span>.</li>
<li>If you have a panel, you should, in general, have no problem adding a time fixed effect <span class="math-container">$\delta_t$</span>.</li>
</ul>

CC BY-SA 4.0
2021-11-13T10:14:06.650Z
2021-11-13T10:14:06.650Z
tdm
<p>I'm working on a gravity model with a panel data. However, the distance variable for this model is a time-fixed effect so it doesn't seem possible to run the model with it.</p>
<p>What can I do to add this variable to the model?</p>
<p>Thanks in advance.</p>

<econometrics><international-trade><international-economics>
How can I add distance variable to panel data?
Katie
# How can I add distance variable to panel data?

(Asked by: username_0 on 2021-11-10)

I'm working on a gravity model with a panel data. However, the distance variable for this model is a time-fixed effect so it doesn't seem possible to run the model with it.

What can I do to add this variable to the model?

Thanks in advance.

**Tags:** econometrics, international-trade, international-economics

---

## 2 answers

### Answer by username_1 on 2021-11-14. Score: 0

When you have a time invariant variable distance, then you can run a random effect model. If you use the fixed effect model the time invariant variable cannot be estimated.


---

### Answer by username_2 on 2021-11-13. Score: 0

I think You should be able to run the following type of regression:
$$
\ln X\_{i,j,t} = C + F^X\_i + F^M\_j + \delta\_t + \alpha \ln D\_{i,j}.
$$
Where $X\_{i,j}$ is the trade flow from $i$ to $j$ at time $t$, $F^X\_i$ and $F^M\_j$ are exporter and importer fixed effects, $\delta\_t$ is a time fixed effect and $D\_{i,j}$ is the distance.

* You cannot add a country pair FE, $F\_{i,j}$ as this will eat up the distance variable $D\_{i,j}$.
* If you only have one destination $j$, you cannot add the desitnation fixed effect $F^M\_j$ as this will be eaten up by the constant $C$. Also you cannot add both destination fixed effects $F^X\_i$ and $D\_{i,j}$ as they will be colinear.
* If you only have one origin $i$, you cannot add an origin fixed effect $F^X\_i$ as it is colinear with the intercept. Also, you cannot add both $F^M\_j$ and $D\_{i,j}$ as these are also colinear.
* If you have only one origin and one destination, you cannot add $F^X\_i$, $F^M\_j$ nor $D\_{i,j}$ as all of them are swallowed up by the constant term $C$.
* If you have a panel, you should, in general, have no problem adding a time fixed effect $\delta\_t$.


---

