Giter Site home page Giter Site logo

eventstudies's People

Contributors

ajaynshah avatar ashimkapoor avatar chiraganand avatar renukasane avatar sargamjain13 avatar vimsaa avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

eventstudies's Issues

Support asymmetric windows

At present, the package forces the event window to be symmetric. We have an arg event.window=7

This needs to change to cover the possibility of an asymmetric window.

Here is one proposal. We should offer two cases:

event.window=7

or

event.window=list(left=3,right=10)

If the functions sees an integer upon input, then it's a symmetric window; if it sees a list, then it's an asymmetric window.

Error in rval[i, j, drop = drop., ...] : subscript out of bounds

Hello, I am trying to estimate an event study model and estimation runs fine when I use type = "None". When I try to use type = "marketModel" and I submit market returns as

model.args = list( market.returns = data$variable)

I get the error Error in rval[i, j, drop = drop., ...] : subscript out of bounds

Looking at the code of the function eventstudy I cannot see when this object is used. I thought the problem might be the different dates or different number of rows between firm.returns and market.returns, but I have made sure they have the same dates and the same number of rows, so I am a bit clueless as to what the problem is.

Any help in debugging this error is appreciated.

Error in rval[i, j, drop = drop., ...] : invalid subscript type 'list'

Hi everyone,

I tried to run an event study for an analysis and I got the following error : "Error in rval[i, j, drop = drop., ...] : invalid subscript type 'list'".
I am not familiar with the method and this might be a rooky mistake.

Here is my code:

df_first_test <- subset(df_first, select=c('channel', 'date_formated', 'id_0'))

info <- df_first_test%>%
  pivot_wider(names_from = channel, values_from = id_0)

# info is a dataframe composed of 21 rows (weeks) and 50064 columns (channels).

info <- read.zoo(info, header=TRUE, index.column = 1, format = "%Y-%m-%d")

df_treatment_time=subset(df_first, select=c('channel'))
colnames(df_treatment_time)[1] ="name"
df_treatment_time$when='2017-03-26'
df_treatment_time$when <- as.Date(df_treatment_time$when, "%Y-%m-%d")

es <-eventstudy(firm.returns = info,
                event.list = df_treatment_time,
                event.window = 9,
                type = 'None', 
                to.remap = TRUE,
                remap = 'cumsum',
                inference = TRUE,
                inference.strategy = 'bootstrap')
plot(es)

Here is a snapshot of the error:
image

Here are some information about my datasets :
Info dataset (prior to transformation into a zoo object)
image

Info data (post transformation into zoo object)
image

df_treatment_time dataset
image

I thank you in advance for your time and help.
Maria

Edit : I think it's my zoo dataset which causes the issue ๐Ÿ˜“

the argument inference = FALSE and to.remap = FALSE leads to and error in plot(eventstudy)

While using the eventstudy package if we put inference = FALSE it leads to an error when trying to use the plot() function within the package
Here is a MWE for the issue:

library(zoo)
library(eventstudies)

time.dt  <- data.frame(name=c("A","B"),
                       when=as.Date(c("2014-01-01","2014-01-01")))


gdp.dt  <- data.frame(state=rep(c("A","B"),each=5),
                      year=as.Date(rep(c("2012-01-01","2013-01-01","2014-01-01","2015-01-01","2016-01-01"),each = 1)),
                      gdp= c(100,100,100,160,165,50,50,50,80,85))

dtlist <- split(gdp.dt, gdp.dt$state)

z_list <- lapply(dtlist, function(x) zoo(x$gdp, order.by = x$year))

exp.zoo  <- do.call(merge, z_list)

### eventstudy without levels,with original values
es <- eventstudies::eventstudy(firm.returns = exp.zoo,
         event.list = time.dt,
         event.window = 2,
         is.levels=FALSE,
         type = "None",
         to.remap = FALSE,
         inference = TRUE
         )
pdf("eventstudy_inference_true.pdf")
plot(es)
dev.off()
### eventstudy with levels, percentage change 
es_inf_false <- eventstudies::eventstudy(firm.returns = exp.zoo,
         event.list = time.dt,
         event.window = 2,
         is.levels=FALSE,
         type = "None",
         to.remap = FALSE,
         inference = FALSE
     )
plot(es_inf_false)

eventstudy_inference_true.pdf
The attached file is the plot created when we keep inference = TRUE
In the following case where inference = FALSE we get the following error

Error in xy.coords(x, y, xlabel, ylabel, log) : 
  'x' and 'y' lengths differ

The eventstudy value in the case of inference = FALSE (i.e es_inf_false) comes out to be

     1  2
-1 100 50
0  100 50
1  160 80
2  165 85

set estimation.period

Is there any way to manually configure the estimation period for the expected returns regression? In a time series with multiple events, one might want to exclude events from the estimation task.

Thanks in advance

USE future_lapply for performance

