ModelBase: ModelBase

ModelBaseR Documentation

ModelBase

Description

Base (abstract) class for return models used inside an EventStudyTask. Each single event gets its own model instance, fitted on that event's estimation-window data alone. Subclass this to plug a custom return model into run_event_study() / fit_model().

A subclass must implement two methods:

  • fit(data_tbl) – fit the model on data_tbl (a single event's rows, estimation and event window together) and populate private$.statistics plus set private$.is_fitted.

  • abnormal_returns(data_tbl) – return data_tbl with an abnormal_returns column added for the event window.

The statistics active binding exposes a named list consumed by the test statistics layer. At minimum a subclass should populate: sigma, degree_of_freedom, residuals, forecast_error_corrected_sigma and forecast_error_corrected_sigma_car. Since 2026-09-24, a model may also set statistics$n_params (the number of parameters estimated from the estimation window); PatellZTest reads this field for its Q_i adjustment and falls back to 2 when a subclass does not report it.

Degenerate-input handling: subclasses that implement the shared contract (see R/contract.R) read self$degenerate_mode, self$event_id and self$firm_symbol, which are threaded onto the cloned model instance by fit_model() before fit() is called.

Public fields

model_name

Name of the model.

degenerate_mode

Resolved degenerate-input mode injected by fit_model() before fit() is called. Subclasses that implement the degenerate-input contract (MarketModel and Phase-2 models) read this field inside fit() via .resolve_degenerate_mode(self$degenerate_mode).

event_id

Event identifier threaded from the outer data_tbl row. Used in degenerate-input error/warning messages.

firm_symbol

Firm identifier threaded from the outer data_tbl row. Used in degenerate-input error/warning messages.

Active bindings

statistics

Read-only field to get statistics.

model

Read-only field to get the fitted model.

is_fitted

Read-only field to check if the model is fitted. Statistics object contains different model specific KPIs that describes the fitted model.

Methods

Public methods


ModelBase$fit()

Fits the model with given data.

Usage
ModelBase$fit(data_tbl)
Arguments
data_tbl

A data frame or tibble containing the data to fit.


ModelBase$abnormal_returns()

Calculate the abnormal returns with given data and fitted model.

Usage
ModelBase$abnormal_returns(data_tbl)
Arguments
data_tbl

Data frame or tibble containing the data to calculate abnormal returns.


ModelBase$clone()

The objects of this class are cloneable with this method.

Usage
ModelBase$clone(deep = FALSE)
Arguments
deep

Whether to make a deep clone.

See Also

Other eventstudy-models: BHARModel, Carhart4FactorModel, ComparisonPeriodMeanAdjustedModel, DCCGARCHModel, FamaFrench3FactorModel, FamaFrench5FactorModel, GARCHModel, LinearFactorModel, LogReturn, MarketAdjustedModel, MarketModel, ReturnCalculation, RollingWindowModel, SimpleReturn, VolatilityModel, VolumeModel


EventStudy documentation built on Oct. 31, 2026, 1:07 a.m.