Hi. I want to include lagged values of my dependent variable (the value of "confirmed_1" from the week before) in the regressions below. Since I have repeated time values in my panel, xtset followed by l. doesn't work over here. For other reasons, I also can't collapse this to one observation per week. I tried "bysort state weeknum : gen lag1 = confirmed_1[_n-1]", but that did not work.
How do I create a variable that reflects the values of variable "confirmed_1" for the previous week? Alternately, is there any other way in which I can include lagged values of confirmed_1. Any help will be much appreciated
How do I create a variable that reflects the values of variable "confirmed_1" for the previous week? Alternately, is there any other way in which I can include lagged values of confirmed_1. Any help will be much appreciated
Code:
areg confirmed_1 post treated_post tested i.weeknum if eventBlock == 1, absorb(state) areg confirmed_1 post treated_post tested i.weeknum if eventBlock == 2, absorb(state) *******SAMPLE DATA input str50 state byte weeknum float(confirmed_1 post treated_post tested eventBlock) "Andaman and Nicobar Islands" 3 .00025188917 0 0 0 8 "Andaman and Nicobar Islands" 3 .00025188917 0 0 0 11 "Andaman and Nicobar Islands" 3 .00025188917 0 0 0 12 "Andaman and Nicobar Islands" 3 .00025188917 0 0 0 10 "Andaman and Nicobar Islands" 3 .00025188917 0 0 0 6 "Andaman and Nicobar Islands" 3 .00025188917 0 0 0 5 "Andaman and Nicobar Islands" 4 .0024469234 0 0 0 4 "Andaman and Nicobar Islands" 4 .0024469234 0 0 0 8 "Andaman and Nicobar Islands" 4 .0024469234 0 0 0 3 "Andaman and Nicobar Islands" 4 .0024469234 1 0 0 12 "Andaman and Nicobar Islands" 4 .0024469234 0 0 0 2 "Andaman and Nicobar Islands" 5 .002626844 0 0 0 8 "Andaman and Nicobar Islands" 5 .002626844 0 0 0 3 "Andaman and Nicobar Islands" 5 .002626844 1 0 0 11 "Andaman and Nicobar Islands" 5 .002626844 0 0 0 1 "Andaman and Nicobar Islands" 5 .002626844 0 0 0 5 "Andaman and Nicobar Islands" 5 .002626844 0 0 0 4 "Andaman and Nicobar Islands" 6 .002806765 0 0 .05048579 2 "Andaman and Nicobar Islands" 6 .002806765 0 0 .05048579 3 "Andaman and Nicobar Islands" 6 .002806765 0 0 .05048579 10 "Andaman and Nicobar Islands" 6 .002806765 1 0 .05048579 11 "Andaman and Nicobar Islands" 7 .004713926 0 0 .09640159 6 "Andaman and Nicobar Islands" 7 .004713926 0 0 .09640159 1 "Andaman and Nicobar Islands" 7 .004713926 1 0 .09640159 11 "Andaman and Nicobar Islands" 7 .004713926 0 0 .09640159 3 "Andaman and Nicobar Islands" 7 .004713926 1 0 .09640159 2 "Andaman and Nicobar Islands" 7 .004713926 0 0 .09640159 9 "Andaman and Nicobar Islands" 8 .008312343 0 0 .23756747 3 "Andaman and Nicobar Islands" 8 .008312343 0 0 .23756747 7 "Andaman and Nicobar Islands" 8 .008312343 1 0 .23756747 2 "Andaman and Nicobar Islands" 9 .008312343 1 0 0 11 "Andaman and Nicobar Islands" 9 .008312343 0 0 0 5 "Andaman and Nicobar Islands" 9 .008312343 0 0 0 7 "Andaman and Nicobar Islands" 9 .008312343 1 0 0 2 "Andaman and Nicobar Islands" 9 .008312343 0 0 0 4 "Andaman and Nicobar Islands" 10 .008312343 0 0 0 3 "Andaman and Nicobar Islands" 10 .008312343 0 0 0 7 "Andaman and Nicobar Islands" 10 .008312343 0 0 0 4 "Andaman and Nicobar Islands" 10 .008312343 1 0 0 10 "Assam" 4 .000023328375 0 0 .0004007482 9 "Assam" 4 .000023328375 0 0 .0004007482 3 "Assam" 4 .000023328375 0 0 .0004007482 5 "Assam" 4 .000023328375 0 0 .0004007482 6 "Assam" 4 .000023328375 0 0 .0004007482 10 "Assam" 5 .000079983 1 0 .0011926632 11 "Assam" 5 .000079983 0 0 .0011926632 5 "Assam" 5 .000079983 0 0 .0011926632 10 "Assam" 5 .000079983 0 0 .0011926632 4 "Assam" 5 .000079983 0 0 .0011926632 9 Assam" 6 .00009456323 1 0 .008996838 11 "Assam" 6 .00009456323 0 0 .008996838 8 "Assam" 6 .00009456323 0 0 .008996838 5 "Assam" 6 .00009456323 0 0 .008996838 13 "Assam" 7 .0001028948 0 0 .011068898 6 "Assam" 7 .0001028948 0 0 .011068898 7 "Assam" 7 .0001028948 0 0 .011068898 8 "Assam" 7 .0001028948 0 0 .011068898 1 "Assam" 7 .0001028948 0 0 .011068898 10
Comment