Dear Stata Experts,
Could you please give me hints on how can I implement the following:
1. I have my data in the following form:
....
wficn ymdate excess mkt smb hml rmw cma nobs r2 r2adj beta_mkt beta_smb beta_hml beta_rmw beta_cma rs_cons
111112 401 .0031 .001 .0261 -.0093 .0118
111112 402 -.0134 -.0034 .009 .0325 -.0216 .0202
...
111112 436 .0332269 .0236 .0313 -.0121 .0026 -.0021 34 .78003481 .74075532 1.2317218 .59357388 -.82897375 -.10990499 -.4979433 .00160522
111112 437 -.0671342 -.0114 -.0347 .0155 .0342 .0109 35 .77233286 .73307991 1.1876516 .51866611 -.81139137 -.20526249 -.58642725 .00172887
2. On ymdate corresponding to January of each year (1990-2012) I would like to sort stocks based on their rs_cons value on that date (values of which begin from 34th months for each stock) into 10 equal deciles, from highest rs_cons to the lowest. As I see it in Stata: count total number of stocks, for which value rs_cons exists on required ymdate, divide by 10, round up - this is the number of stocks in each decile for each yearly ymdate. Then sort, allocate stocks among deciles.
3. Calculate equal-weighted average of "excess" among stocks in each decile for each yearly ymdate. Save averages of each deciles as time-series on yearly frequency.
4. Regress yearly time-series averaged returns of each decile on the two factors (also time-series, with the same frequency).
Given that Stata can work only with one matrix at a time, I'm a bit lost of how can I sort, average returns, store them and regress on factors for several periods.
I would appreciate your help very much.
Best,
Ekaterina
Could you please give me hints on how can I implement the following:
1. I have my data in the following form:
Code:
stock ymdate excess mkt smb hml rmw cma nobs r2 r2adj beta_mkt beta_smb beta_hml beta_rmw beta_cma rs_cons 111111 330 .0385 -.0108 .0071 -.0039 .0163 . 111111 331 .0287317 .0352 -.0091 -.0093 .0196 -.0163 . 111111 332 -.0397046 -.0259 .0038 .0028 -.0097 .0189 1 111111 333 -.1983077 -.2324 -.0813 .0423 .0171 .0222 2 111111 334 -.0792021 -.0777 .0285 .0308 -.0206 .007 3 111111 335 .0706091 .0681 .0007 -.0445 .0303 -.025 4 .... 111111 364 .0827522 .0842 -.0238 -.0373 .0178 -.0149 33 111111 365 -.0080123 -.0109 .0137 -.0195 -.0123 -.0036 34 .9830043 .97996935 .89905739 -.3561997 -.17716458 -.2862515 -.08569398 -.00008467 111111 366 -.0030894 -.019 -.0329 -.0002 -.0044 .0309 35 .98301784 .98008988 .89945595 -.3561501 -.1752691 -.28215496 -.08410732 -.00011995
wficn ymdate excess mkt smb hml rmw cma nobs r2 r2adj beta_mkt beta_smb beta_hml beta_rmw beta_cma rs_cons
111112 401 .0031 .001 .0261 -.0093 .0118
111112 402 -.0134 -.0034 .009 .0325 -.0216 .0202
...
111112 436 .0332269 .0236 .0313 -.0121 .0026 -.0021 34 .78003481 .74075532 1.2317218 .59357388 -.82897375 -.10990499 -.4979433 .00160522
111112 437 -.0671342 -.0114 -.0347 .0155 .0342 .0109 35 .77233286 .73307991 1.1876516 .51866611 -.81139137 -.20526249 -.58642725 .00172887
2. On ymdate corresponding to January of each year (1990-2012) I would like to sort stocks based on their rs_cons value on that date (values of which begin from 34th months for each stock) into 10 equal deciles, from highest rs_cons to the lowest. As I see it in Stata: count total number of stocks, for which value rs_cons exists on required ymdate, divide by 10, round up - this is the number of stocks in each decile for each yearly ymdate. Then sort, allocate stocks among deciles.
3. Calculate equal-weighted average of "excess" among stocks in each decile for each yearly ymdate. Save averages of each deciles as time-series on yearly frequency.
4. Regress yearly time-series averaged returns of each decile on the two factors (also time-series, with the same frequency).
Given that Stata can work only with one matrix at a time, I'm a bit lost of how can I sort, average returns, store them and regress on factors for several periods.
I would appreciate your help very much.
Best,
Ekaterina
Comment