Announcement

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

  • IV regressions - modifying dates

    Hi,

    I am working on a panel data set with 20 countries and quarterly data. The dependent variable is price and the independent variable is risk. I am using quarterly election as an IV in IV regressions. This is a dummy variable which takes the value of 1 for election quarters and 0 otherwise. I want to run instrumental variable regressions;

    01. by using three quarters before plus election quarter as the IV
    02. quarter right before the election quarter as the IV

    A snapshot of the data file is included below.

    The current code that I use to run regressions using current election quarter data is;

    ivreg2 price $controls i.countrynum i.yearqtr (risk = election), savefirst savefprefix(first)

    Can someone please advise on how to modify this code to run the above 2 regressions?



    Code:
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input str97 location double(year qdate price risk) byte election
    "Australia" 1970 41    .04297956780566525 .3646308 0
    "Australia" 1970 42    .05162054093048929  .655308 0
    "Australia" 1970 43    .04565936262218839        0 0
    "Australia" 1971 44    .04049916884918492  .337344 0
    "Australia" 1971 45   .049496729488366364  .449169 0
    "Australia" 1971 46    .07607787494393325  .304909 0
    "Australia" 1971 47    .07383885597122553        0 0
    "Australia" 1972 48     .0903276229663641  .373925 0
    "Australia" 1972 49     .1292809534922108        0 0
    "Australia" 1972 50    .11936403114460226 .2447681 0
    "Australia" 1972 51    .14367467361375175 1.230959 1
    "Australia" 1973 52    .11256845289860817  .354045 0
    "Australia" 1973 53   .023396646749443528  .226142 0
    "Australia" 1973 54  -.022503139633368807        0 0
    "Australia" 1973 55   -.07171322256754664        0 0
    "Australia" 1974 56  -.059487461301409694 .4249894 0
    "Australia" 1974 57 -.0009579086563914485 .4659109 1
    "Australia" 1974 58   -.01590767621940592        0 0
    "Australia" 1974 59   .012655398230987824  .474046 0
    "Australia" 1975 60   .004346961030980312 .3881988 0
    end
    format %tq qdate
    Thanks a lot.

  • #2
    You need to -xtset- your data, and then lead (F.) and lag (L.) operators become available.

    Comment


    • #3
      Originally posted by Joro Kolev View Post
      You need to -xtset- your data, and then lead (F.) and lag (L.) operators become available.
      Thanks for your response.

      so three quarters before election quarter would be:
      ivreg2 price $controls i.countrynum i.yearqtr (risk = l3.election), savefirst savefprefix(first)?

      Thanks.

      Comment


      • #4
        Originally posted by Ama Perera View Post

        Thanks for your response.

        so three quarters before election quarter would be:
        ivreg2 price $controls i.countrynum i.yearqtr (risk = l3.election), savefirst savefprefix(first)?

        Thanks.
        Yes. Something like:

        Code:
        xtset country qdate, quarterly
        
        ivreg2 price $controls i.countrynum i.yearqtr (risk = l3.election), savefirst savefprefix(first)
        This will include only the said quarter. You can also include all quarters up to certain lag with something like

        Code:
        ivreg2 price $controls i.countrynum i.yearqtr (risk = l(1/3).election), savefirst savefprefix(first)
        see -help tsvarlist-.

        Comment


        • #5
          Originally posted by Joro Kolev View Post

          Yes. Something like:

          Code:
          xtset country qdate, quarterly
          
          ivreg2 price $controls i.countrynum i.yearqtr (risk = l3.election), savefirst savefprefix(first)
          This will include only the said quarter. You can also include all quarters up to certain lag with something like

          Code:
          ivreg2 price $controls i.countrynum i.yearqtr (risk = l(1/3).election), savefirst savefprefix(first)
          see -help tsvarlist-.
          Thanks a lot.

          can you please let me know how to create an interaction term between all quarters upto third lag with the election variable?

          I tried gen new_var = l(1/3).election*election
          but it doesn't work.

          Comment


          • #6
            Try directly using the time series operators in conjunction with interactions terms, like this

            Code:
             
             ivreg2 price $controls i.countrynum i.yearqtr (risk = l(1/3)#election), savefirst savefprefix(first)

            Comment


            • #7
              If Stata does not understand the syntax, you need to use the -generate- statements lag by lag

              E.g.,

              Code:
              gen l3electionXelection = l3.election*election
              gen l2electionXelection = l2.election*election
              etc.

              Comment

              Working...
              X