I am sitting here on a problem where I try to replace all observations that have extreme Returns in one month that are reversed over the course of the next month.
The general formula:
Code:
Rt or Rt−1 is greater than 300%, and (1 + Rt) × (1 + Rt−1) − 1 < 50%, then both Rt and Rt−1 are set to “missing.”
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input str12 ISIN float date str153 Name double prices float growth "AU0000XINAW3" 16810 "AUSTRALIAN SOLOMONS GOLD DEAD - DELIST.28/01/10 - TOT RETURN IND 80.74 . "AU0000XINAW3" 16811 "AUSTRALIAN SOLOMONS GOLD DEAD - DELIST.28/01/10 - TOT RETURN IND 76.77 -.04917018 "AU0000XINAW3" 16812 "AUSTRALIAN SOLOMONS GOLD DEAD - DELIST.28/01/10 - TOT RETURN IND 72.66 -.05353654 "AU0000XINAW3" 16813 "AUSTRALIAN SOLOMONS GOLD DEAD - DELIST.28/01/10 - TOT RETURN IND 87.41 .20300028 "AU0000XINAW3" 17167 "AUSTRALIAN SOLOMONS GOLD DEAD - DELIST.28/01/10 - TOT RETURN IND 85.32 -.02391031 "AU0000XINAW3" 17168 "AUSTRALIAN SOLOMONS GOLD DEAD - DELIST.28/01/10 - TOT RETURN IND 109.25 .2804735 "BM78669Q1007" 20827 "SAGICOR FINANCIAL COMPANY - TOT RETURN IND 80.75 . "BM78669Q1007" 20828 "SAGICOR FINANCIAL COMPANY - TOT RETURN IND 81.11 .0044582044 "BM78669Q1007" 20829 "SAGICOR FINANCIAL COMPANY - TOT RETURN IND 81.67 .006904204 "BM78669Q1007" 20830 "SAGICOR FINANCIAL COMPANY - TOT RETURN IND 78.3 -.04126362 "BM78669Q1007" 20831 "SAGICOR FINANCIAL COMPANY - TOT RETURN IND 79.27 .01238825 "BMG8586W1073" 10962 "SUNWAH INTERNATIONAL - TOT RETURN IND 85.89 . "BMG8586W1073" 10963 "SUNWAH INTERNATIONAL - TOT RETURN IND 80.14 -.0669461 "BMG8586W1073" 10964 "SUNWAH INTERNATIONAL - TOT RETURN IND 85.25 .06376342 end format %tdCCYYNNDD date
Code:
replace growth = . if growth | growth[_n-1] >=3 & ((1+growth)*(1+growth[_n-1])-1)<.5
0 Response to Replace all growth rates if cond1 or cond 2 and cond3
Post a Comment