<p>You need to collect more data if you want to use xtlogit. If the dependent variable does not vary in any group it is not possible to estimate the coefficients of fixed effects logit which uses within estimator.</p>
<p>You can also use some different models. For example, you could do pooled logit (just do regular logit on pooled data) or random effects logit (xtlogit with re option). However, all these models have different advantages and disadvantages so you should probably do some research on them before you do this.</p>

CC BY-SA 4.0
2023-04-04T11:40:39.950Z
2023-04-04T11:40:39.950Z
csilvia
<p>In my case, I am finding pscore for doing PSM. To get there, I need to run the logistic regression to get the pscore.In my setting, I have 7 countries, all firms in country A have the &quot;treatment&quot; variables equal to 1, otherwise 0.
My logit regression is</p>
<pre><code>xtset firm year
xtlogit treatment  firm-level-variables  country-level-variables i.year, fe
</code></pre>
<p>while treatment equal to1 if firms in country A and 0 otherwise. firm-level-variables includes firm size, firm age... country-level variables include lngdp, unemployment ....</p>
<p>When running the regression</p>
<p>Code:</p>
<pre><code>xtlogit treatment firm_age i.year, fe
</code></pre>
<p>I got the error immediately</p>
<p>Code:</p>
<pre><code>outcome does not vary in any group
</code></pre>
<p>So, I asked myself and think this means that in at least one group, all observations have either a 0 or a 1 as the outcome variable. It makes sense because all observations of firms in country A will have treatment =1 and all observations of firms in other countries will have treatment=0, so they wont vary.</p>
<p>I am not sure whether my understanding is correct. If it is the case, would you please guide me how to overcome the problem. Thank you.</p>

<econometrics><stata>
How to deal with "outcome does not vary in any group" when dealing with xtlogit
Phil Nguyen
# How to deal with "outcome does not vary in any group" when dealing with xtlogit

(Asked by: username_0 on 2023-04-04)

In my case, I am finding pscore for doing PSM. To get there, I need to run the logistic regression to get the pscore.In my setting, I have 7 countries, all firms in country A have the "treatment" variables equal to 1, otherwise 0.
My logit regression is
xtset firm year
xtlogit treatment  firm-level-variables  country-level-variables i.year, fe

while treatment equal to1 if firms in country A and 0 otherwise. firm-level-variables includes firm size, firm age... country-level variables include lngdp, unemployment ....
When running the regression
Code:
xtlogit treatment firm_age i.year, fe

I got the error immediately
Code:
outcome does not vary in any group

So, I asked myself and think this means that in at least one group, all observations have either a 0 or a 1 as the outcome variable. It makes sense because all observations of firms in country A will have treatment =1 and all observations of firms in other countries will have treatment=0, so they wont vary.
I am not sure whether my understanding is correct. If it is the case, would you please guide me how to overcome the problem. Thank you.

**Tags:** econometrics, stata

---

## 1 answers

### Answer by username_1 on 2023-04-04. Score: 2

You need to collect more data if you want to use xtlogit. If the dependent variable does not vary in any group it is not possible to estimate the coefficients of fixed effects logit which uses within estimator.

You can also use some different models. For example, you could do pooled logit (just do regular logit on pooled data) or random effects logit (xtlogit with re option). However, all these models have different advantages and disadvantages so you should probably do some research on them before you do this.


---

