Syndicate content

Add new comment

Submitted by Simon H. Heß on

Hi Nicolas,

You used "ritest ..., ... cluster(municipality)", which lets ritest think that treatment (weather) has been assigned at that level. For two reasons this is not what you seem to want to be doing: (1) you argued for dependence of weather across municipalities, (2) your data has a panel structure, so you have multiple observations per municipality that have different [by assumption independent] weather conditions.

I assume you want to use resample the weather variables, ignoring that there might be inter-temporal dependence but leaving the spacial correlation structure as is. That could be achieved by shuffling the weather data across years. The easiest way to do so would be via your own permutation program. What the easiest approach for that would be depends a lot on your data structure and how exactly you want the resampling, but it could be something like this:

program randomyearmerge
 syntax, * //this "swallows" whatever ritest passes on to the program
 sort year municipality, stable //to ensure reproducibility
 //draw a random year
 by year: gen randomyear = round(1980+runiform()*20) if _n==1
 //use the same random year for all municipalities
 by year: replace randomyear = randomyear[1]
 merge m:1 year municipility using weatherdata.dta, nogen //load the weatherdata
. ritest mean_temp _b[mean_temp] , samplingprogram(randomyearmerge): xtreg ...
(obviously you'll have to adapt the code to your needs and I can give no guarantee that it does what you want it to do)