Announcement

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

  • Creating Dummy Variable for Years

    Hello!
    Can anyone please help me with the commands for creating a dummy variable?

    Currently, I have time series data between the years 2004-2019 (financial data).

    I want to create a dummy variable for the years (2008,2009,2010) = 1, all other years 0. This will represent the financial crisis years. I have 6 independent variables and hoping for the 7th to be my dummy variable.

    Anyway,
    I'm really stuck on how to do this and don't know what the commands are.

    Thanks everyone!

  • #2
    This is something you can probably find in any introduction to Stata. There are different ways to do this, but the simplest version is:
    Code:
    generate financial_crisis = 0
    replace financial_crisis = 1 if year==2008 | year==2009 | year==2010
    I assumed that the variable that indicates the year is called "year".

    Comment


    • #3
      What Felix says, or directly

      Code:
      generate financial_crisis = year==2008 | year==2009 | year==2010
      or

      Code:
      generate financial_crisis = inlist(year,2008,2009,2010)
      or

      Code:
      generate financial_crisis = inrange(year,2008,2010)


      Comment


      • #5
        Thanks everyone. Appreciate the help. I'm new to Stata so I'm finding the easy things difficult atm.

        Comment


        • #6
          When I'm running a fixed effect regression, how does it work with the dummy variable and incorporating this into the analysis? I'm investigating the effects of the financial crisis so do i just run the regression as normal? Do I need to incorporate diffferent commands when using a dummy variable?

          Comment


          • #7
            Generally fixed effects regression in Stata is done through either -xtreg, fe- (you need to xtset your data before), or through -areg, absorb(fixed_effect).

            You need to tell us more about your data what you are trying to do.

            Originally posted by Lucy Gordon View Post
            When I'm running a fixed effect regression, how does it work with the dummy variable and incorporating this into the analysis? I'm investigating the effects of the financial crisis so do i just run the regression as normal? Do I need to incorporate diffferent commands when using a dummy variable?

            Comment


            • #8
              Basically I am exploring the effects of gender diversity on the board of directors of banks on financial performance. I have three dependent variables (financial performance indicators) and 6 independent variables. I want to further my analysis by incorporating this dummy variable that will enable me to explore the effect of female representation on the board of directors during the crisis years. I have never used stata prior to last week really. It's totally new and confusing. I have watched tutorials.

              I have been told I need to run a random effects, fixed effects and a hausman test. Then accounting to endogeneity by lagging the dependent variables by one year. I also need to add year fixed effect and robust standard error. After this i was going to run a regression with the dummy variable...

              Comment

              Working...
              X