-
Notifications
You must be signed in to change notification settings - Fork 18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error in lm.fit(x, y, offset = offset, singular.ok = singular.ok, ...) : 0 (non-NA) cases #8
Comments
Can you please give us a MWE?
…On Mon, 7 Jun, 2021, 15:45 Mislav Sagovac, ***@***.***> wrote:
I am getting ollowing error:
Error in lm.fit(x, y, offset = offset, singular.ok = singular.ok, ...) :
0 (non-NA) cases
It seems the error appears if data in lm function contains only NA. And
that happens when, for example, event.window is exactly equal to number of
non-NA elements before event date.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#8>, or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ACO2TJGAVSLPC5K2YCYSB53TRSL2RANCNFSM46HKW6QQ>
.
|
Here is the sample code:
|
The code does not run for me. Please define event_horizon and provide a MWE to replicate the error. |
@vimsaa , Please try with this code, after defining
|
I am unable to replicate the error you show above. I used the code you shared (appended below) and I get the following error: "Error in lm.fit(x, y, offset = offset, singular.ok = singular.ok, ...) : This is because lm.fit does not like NA/Inf in the data. In the next rollout of the package, we will internally drop entries that contain "Inf". A single line of code before calling eventstudy() currently fixes this problem: returns_sample <- returns_sample[is.finite(returns_sample$ATC),drop=FALSE] ## <-- This is all is needed. Hope this helps, library(eventstudies) returns_sample <- structure(c(Inf, -0.012987012987013, 0, -0.0105263684210527, events_sample <- structure(list(when = structure(c(18663, 18690, 18751, 18751), class = "Date"), market_returns <- quantmod::getSymbols("SPY") es <- eventstudy(firm.returns = returns_sample , |
I was looking for Inf in View mode, but didn't see it. Thanks for explanation. |
Just want to add that I get this error sometimes even if there are no Inf or NaN values in firm returns. |
Thank you for getting back in touch! Please provide an MWE to replicate the error so that we can improve the package! |
I figure out the problem. Market returns and firm returns were not aligned. For example, if market returns start in 1993 and firm returns span some data from 1992, it can return above error. |
Is there some way in which we can do better error detection & handling?
…On Mon, 19 Jul 2021 at 19:17, Mislav Sagovac ***@***.***> wrote:
I figure out the problem. Market returns and firm returns were not
aligned. For example, if market returns start in 1993 and firm returns span
some data from 1992, it can return above error.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#8 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ACO2TJEH6WBD2YM4NZ5ZLFLTYQUFNANCNFSM46HKW6QQ>
.
--
Ajay Shah
***@***.***
http://www.mayin.org/ajayshah
|
We can detect
Ideally, the package function should take care of this scenario because it does an inner join (via |
Hello |
I am getting ollowing error:
It seems the error appears if data in lm function contains only NA. And that happens when, for example, event.window is exactly equal to number of non-NA elements before event date.
The text was updated successfully, but these errors were encountered: