0

Our dataframe has the following structure:

 RecordID   datecode                             Name     Betha     RF MKTRF     Ri
60         1 2014-12-01 1290 GAMCO Small/Mid Cap Value A 0.7256891 0.0000 -0.06   1.61
61         1 2015-01-01 1290 GAMCO Small/Mid Cap Value A 0.7256891 0.0000 -3.11  -3.53
62         1 2015-02-01 1290 GAMCO Small/Mid Cap Value A 0.7256891 0.0000  6.13   5.49
63         1 2015-03-01 1290 GAMCO Small/Mid Cap Value A 0.7256891 0.0000 -1.12   0.29
64         1 2015-04-01 1290 GAMCO Small/Mid Cap Value A 0.7256891 0.0000  0.59   0.67
65         1 2015-05-01 1290 GAMCO Small/Mid Cap Value A 0.7256891 0.0000  1.36   0.57

392035     3267 2019-07-01 Wasatch Core Growth Institutional 0.6421722 0.0019  1.19   6.75
392036     3267 2019-08-01 Wasatch Core Growth Institutional 0.6421722 0.0016 -2.58   0.09
392037     3267 2019-09-01 Wasatch Core Growth Institutional 0.6421722 0.0018  1.44   4.99
392038     3267 2019-10-01 Wasatch Core Growth Institutional 0.6421722 0.0015  2.06  -3.68
392039     3267 2019-11-01 Wasatch Core Growth Institutional 0.6421722 0.0012  3.87   5.35
392040     3267 2019-12-01 Wasatch Core Growth Institutional 0.6421722 0.0014  2.77   1.12

We need to compute yearly Jensen's Alpha and Fama & French 3-factor alphas and store them in separate columns in order to run regressions on them. The formulas for both regressions are illustrated below:

Jensen Alpha: Ri ~ a + B1*MKTRF + e 
3-factor Alpha: Ri ~ a + B1*MKTRF + B2*SMB + B3*HML + B4*UMD + e

We have tried saving the data as a data table and in a panel data format and run this regression from a similar post to compute the Jensen Alpha:

dt[, alpha:= roll_regres.fit(x = cbind(1, .SD[["MKTRF"]]), y = .SD[["Ri"]], width = 12L)$coefs[, 1], by = RecordID]

The post: Rollregres with multiple regression and panel data

However, it did not work and kept giving the error message:

Error in roll_regres.fit(x = cbind(1, .SD[["MKTRF"]]), y = .SD[["Ri"]],  : 
subscript out of bounds

We are trying to use the "rollRegress" package and no additional packages have been used.

What are we doing wrong and is there anybody that can help us compute the yearly Jensen Alpha which we can store in a separate column? :)

  • P.s.: We are complete R-noobs! However, we are eager to learn :) – Jarivdmoos May 14 '20 at 11:27
  • 1
    Welcome to Stack Overflow. Your enthusiasm is appreciated, However, minimal reproducible self-contained code is needed, please read: [how-to-make-a-great-r-reproducible-example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example/5963610#5963610). – jay.sf May 14 '20 at 12:34

0 Answers0