Learn R Programming

eventstudies (version 1.2.2)

marketModel: Extract residuals from a market model

Description

This function extracts residuals from a market model using function stats:lm. ‘na.exclude’ is passed as ‘na.action’ for ‘lm’. For more than one firm, the function merges “market.returns” with each element of “firm.returns” before passing to ‘lm’ so that rows of firms without ‘NA’s are not removed from the zoo object.

Usage

marketModel(firm.returns, market.returns, residuals = TRUE)

Arguments

firm.returns

a zoo time series object (univariate or otherwise) with firm returns.

market.returns

a zoo time series of market index returns.

residuals

a ‘logical’ indicating whether to return residuals or ‘lm’ object. When argument to the function includes the entire time series, returns are estimated using the entire data set and not just estimation period, value of residuals should be TRUE in such a case.

Value

Residual returns unexplained by market index returns.

Examples

Run this code
# NOT RUN {
data("StockPriceReturns")
data("OtherReturns")

mm.result <- marketModel(firm.returns = StockPriceReturns,
                         market.returns = OtherReturns$NiftyIndex,
                         residuals = TRUE)

comparison <- merge(MarketModel = mm.result$Infosys,
                    Infosys = StockPriceReturns$Infosys,
                    NiftyIndex = OtherReturns$NiftyIndex,
                    all = FALSE)
plot(comparison)
# }

Run the code above in your browser using DataLab