Hi,
I have a question on how (and if) we could use rangestat for the following specific case. I want that: for the current observation (indexed by id & yearmonth) a value is calculated using previous 60 months returns such that: value = sumproduct of two vectors, vector a is the previous 60 returns (variable ret below)) and vector b is the (vectors of numbers such as 1/60,4/60...3/60...10/60....having 60 such numbers.). I guess one would have to write the mata subroutine for the sumproduct first and then call rangestat. I am just not sure how to proceed. Any hlep, as usual, is greatly appreciated.
I have a question on how (and if) we could use rangestat for the following specific case. I want that: for the current observation (indexed by id & yearmonth) a value is calculated using previous 60 months returns such that: value = sumproduct of two vectors, vector a is the previous 60 returns (variable ret below)) and vector b is the (vectors of numbers such as 1/60,4/60...3/60...10/60....having 60 such numbers.). I guess one would have to write the mata subroutine for the sumproduct first and then call rangestat. I am just not sure how to proceed. Any hlep, as usual, is greatly appreciated.
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input double permno float fmy double ret 10000 321 -.24242424964904785 10000 322 .05999999865889549 10000 323 -.37735849618911743 10000 324 -.21212121844291687 10000 325 0 10000 326 -.38461539149284363 10000 327 -.0625 10000 328 -.06666667014360428 10000 329 . 10001 312 . 10001 313 .020408162847161293 10001 314 .025200003758072853 10001 315 .009900989942252636 10001 316 -.009803921915590763 10001 317 -.013069307431578636 10001 318 -.010204081423580647 10001 319 .07216494530439377 10001 320 -.003076923545449972 10001 321 .03921568766236305 10001 322 .056603774428367615 10001 323 .014999999664723873 10001 324 -.0357142873108387 10001 325 -.07407407462596893 10001 326 .03680000081658363 10001 327 -.03921568766236305 10001 328 -.0714285746216774 10001 329 .051428571343421936 10001 330 .021276595070958138 10001 331 .0833333358168602 10001 332 -.02230769209563732 end format %tm fmy
Comment