RiskPremium

Measuring the market risk premium
Log | Files | Refs

commit 5c772597840b6dd5d1e5c1db49ef3a6d5d5ae21e
parent aa44ef8b19ae8b81060f7e4a02564e91d4b974dc
Author: Erik Loualiche <eloualic@umn.edu>
Date:   Tue,  4 Jun 2019 12:53:04 -0400

plot of prediction

Diffstat:
Mlog/R-session-info.log.R | 3++-
Mlog/import_predictors.log.R | 4++--
Mlog/rp_measure.log.R | 58++++++++++++++++++++++++++++++++++++++++++++++++++++++----
Aoutput/predict.png | 0
Mreadme.md | 3+++
Msrc/readme_in.md | 3+++
Msrc/rp_measure.R | 35+++++++++++++++++++++++++++++++++--
7 files changed, 97 insertions(+), 9 deletions(-)

diff --git a/log/R-session-info.log.R b/log/R-session-info.log.R @@ -89,7 +89,7 @@ devtools * 1.13.6 2018-06-27 CRAN (R 3.5.1) digest 0.6.15 2018-01-28 CRAN (R 3.5.1) dplyr 0.8.0.9010 2019-03-31 Github (tidyverse/dplyr@6832c62) - ggplot2 3.1.0.9000 2019-03-31 Github (tidyverse/ggplot2@230e8f7) + ggplot2 * 3.1.0.9000 2019-03-31 Github (tidyverse/ggplot2@230e8f7) glue 1.3.0 2018-07-17 CRAN (R 3.5.1) graphics * 3.5.1 2018-08-05 local grDevices * 3.5.1 2018-08-05 local @@ -124,6 +124,7 @@ tools 3.5.1 2018-08-05 local utils * 3.5.1 2018-08-05 local vctrs 0.1.0.9003 2019-05-19 Github (r-lib/vctrs@b1e6b81) + wesanderson * 0.3.6 2018-04-20 CRAN (R 3.5.1) withr 2.1.2 2018-03-15 CRAN (R 3.5.1) zeallot 0.1.0 2018-01-28 CRAN (R 3.5.1) zoo * 1.8-3 2018-07-16 CRAN (R 3.5.1) diff --git a/log/import_predictors.log.R b/log/import_predictors.log.R @@ -48,7 +48,7 @@ Type 'q()' to quit R. Log file for code executed at > message(format(Sys.time(), "%a %b %d %X %Y")) -Tue Jun 04 12:05:52 2019 +Tue Jun 04 12:51:59 2019 > ################################################################################## > > @@ -237,4 +237,4 @@ Packages ---------------------------------------------------------------------- > > proc.time() user system elapsed - 1.336 0.138 1.783 + 1.526 0.164 2.142 diff --git a/log/rp_measure.log.R b/log/rp_measure.log.R @@ -36,7 +36,7 @@ Type 'q()' to quit R. Log file for code executed at > message(format(Sys.time(), "%a %b %d %X %Y")) -Tue Jun 04 12:05:54 2019 +Tue Jun 04 12:52:01 2019 > ################################################################################## > > @@ -44,8 +44,15 @@ Tue Jun 04 12:05:54 2019 > # APPEND REQUIRED PACKAGES > library(crayon) > library(devtools) -> -> # library(ggplot2) +> library(wesanderson) +> library(ggplot2) + +Attaching package: ‘ggplot2’ + +The following object is masked from ‘package:crayon’: + + %+% + > library(statar) > library(stringr) > library(lubridate) @@ -186,6 +193,49 @@ Notes: ***Significant at the 1 percent level. > ################################################################################## > > +> ################################################################################## +> # PLOT +> dt_plot <- dt_exp_rmrf[, .(date=as.Date(ISOdate(str_sub(dateym,1, 4), str_sub(dateym, 5, 6), 1)), ++ dp, cay, rf, rmrf_y3, exp_rmrf)] +> dt_plot + date dp cay rf rmrf_y3 exp_rmrf + 1: 1952-01-01 0.05812871 0.01646544 0.0157 0.17701996 0.201294617 + 2: 1952-02-01 0.05899675 0.02551783 0.0154 0.19964326 0.222836429 + 3: 1952-03-01 0.05817138 0.01633620 0.0159 0.18092953 0.200926735 + 4: 1952-04-01 0.05847809 0.02542006 0.0157 0.21473395 0.220859636 + 5: 1953-01-01 0.05472504 0.02543387 0.0196 0.21110181 0.206163415 + --- +252: 2014-04-01 0.02159773 -0.02747550 0.0003 0.08441447 0.025044998 +253: 2015-01-01 0.02090927 -0.03462231 0.0003 0.12632351 0.008287874 +254: 2015-02-01 0.02098770 -0.03462943 0.0002 0.09072934 0.008601014 +255: 2015-03-01 0.02111608 -0.02656083 0.0003 0.08734601 0.025601134 +256: 2015-04-01 0.02109137 -0.03519129 0.0002 0.08565438 0.007723565 +> +> p0 <- dt_plot[, .(date, dp, cay, rf, rmrf_y3) ] %>% ++ melt(id.vars="date") %>% ++ ggplot(aes(date, value, colour = variable)) + ++ geom_line(alpha=0.75, size=0.25) + geom_point(shape=1, size = 1, alpha=0.5) + ++ theme_bw() +> # p0 +> +> p1 <- dt_plot[, .(date, exp_rmrf, rmrf_y3) ] %>% ++ melt(id.vars="date") %>% ++ ggplot(aes(date, 100*value, colour = variable)) + ++ geom_line(alpha=0.75, size=0.25) + geom_point(shape=1, size = 1, alpha=0.5) + ++ xlab("") + ylab("Returns (percent)") + ++ theme_bw() + ++ theme(legend.position = c(0.3, 0.9)) + ++ scale_colour_manual(name = "", ++ breaks = c("exp_rmrf", "rmrf_y3"), ++ values = c(wes_palette("Zissou1")[1], wes_palette("Zissou1")[5]), ++ labels=c("Expected", "Realized")) + ++ guides(colour = guide_legend(nrow = 1)) +> +> ggsave("./output/predict.png", p1, width = 8, height=6) +> +> +> +> > proc.time() user system elapsed - 1.685 0.135 1.793 + 2.500 0.207 2.776 diff --git a/output/predict.png b/output/predict.png Binary files differ. diff --git a/readme.md b/readme.md @@ -1,5 +1,8 @@ # Measuring the Market Risk Premium +![](output/predict.png) + + This code updates the measure of equity risk premium from the paper **Buyout Activity: the Impact of Aggregate Discount Rates** in the *Journal of Finance* Authors: Valentin Haddad, Erik Loualiche & Matthew Plosser. diff --git a/src/readme_in.md b/src/readme_in.md @@ -1,5 +1,8 @@ # Measuring the Market Risk Premium +![](output/predict.png) + + This code updates the measure of equity risk premium from the paper **Buyout Activity: the Impact of Aggregate Discount Rates** in the *Journal of Finance* Authors: Valentin Haddad, Erik Loualiche & Matthew Plosser. diff --git a/src/rp_measure.R b/src/rp_measure.R @@ -22,8 +22,8 @@ message(format(Sys.time(), "%a %b %d %X %Y")) # APPEND REQUIRED PACKAGES library(crayon) library(devtools) - -# library(ggplot2) +library(wesanderson) +library(ggplot2) library(statar) library(stringr) library(lubridate) @@ -73,3 +73,34 @@ dt_exp_rmrf <- cbind(dt_predict[!is.na(rmrf_y3), -c("datem")], exp_rmrf = predic fwrite(dt_exp_rmrf, "./output/predict.csv") ################################################################################## + +################################################################################## +# PLOT +dt_plot <- dt_exp_rmrf[, .(date=as.Date(ISOdate(str_sub(dateym,1, 4), str_sub(dateym, 5, 6), 1)), + dp, cay, rf, rmrf_y3, exp_rmrf)] +dt_plot + +p0 <- dt_plot[, .(date, dp, cay, rf, rmrf_y3) ] %>% + melt(id.vars="date") %>% + ggplot(aes(date, value, colour = variable)) + + geom_line(alpha=0.75, size=0.25) + geom_point(shape=1, size = 1, alpha=0.5) + + theme_bw() +# p0 + +p1 <- dt_plot[, .(date, exp_rmrf, rmrf_y3) ] %>% + melt(id.vars="date") %>% + ggplot(aes(date, 100*value, colour = variable)) + + geom_line(alpha=0.75, size=0.25) + geom_point(shape=1, size = 1, alpha=0.5) + + xlab("") + ylab("Returns (percent)") + + theme_bw() + + theme(legend.position = c(0.3, 0.9)) + + scale_colour_manual(name = "", + breaks = c("exp_rmrf", "rmrf_y3"), + values = c(wes_palette("Zissou1")[1], wes_palette("Zissou1")[5]), + labels=c("Expected", "Realized")) + + guides(colour = guide_legend(nrow = 1)) + +ggsave("./output/predict.png", p1, width = 8, height=6) + + +