Announcement

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

  • GDP year dummies

    Hi! How can I substitute a variable like GDP (with values by quarter) for dummy variables like 2011Q1 (dummy 1), 2011Q2 (dummy 2), etc. My professor told me to look for "year dummies" but I don't find much information about it. It is to later incorporate in an estimation of a model. I'm not an expert in stata, quite the opposite. But I know what dummy variables are (with values 0 and 1), but I don't understand how a 0 and a 1 can carry information about GDP.

    Many thanks

  • #2
    I don't understand how a 0 and a 1 can carry information about GDP.
    Basically, it can't. I suppose to a minimal extent you could define a 0/1 variable indicating whether GDP was above or below some threshold (which might be an arbitrary number, of the median of your sample or something like that) but that would be throwing out 99.999999+% of the information in a GDP variable.

    I think that either your professor mis-spoke or your misunderstood him or her. It is more likely that you are being asked to organize your data set in such a way that each observation in the data set corresponds to one calendar quarter, and there is a variable for GDP in that quarter and another variable designating the calendar quarter itself (and maybe you have other variables as well). Since you don't show what data you currently have, it is impossible to advise how to get it into this shape.

    I should also point out that if the purpose is ultimately to incorporate quarterly time indicators into a model to be estimated, there is no need to create separate indicator ("dummy") variables for each quarter unless you are using an ancient version of Stata. In modern Stata, you just need the single variable that takes on values like 2011Q1, 2011Q2, etc. (as Stata internal format date variables, not as strings) and then you can apply factor-variable notation to incorporate that into your model and Stata will create "virtual" indicator variables for you on the fly.

    So, things you need to read up on if you are not already familiar with them are:

    Code:
    help datetime variables 
    help fvvarlist // FACTOR VARIABLE NOTATION
    That said, I think you should speak to your professor again to see if what I'm saying here is what he or she had in mind. And if not, keep asking until you get clarity on just what is wanted.

    For further, and more specific advice, post back using the -dataex- command to show an example of your data. 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-.

    Comment


    • #3
      Thanks Clyde, my data is organized as follows:

      Code:
      * Example generated by -dataex-. To install: ssc install dataex
      clear
      input double id int year byte quarter float(urate GDP)
       10014702 2011 1 12.4    0
       10014702 2011 2 12.5 -1.3
       10014702 2011 4 14.4 -4.3
       10015401 2012 1   15 -4.3
       10015401 2012 2 15.7 -5.1
       10015901 2011 3 13.2 -2.6
       10015901 2012 1   15 -4.3
       10015901 2012 2 15.7 -5.1
       10015901 2012 3 16.2 -4.8
       10015901 2012 4 16.9 -3.4
       10053701 2011 1 12.4    0
      end
      Quoting what he asked: "estimate a model x, but substituting urate and GDP by a categorical variable: one dummy for 2011Q2, another for 2011Q3, etc"

      The model is for ex:
      svy: stcox i.age_g female married born_portugal ui i.reason i.residency_location i.education i. previous_firm urate GDP, nolog

      Comment


      • #4
        So I think he means this:

        Code:
        gen qdate = yq(year, quarter)
        format qdate %tq
        svy: stcox i.age_g female married born_portugal ui i.reason i.residency_location ///
            i.education i. previous_firm i.qdate, nolog
        If he is not up to date on Stata he may be expecting a whole bunch of "dummy" variables for all the quarters (except one), but the i.qdate in the model will expand to that automatically.

        Comment

        Working...
        X