phys2eventtime: Convert data from physical to event time

Description Usage Arguments Details Value Author(s) See Also Examples

View source: R/phys2eventtime.R

Description

‘phys2eventtime’ is used to convert data from physical to event time using information on events identified by the user.

Usage

1
phys2eventtime(z, events, width = 10)

Arguments

z

an object of class zoo or xts containing data to be converted into event time.

events

‘data.frame’ containing event identifiers. See ‘Details’.

width

an ‘integer’ specifying the event window within which data should be available to consider the outcome a 'success'. See ‘Details’.

Details

“events” object contains two columns: “name” consists of names of the event, and “when” is the respective event time. ‘class’ of ‘index’ of “z” and “when” should be same and one of the ‘date-time’ or ‘Date’ classes.

If an event date does not lie within the index of “z”, the function approximates to the nearest previous time using findInterval. Note that ‘findInterval’ assumes the index of ‘z’ is non-decreasing.

The argument “width” provides the user with an option to define successful events as those that have data within a window around the event. Window is defined as (-width, +width]. If “width” is 10 periods, those events with ‘NA’ within 10 periods before and after the event will be classified as “wdatamissing”, otherwise, the event “outcome” will be classified as “success”.

Currently this function requires “z” to have at least one column. It relies on ‘colnames’ of “z” for the series names, and matches it with the “events” object. One can use drop = FALSE with ‘[’ to achieve a single-column object.

Value

Returns a ‘list’ of two elements:

z.e

a zoo object containing data of successful events indexed with event time; “NULL” if there are no “success” in “outcomes”. ‘colnames’ of z.e are event numbers: row numbers of “events”.

outcomes

a character vector with outcome definition for each event.

Author(s)

Ajay Shah, Chirag Anand, Vikram Bahure, Vimal Balasubramaniam

See Also

findInterval

Examples

1
2
3
4
5
6
7
8
data(StockPriceReturns)
data(SplitDates)

result <- phys2eventtime(z = StockPriceReturns,
			 events = SplitDates,
			 width = 5)
print(result$z.e[as.character(-4:5)])
print(SplitDates[result$outcomes == "success", ])

eventstudies documentation built on July 4, 2017, 9:46 a.m.