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.