Hi,
I'm working on panel data and want to run vecrank on firm-level with rolling windows, where I want to store some postestimation results as new variables. My data has the following format:
I'm currently using the following code:
The code works perfectly, but my problem is that it takes a very long time to run. I'm aware that foreach and forvalue loops tend to take a long time. I came across rangestat which is much faster but it does not support vecrank command, so I would need to use mata to write the command myself and I have zero experience with mata.
Do you have any advice or suggestions?
Thanks,
Noor
I'm working on panel data and want to run vecrank on firm-level with rolling windows, where I want to store some postestimation results as new variables. My data has the following format:
Code:
* Example generated by -dataex-. For more info, type help dataex clear input float(firmid timeid logMV logVF) 1 218 4.1860685 4.30219 1 219 4.19654 4.5676622 1 220 4.522541 4.5608683 1 221 4.4920044 4.56502 1 222 4.4122176 4.57979 1 223 4.3952684 4.5846977 1 224 4.3426247 4.598754 1 225 4.258428 4.6033964 1 226 4.378387 4.6064277 1 227 4.351954 4.611788 end
Code:
bysort firmid: gen N=_n gen rank5=. gen obs_johns=. levelsof firmid, local (firmids) foreach i in `firmids' { sum N if firmid==`i' local n=r(min)+119 local p=r(max) forvalues j=`n'(6)`p'{ vecrank logMV logVF if firmid==`i' & N<=`j' & N>`j'-120, lags(1) replace rank5= e(k_ce95) if firmid==`i' & N==`j' replace obs_johns=e(N) if firmid==`i' & N==`j' } }
Do you have any advice or suggestions?
Thanks,
Noor
Comment