Dear Stata Users,

I want to generate a 5 year (min 3 years) rolling Spearman correlation. I have come with the following codes:

Code:
1.  rangestat (corr) x1 x2, int(fyear 0 -4) by(firm_id) 

2. tsset firm_id fyear 
  rolling correlation=r(rho), window(5) saving(f2, replace): corr x1 x2
The problem with these codes is that: 1. they dont allow to use minimum window (of 3 years) 2.For "rangestat" I am not sure if it is a spearman correlation 3. I have a huge dataset, so "rolling" is to slow.

Can you suggest me any alternative way in terms of using minimum window requirement and speed of execution?

Best regards,
Alberto