Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

st: Re: FE over two columns

From   Christopher Baum <>
To   tazz_ben <>
Subject   st: Re: FE over two columns
Date   Mon, 24 Oct 2011 13:41:38 -0400

Then something like

foreach c in US UK MX {
	g `c'dum = expt=="`c'" | impt=="`c'"

will work to generate the set of country dummies.  You could use the levelsof command to get the list of all the countries in your data.

I imagined that as you were speaking of FEs you meant you had panel data, as that term is usually used
in the context of panel data.


Kit Baum   |   Boston College Economics & DIW Berlin   |
                             An Introduction to Stata Programming  |
  An Introduction to Modern Econometrics Using Stata  |

On Oct 24, 2011, at 1:31 PM, tazz_ben wrote:

> Hi Christopher,
> If you are running time series panel data what you said makes a lot of
> sense.  But in my case, I'm running a model that occurs in a single year.
> You might say that's dumb (and I actually don't disagree), but it is a
> homework assignment (not my own research) I don't get to change the model.
> So, if I were to apply fixed effects in the way you are describing to my
> data, each row would have its own fixed effect; which obviously isn't what
> I want.
> So, what I'm wanting to do is not combine the two columns as you described
> with Group, but in fact there should be two 1 valued fixed effects on each
> row.  So, to your example, for UK->US trade data row, there should be the
> US Fixed Effect, and UK Fixed Effect.  For the US->Mexico trade data row,
> it should have 1 values for the US Fixed Effect and Mexico Fixed Effect.
> Ben
> ---
> <>
> This is probably a stupid question that can easily be done within Stata.
> So I have a gravity model with two columns containing the country names
> (obviously). I want to apply country fixed effects: which means the index
> of the FE model is over two columns (ie. a country specific dummy should
> be set to one regardless of whether it appears in column one or column
> two).
> I only have about 50 countries, so I can easily do this manually with
> excel then push it into stata; but I thought I should learn how to do this
> if Stata can do it internally.
> If the two columns are labeled exporter and importer (as is usual in
> analyzing trade data)
> you can't specify country fixed effects based on a country being either an
> X or an M, as the
> dummies would not be mutually exclusive (e.g. both US->UK and UK->US
> contain each of those
> countries). Usually with this sort of data you create fixed effects for
> all combinations, e.g.
> egen exorem = group(exporter importer)
> tsset exorem year (or whatever is your time unit)
> exorem will take on different values for each trade linkage.
> Kit
> Kit Baum | Boston College Economics & DIW Berlin |
> An Introduction to Stata Programming |
> An Introduction to Modern Econometrics Using Stata |
> *
> * For searches and help try:
> *
> *
> *

*   For searches and help try:

© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index