Hi everyone,
I want to run some macro regressions but i don't know anything about macros in stata.
I have a data set for which i want to estimate coefficients. I want stata to calculate coefficients on monthly basis by taking historical 60 months data to give me estimated coefficients and then roll by one month i.e. remove first month and take 61st month to calculate the results for next observation. I also want stata to generate estimated coefficient results which can be saved as "const b1 b2 b3". I have many firms for which i want to do this. I have data for 312 months for each firm. For each firm, my first results will appear from 61st observation as i utilize first 60 months to estimate the 1st observation and then on rolling basis it can generate results for all 312 observation starting from 61st through a loop.
My dependent variable is return
three independent variables are mkt-rf hml smb i want estimated coefficients for these three variables plus coefficient for constant based on 60 months historical data and then making rolling regressions as explained above.
Firm ID is defined by gvkey. for each firm ID (gvkey) i have months starting from 1 to 312.
My data looks like this.
I want to run some macro regressions but i don't know anything about macros in stata.
I have a data set for which i want to estimate coefficients. I want stata to calculate coefficients on monthly basis by taking historical 60 months data to give me estimated coefficients and then roll by one month i.e. remove first month and take 61st month to calculate the results for next observation. I also want stata to generate estimated coefficient results which can be saved as "const b1 b2 b3". I have many firms for which i want to do this. I have data for 312 months for each firm. For each firm, my first results will appear from 61st observation as i utilize first 60 months to estimate the 1st observation and then on rolling basis it can generate results for all 312 observation starting from 61st through a loop.
My dependent variable is return
three independent variables are mkt-rf hml smb i want estimated coefficients for these three variables plus coefficient for constant based on 60 months historical data and then making rolling regressions as explained above.
Firm ID is defined by gvkey. for each firm ID (gvkey) i have months starting from 1 to 312.
My data looks like this.
gvkey | months | return | mkt_rf | smb | hml |
10026 | 1 | 0.015873 | 0.95 | 0.68 | -0.42 |
10026 | 2 | 0.375 | 0.02 | 0.79 | 0.88 |
10026 | 3 | 0.056818 | -0.09 | 0.72 | -0.01 |
10026 | 4 | 0.193548 | 0.18 | -1.12 | 0.43 |
10026 | 5 | -0.04505 | 0.69 | 0.03 | 0.2 |
10026 | 6 | 0.075472 | -0.64 | 0.83 | -0.03 |
10026 | 7 | 0.052632 | 0.39 | 0.36 | -0.43 |
10026 | 8 | -0.075 | -0.15 | 0.45 | -0.16 |
10026 | 9 | 0 | 0.53 | 0.11 | -0.04 |
10026 | 10 | -0.0991 | 0.09 | 0.75 | -0.43 |
Comment