Nath Kack December 25, 2020 at 7:48 am
Dear Shah,
I'k a student and looking for help nearly converting daily returns to weekly returns in Stata. In fact, I read some of your posts and tried to employ ascol without success.
the code for raw_return is :
m raw_return = log(price[_n]/price[_n-i])
Could yous please tell me which code I need to use?
Cheers very much in advance for your assist,
Have a wonderful day,
Nathan
Hello Nathan
To convert daily returns to weekly, you can either use asrol or ascol. Both of them employ like methods, though ascol is specifically designed for this task. The help file of ascol provides several examples in this regard. You might also detect this blog entry helpful. In the post-obit paragraph, I show i boosted case using data from my site.
ssc install ascol
bys symbol : gen daily_return = ln(close / close[_n-1]) gen week_date = wofd(date) format week_date %tw ascol daily_return , returns(log) keep(all) toweek gen(weekly_return) timevar(engagement) panelvar(symbol)
Explanation
returns(log) : Tells ascol that the returns were initially generated using log method. This is important because ascol then applies the unproblematic summation method to catechumen the returns from daily to weekly frequency.
proceed(all): When we convert data from daily to a lower-frequency such every bit weekly, monthly, etc., we end up with repeated values of the converted variable. We frequently just demand ane value of the variable per cross-sectional unit of measurement and time-catamenia. Therefore, the repeated observations are not needed and should be dropped. This is what the Stata's collapse control does. The default in ascol is to collapse the information to a lower frequency and delete all other variables except the newly created one. Nevertheless, there might be circumstances when we want to retain all the observations without collapsing the information set. Towards this cease, we tin can employ the pick go on(all) or keep(vars). keep(all) will keep the information fix as it was earlier running the command, while keep(vars) will collapse the information to a lower frequency and keep all the variables of the data prepare. Hither is the summary:
continue(all) conversion happens without collapsing the data and without deleting other variables
keep(vars) conversion happens without deleting other variables; data collapses to a lower frequency
timevar(date) panelvar(symbol) : If the information is already alleged every bit console with the tsset, these 2 options are not required. If the information is alleged equally panel data, so timevar() is used to declare the time variable and panelvar() is used to declare the panel variable, hither it is the company symbol.
0 Response to "How To Convert Monthly Data To Quarterly In Stata"
Post a Comment