Nothing
## ----setup, include = FALSE---------------------------------------------------
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>"
)
## ----eval=FALSE---------------------------------------------------------------
# library(EventStudy)
#
# IndustryAdjustedModel <- R6::R6Class("IndustryAdjustedModel",
# inherit = ModelBase,
# public = list(
# model_name = "IndustryAdjustedModel",
#
# fit = function(data_tbl) {
# # No estimation needed -- just compute statistics
# private$.is_fitted <- TRUE
# private$calculate_statistics(data_tbl)
# },
#
# abnormal_returns = function(data_tbl) {
# # AR = firm return - industry index return
# # Assumes data_tbl has an 'industry_return' column
# data_tbl %>%
# dplyr::mutate(abnormal_returns = firm_returns - industry_return)
# }
# ),
# private = list(
# calculate_statistics = function(data_tbl) {
# estimation_tbl <- data_tbl %>%
# dplyr::filter(estimation_window == 1)
#
# residuals <- estimation_tbl$firm_returns - estimation_tbl$industry_return
# private$add_residuals(residuals)
# private$first_order_autocorrelation(residuals)
#
# sigma <- sd(residuals, na.rm = TRUE)
# private$.statistics$sigma <- sigma
# private$.statistics$degree_of_freedom <- length(residuals) - 1
#
# # Forecast error correction
# event_window_tbl <- data_tbl %>% dplyr::filter(event_window == 1)
# private$calculate_forecast_error_correction(
# sigma, nrow(estimation_tbl),
# estimation_tbl$index_returns,
# event_window_tbl$index_returns
# )
# }
# )
# )
## ----eval=FALSE---------------------------------------------------------------
# # Create parameter set with custom model
# params <- ParameterSet$new(
# return_model = IndustryAdjustedModel$new()
# )
#
# # Run the event study
# task <- EventStudyTask$new(firm_data, index_data, request_data)
# task <- run_event_study(task, params)
## ----eval=FALSE---------------------------------------------------------------
# ExcessReturnModel <- R6::R6Class("ExcessReturnModel",
# inherit = ModelBase,
# public = list(
# model_name = "ExcessReturnModel",
# risk_free_rate = 0.0001, # daily risk-free rate
#
# initialize = function(risk_free_rate = 0.0001) {
# self$risk_free_rate <- risk_free_rate
# },
#
# fit = function(data_tbl) {
# private$.is_fitted <- TRUE
# estimation_tbl <- data_tbl %>%
# dplyr::filter(estimation_window == 1)
# residuals <- estimation_tbl$firm_returns - self$risk_free_rate
# private$.statistics$sigma <- sd(residuals, na.rm = TRUE)
# private$.statistics$degree_of_freedom <- length(residuals) - 1
# private$add_residuals(residuals)
# private$first_order_autocorrelation(residuals)
# },
#
# abnormal_returns = function(data_tbl) {
# data_tbl %>%
# dplyr::mutate(abnormal_returns = firm_returns - self$risk_free_rate)
# }
# )
# )
## ----eval=FALSE---------------------------------------------------------------
# # Factor data with date column matching firm/index data
# factor_data <- tibble::tibble(
# date = dates,
# smb = smb_returns,
# hml = hml_returns,
# risk_free_rate = rf_rate
# )
#
# task <- EventStudyTask$new(firm_data, index_data, request_data,
# factor_tbl = factor_data)
# params <- ParameterSet$new(
# return_model = FamaFrench3FactorModel$new()
# )
# task <- run_event_study(task, params)
Any scripts or data that you put into this service are public.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.