No announcement yet.
  • Filter
  • Time
  • Show
Clear All
new posts

  • Aggregate all fixed effects into one number

    Hi all,

    I am doing an OLS regression and would like to include three fixed effects into my model. The table below shows the variables I plan to include in my model. Column 2 is my dependent variable, columns 3-4 are my independent variables, and columns 5-7 are my variables I would like to include as fixed effects. (Note: the table is not representive of my data set and I just attached it to illustrate what I am trying to do). Without the fixed effects my do-file is the following: regress Dependent_Variable Independent_Variable1 Independent_Variable2. Now I would also like to include the fixed effects into the model. I have used the following code: regress Dependent_Variable Independent_Variable1 Independent_Variable2 i.Year i.Organisation i.City.

    I would like to get one number, which is aggregated over all my fixed effects. At the moment, I get a separate line for each value of my variables in columns 5-7. Does anyone know how to solve this issue?

    Thank you for your help!

    ID Dependent_variable Independent_Variable1 Independent_Variable2 Year Organisation City
    1 1 32 44 1990 1 1
    2 37 9 98 1991 1 2
    3 23 14 71 1995 2 2
    4 43 50 11 1993 3 3
    5 23 53 31 1998 3 4
    6 37 31 42 2000 3 5
    7 9 6 84 1991 4 6
    8 63 44 34 1995 5 7
    9 78 34 77 1993 6 7

  • #2
    I'm not sure I understand what you want to do here, but perhaps you mean that you would like to combine all three of these fixed effects into a single variable.

    egen fe3 = group(Year Organization City)
    regress Dependent_Variable Independent_Variable1 Independent_Variable2 i.fe3
    In the future, when showing data examples, please use the -dataex- command to do so. If you are running version 15.1 or a fully updated version 14.2, it is already part of your official Stata installation. If not, run -ssc install dataex- to get it. Either way, run -help dataex- to read the simple instructions for using it. -dataex- will save you time; it is easier and quicker than typing out tables. It includes complete information about aspects of the data that are often critical to answering your question but cannot be seen from tabular displays or screenshots. It also makes it possible for those who want to help you to create a faithful representation of your example to try out their code, which in turn makes it more likely that their answer will actually work in your data.

    When asking for help with code, always show example data. When showing example data, always use -dataex-.