hi,

Thanks for great package. I have tried to use you package with hour frequency data for period 2004-2020, with just 694 events and 10 stocks.

The code is really slow (I haven't wait it to finish but it is slow).

I discovered the lapply part inside prepare.returns function is slow.

Can I advise you to use future_lapply instead of lapply for parallel processing?

It can increases the performance.

IS there any function that can be improved by using C++?

Improvements to the "replications" vignette

  1. This is impressive. It is the hallmark of professional software that we do replication of published results and prove that the answers are correct.

  2. For both the replicated results, there is a need to place scanned PNG files of the tables/graphs from the original papers into this file so that, at a glance, the user can see that this is replicated.

  3. What's the "make replicate" equivalent through which the end-user can verify that these test cases work correctly? One needs to manually dput() the required data object and then compare all the values.

  4. There is probably a grammar error at "As the results reported in Table 2 on Page No. 358 in Chen and Siems (2004), we report the 11-day CAR and 6-day CAR. " where we probably want "As with the results".

  5. In both cases, I did not like the look of the replication code. It was too complicated. I feel we need to have native functionality of the package so that such tasks are done readily.

  6. We need more replicated papers.

  7. These two papers cover one use case (daily data, market model adjustment). The package needs to be much more general and cover all kinds of economic data (households, countries, etc.) including non-financial data. The replication of papers also needs to be similarly ambitious.

Front page is not nice

https://github.com/xKDR/eventstudies is not a good front page for the package.

(In general, I dislike most front pages on github, so this could just be me). But if we had to show a one page to a prospective user, it would not be this.

We have citations -- https://scholar.google.com/scholar?cites=15232508038484313390&as_sdt=2005&sciodt=0,5&hl=en and https://scholar.google.com/scholar?cites=332369116181392410&as_sdt=2005&sciodt=0,5&hl=en , these need to be shown or linked on the front page.

eventstudies package unable to handle integer dates

eventstudies package accepts only "POSIXt" or "Date" format for dates and gives the following error when integers are used as index for the zoo object.

Error in phys2eventtime(z = returns$firm.returns, events = event.list[i,  : 
  events$when should be one of 'Date' or 'date-time' classes.

Here is a MWE for the issue:

library(eventstudies)
library(zoo)

### Creating data
time.dt  <- data.frame(name=c("A","B","C","D","E"),
                       when=c(3,3,3,3,3))
gdp.dt  <- data.frame(state=rep(c("A","B","C","D","E"),each=10),
                      year=rep(c(1,2,3,4,5,6,7,8,9,10),each = 1),
                      gdp= rep(c(100,100,100,160,165,50,50,50,80,85),each = 5))

dtlist <- split(gdp.dt, gdp.dt$state)

z_list <- lapply(dtlist, function(x) zoo(x$gdp, order.by = x$year))

exp.zoo  <- do.call(merge, z_list)

### eventstudy
es <- eventstudies::eventstudy(firm.returns = exp.zoo,
                 event.list = time.dt,
                 event.window = 2,
                 is.levels=FALSE,
                 type = "None",
                 to.remap = FALSE,
                 inference = TRUE)

Plot method

Great package! Minor issue though: although recorded in the NAMESPACE as export, can't access plot method for es objects.

Improvements for the main package vignette

  1. It would be better if the identical ylim were used for Figure 1 and Figure 2, so that the variance reduction is visually apparent.

  2. A little more work on interpreting Figure 3 would be useful. I think I see the market revving up the stock price from about -20 minutes on.

  3. We require a package that will work with all possible time frequencies (intra-day, daily, weekly, monthly, quarterly, annual, non-specific integer valued time). And, the package vignette needs to flaunt this so that it does not look like a stock market + AMM story alone.

p-values

Hello and thank you for the excelant package
Is it possible to obtain p-values for the bootstrapped estimates>
Regards
snvv

Error in rval[i, j, drop = drop., ...] : subscript out of bounds (eventstudies)

Hi, I am trying to run an event study model using the market model and i get the error: Error in rval[i, j, drop = drop., ...] : subscript out of bounds.

When I run the event study using the type="None" it runs fine but when I use type = "marketModel" that fails.

This is the code:
es1 <-eventstudy(firm.returns = pret,
event.list = SplitDates,
event.window = 2,
type = 'marketModel', #Here we use the market model
to.remap = TRUE,
remap = 'cumsum',
inference = TRUE,
inference.strategy = 'bootstrap',
model.args = list(
market.returns = index[,"BET", drop = FALSE] #Here we specify what benchmark we will use
))

I made sure that the daates start, are and end the same. The number of observations is the same.

Extra info about the data sets:

class(pret)
[1] "zoo"
pret contains 17 companies
class(SplitDates)
[1] "data.frame"
class(index)
[1] "zoo"
index contains 2 indexes

Any help in debugging this error is much appreciated.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.