Autodocs
EventStudies.BootstrapInference — TypeBootstrapInference(sampling_method::Bootstrap.BootstrapSampling)
BootstrapInference(; replicates = 1000)Creates an instance of BootstrapSampling for use in inference. This can be constructed using a Bootstrap.BootstrapSampling subtype directly, or by the convenience keyword constructor which creates a BootstrapInference backed by BasicSampling.
Available sampling methods
- Random resampling with replacement (
BasicSampling) - Antithetic resampling, introducing negative correlation between samples (
AntitheticSampling) - Balanced random resampling, reducing bias (
BalancedSampling) - Exact resampling, iterating through all unique resamples ([]
ExactSampling](@ref)): deterministic bootstrap, suited for small samples sizes - Resampling of residuals in generalized linear models (
ResidualSampling,WildSampling) - Maximum Entropy bootstrapping for dependent and non-stationary datasets (
MaximumEntropySampling)
EventStudies.ClassicInference — TypeClassicInference()Creates an instance of ClassicInference for use in inference. This forwards to the T-test from HypothesisTests.jl.
EventStudies.DataMissing — TypeThis means that there was missing data within the window.
EventStudies.EventStatus — Typeabstract type EventStatusAn abstract supertype for all event status types. These are used to indicate the status of an event (i.e., if it was successful or not, and if so why it was unsuccessful).
EventStudies.InvalidColname — TypeThis means that the column name was not found in the data. It prints the column name. Equivalent to unitmissing in eventstudies.R.
EventStudies.MissingAfterModel — TypeThis means that the data had a missing value after the model's prediction.
EventStudies.ModelDataMissing — TypeThis means that the model was missing data within the event time window.
EventStudies.ModelIndexIncompatible — TypeThis means that the model's index type was incompatible with the event's index type.
EventStudies.Success — TypeRepresents a successful event
EventStudies.WilcoxonInference — TypeWilcoxonInference(; exact = nothing)Creates an instance of WilcoxonInference for use in inference. This forwards to the Wilcoxon inference test from HypothesisTests.jl.
If exact = nothing, then a heuristic determines whether to use the exact or approximate Wilcoxon signed-rank test. If exact = true, then the exact test is used; if exact = false, then the approximate test is used. If exact = nothing, then a heuristic determines whether to use the exact or approximate tests.
EventStudies.WrongSpan — TypeThis means that the span of the window extended outside the available data.
EventStudies.eventstudy — Methodeventstudy(
return_timeseries::TSFrame,
event_times::Vector{Pair{Symbol, T}},
window::Int,
model = nothing;
verbose = true
) where TTakes in a TSFrame of returns, a vector of pairs of column names and event times, and a window size. It then returns a TSFrame of event windows, where each column is the event return for the corresponding event.
Arguments
return_timeseriesis aTSFramewhich contains the returns of the assets.event_timesis a vector of pairs, where the first element is the name of the column inreturn_timeseriesand the second element is the time of the event. This is in the form:colname => date.windowis the number of data points before and after the event to include in the event window. It may be an Integer, which describes a range-window:1:window. It may also be anAbstractVectorof Integers orDates.Periods, which describes the exact window to use.modelis the decorrelating function to apply.verboseis a boolean which indicates whether to print information about the event study.
EventStudies.inference — Functioninference(inf::BootstrapInference, ts::TSFrame, conf = 0.975)Performs bootstrap inference and returns a tuple of vectors (t₀, lower, upper).
EventStudies.inference — Functioninference(::ClassicInference, ts::TSFrame, conf = 0.975)Performs classic T-test inference and returns a tuple of vectors (t₀, lower, upper).
EventStudies.inference — Methodinference(::WilcoxonInference{ExactType}, ts::TSFrame, conf = 0.975) where ExactTypePerforms Wilcoxon signed-rank inference and returns a tuple of vectors (t₀, lower, upper).
EventStudies.inference_surface — Functioninference_surface(infer::InferenceMethod, ts::TSFrame, conf = 0.975; density = 200)::(y_values::Matrix, y_colors::Matrix)EventStudies.levels_to_returns — Functionlevels_to_returns(ts::TSFrame [, base = 100])::TSFrameConverts the data in ts into "returns" data, i.e., executes diff(log(ts)) .* base on each column of ts.
EventStudies.load_data — Methodload_data(dataset::String)Load a dataset from the EventStudies.jl package. The dataset can be either a CSV file or an RData file, which is shipped along with EventStudies.jl!
EventStudies.physical_to_event_time — Methodphysical_to_event_time(timeseries::TSFrame, event_times::Vector{Pair{Symbol, T}}, window::Union{Integer, AbstractVector{<: Integer}}, model = nothing) where TConverts the input TSFrame to a vector of TSFrames - one per successful event, centered around the event time.
Arguments are the same as eventstudy. Note that model is not applied here, but its contents are checked to ensure that the model has data in that span.
Returns a tuple (event_tsframes, event_time_indices, event_return_codes):
event_tsframes::Vector{TSFrame}: a vector ofTSFrames, one per successful event.event_time_indices::Vector{Int}: the (integer) indices intimeseriesof the events.event_return_codes::Vector{EventStatus}: the status of each event. This is a vector ofEventStudies.EventStatusobjects, of the same length as the inputevent_times.
EventStudies.remap_cumsum — Methodremap_cumsum(ts::TSFrame; base = 0)This function remaps a time series into its cumulative summation. The first value of each column is set to base.
EventStudies.remap_levels — Functionremap_levels(ts::TSFrame, base = 100)EventStudies.Models — ModuleModelsThis module implements several decorrelating models for event studies.
API
The basic API which any struct MyModel <: Models.AbstractModel needs to implement is:
StatsBase.fit!(model::MyModel, data::TSFrame)StatsBase.predict(model::MyModel, data::TSFrame)
Optionally,
Models.check_window(model::MyModel, window::AbstractVector{Int}, event_time)::Bool
There is a convenience which allows any model to be fit using StatsBase.fit(model, data). In general, the model can be constructed ahead of time by providing the index or market data which it needs to predict. Then, the model can be fit to the data using StatsBase.fit!(model, data). Finally, the model can be applied to the data using StatsBase.predict(model, data).
Models
MarketModel: A basic market model which calculates $r_{ind} = r_{firm} - \alpha - \beta * r_{market}$`AugmentedMarketModel
EventStudies.Models.AbstractModel — Typeabstract type Models.AbstractModelAbstract type for models used in EventStudies.jl. Any model should implement: StatsBase.fit!(model, data::TSFrame) and Models.apply(model, data::TSFrame).
EventStudies.Models.ConstantMeanReturn — TypeConstantMeanReturn()Each column is decreased by its mean.
EventStudies.Models.ExcessReturn — TypeExcessReturn(market_returns::TSFrame)This models basic scalar excess return.
EventStudies.Models.MarketModel — Typestruct MarketModel <: AbstractModel
MarketModel(market_returns::TSFrame)A model which fits the firm's returns to the market returns, using some provided index or market indicator.
Fit using fit or fit!, and apply to data using apply
Fields
market_returns: A TSFrame which holds the market indicator/index data.coefs: The coefficients of the fit. Set byfit!.