Skip to content

Instantly share code, notes, and snippets.

@erikcs
Created December 19, 2016 19:27
Show Gist options
  • Save erikcs/04c64bd8b9526520feba6e408ccfa481 to your computer and use it in GitHub Desktop.
Save erikcs/04c64bd8b9526520feba6e408ccfa481 to your computer and use it in GitHub Desktop.
source('R/penfmbr.R')
library(stargazer)
factors = read.csv('data/factors.csv')[, -1]
returns = read.csv('data/returns.csv')[, -1]
# Models
fmb_mkt = fmb(factors[, 1, drop = FALSE], returns)
fmb_ff = fmb(factors[, c(1, 2, 3)], returns)
fmb_ch = fmb(factors, returns)
penfmb_mkt = penfmb(factors[, 1, drop = FALSE], returns)
penfmb_ff = penfmb(factors[, c(1, 2, 3)], returns)
penfmb_ch = penfmb(factors, returns)
models = list(fmb_mkt, fmb_ff, fmb_ch,
penfmb_mkt, penfmb_ff, penfmb_ch)
stargazer(models,
se = lapply(models, function(x) sqrt(diag(vcov(x)))),
keep.stat = 'adj.rsq',
type = 'text',
dep.var.caption = '',
dep.var.labels = '',
star.cutoffs = NA,
column.labels = c('FamaMacBeth', 'Penalized FamaMacBeth'),
column.separate = c(3, 3),
notes = c('FamaMacBeth and Penalized FamaMacBeth regressions for the 25 B/M sorted portfolios.',
'Shanken standard errors in parenthesis. For PenFMB bootstrapped shrinkage rate',
'in parenthesis, based on the stationary bootstrap.'),
notes.append = FALSE,
notes.align = 'l')
>
====================================================================================================
FamaMacBeth Penalized FamaMacBeth
(1) (2) (3) (4) (5) (6)
----------------------------------------------------------------------------------------------------
Mkt -0.697 -0.795 0.025 -0.697 -0.795 -0.753
(0.483) (0.355) (0.437) (0.000) (0.000) (0.000)
SMB 0.141 0.152 0.141 0.140
(0.143) (0.144) (0.000) (0.030)
HML 0.426 0.447 0.426 0.422
(0.135) (0.137) (0.000) (0.010)
Mom 2.308 0.000
(0.792) (0.990)
Constant 1.474 1.350 0.574 1.474 1.350 1.309
(0.442) (0.290) (0.376) (0.000) (0.000) (0.000)
----------------------------------------------------------------------------------------------------
Adjusted R2 0.165 0.674 0.723 0.165 0.674 0.650
====================================================================================================
Note: FamaMacBeth and Penalized FamaMacBeth regressions for the 25 B/M sorted portfolios.
Shanken standard errors in parenthesis. For PenFMB bootstrapped shrinkage rate
in parenthesis, based on the stationary bootstrap.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment