Hi,
I am calculating idiosyncratic volatility based on previous 1 month and previous 3 months daily regressions. I created mdate as year*100+month. And when I run the regressions for previous 1 month I have no problem in getting my residuals using this command:
rangestat (reg) excessret mrktx smb hml , interval(mdate 0 0) by( permno )
gen residual = excessret - b_cons - b_mrktx * mrktx- b_smb* smb- b_hml* hml
However when I want the regressions to use previous 3 months data, I have a problem, let me tell you what it is. I run the following code:
rangestat (reg) excessret mrktx smb hml , interval(mdate -2 0) by( permno )
and it does the job but the problem is whenever the year changes i. e. 1986 to 1987, the mdate variable changes 198612 to 198701. So the difference is not apparently 2. And for every new year for the same firm the first 2 months of regression is only ran on the first month and first 2 month instead of going back to December of last year. In order to solve the issue, I need a continuos mdate variable that doesnt jump every beginning year. How do can I construct it? Or is there any other solution,
any comment would be appreciated.
the num of observation in each regression changes as follow for the same firm. I am not sure if my question is clear. Every new year obs used in that window is just the days in January. That way I lose the first 2 months of every year.
mdate reg_nobs
198612 64
198612 64
198612 64
198612 64
198701 21
198701 21
198701 21
198701 21
198701 21
198701 21
198701 21
198701 21
198701 21
198701 21
198701 21
198701 21
198701 21
198701 21
198701 21
198701 21
198701 21
198701 21
198701 21
198701 21
198701 21
198702 40
198702 40
198702 40
198702 40
198702 40
198702 40
198702 40
198702 40
198702 40
198702 40
198702 40
198702 40
198702 40
198702 40
198702 40
198702 40
198702 40
198702 40
198702 40
198703 62
198703 62
198703 62
198703 62
198703 62
198703 62
198703 62
198703 62
198703 62
198703 62
198703 62
198703 62
198703 62
198703 62
198703 62
198703 62
198703 62
198703 62
198703 62
198703 62
198703 62
198703 62
198704 62
198704 62
198704 62
198704 62
198704 62
198704 62
198704 62
198704 62
198704 62
198704 62
198704 62
198704 62
198704 62
198704 62
198704 62
198704 62
198704 62
198704 62
198704 62
198704 62
198704 62
198705 63
198705 63
198705 63
198705 63
198705 63
198705 63
198705 63
198705 63
198705 63
198705 63
198705 63
198705 63
198705 63
198705 63
198705 63
198705 63
198705 63
198705 63
198705 63
198705 63
198706 50
198706 50
198706 50
198706 50
198706 50
198706 50
198706 50
198706 50
198706 50
198601 16
198601 16
198601 16
198601 16
198601 16
198601 16
198601 16
198601 16
198601 16
198601 16
198601 16
198601 16
198601 16
198601 16
198601 16
198601 16
198602 35
198602 35
198602 35
198602 35
198602 35
198602 35
198602 35
198602 35
198602 35
198602 35
198602 35
198602 35
198602 35
198602 35
198602 35
198602 35
198602 35
198602 35
198602 35
198603 55
198603 55
198603 55
198603 55
198603 55
198603 55
198603 55
198603 55
198603 55
Related Posts with idiosyncratic volatility using rangestat
Three level nested logitHi, I'm trying to run a nested logit using three levels with -nlogit-. Level 1 is whether the indi…
How to eliminate male-only households from individual-level dataDear Stata Users, I am new to Stata. I have a Census dataset on individuals, that are identified p…
Varbench - Is there any minimum number of observations needed?Hi, I am using the varbench command. My dataset has 96 observations in total. When I run this comma…
Deleting observations with missing values using macro/loopingHi all, I am very new to macros and looping (in Stata). I have certain variables for which it is ne…
netsed logit with panel dataHi all, This is the first time that I encountered with choice model in my research, the data we hav…
Subscribe to:
Post Comments (Atom)
0 Response to idiosyncratic volatility using rangestat
Post a Comment