Dear all,
Please forgive the rookie question.
I want to perform a placebo test to show that my IV results are not the result of a spurious correlation. To that end, I want to perform 1000 replications of my IV specification, shuffling the endogenous variable (within each year) each time. I want to save the coefficients and p-values on the endogenous variable so that I can depict them on a density plot.
I know that by using the -shufflevar- command with cluster(year) I can shuffle the endogenous variable by year and then run the regression. This would then be:
shufflevar endo, cluster(year)
xtivreg2 y (endo_shuffled = instrument) controls, fe
To do it once. What I don't know how to do is to run this 1000 times, saving the coefficient on endo_shuffled each time, so that I can produce the density plot. I don't know this because my knowledge of stata is not yet at a level where I know how to program loops etc.
Therefore, I would appreciate any help.
Thankyou.
Please forgive the rookie question.
I want to perform a placebo test to show that my IV results are not the result of a spurious correlation. To that end, I want to perform 1000 replications of my IV specification, shuffling the endogenous variable (within each year) each time. I want to save the coefficients and p-values on the endogenous variable so that I can depict them on a density plot.
I know that by using the -shufflevar- command with cluster(year) I can shuffle the endogenous variable by year and then run the regression. This would then be:
shufflevar endo, cluster(year)
xtivreg2 y (endo_shuffled = instrument) controls, fe
To do it once. What I don't know how to do is to run this 1000 times, saving the coefficient on endo_shuffled each time, so that I can produce the density plot. I don't know this because my knowledge of stata is not yet at a level where I know how to program loops etc.
Therefore, I would appreciate any help.
Thankyou.
Comment