Skip to content
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

Getting Error on part of my time series #54

Open
MehrdadVaredi opened this issue Feb 28, 2021 · 3 comments
Open

Getting Error on part of my time series #54

MehrdadVaredi opened this issue Feb 28, 2021 · 3 comments

Comments

@MehrdadVaredi
Copy link

Hi Steffen and Bartz,

I got an error after running the na_kalman from imputeTS library. This function works on part of the xts time series object I was testing, although it returns an error if applied on all of it.

The error is:

Error in if (frequency > 1 && 0 < (d <- abs(frequency - round(frequency))) && :
missing value where TRUE/FALSE needed

This is the structure of the its object:

str(SCADA_xts)

An ‘xts’ object on 2017-04-18 20:00:00/2019-07-31 20:00:00 containing:
Data: num [1:64120, 1] 198348 198618 195981 188490 186822 ...
Indexed by objects of class: [POSIXct,POSIXt] TZ: America/Toronto
xts Attributes:
NULL

Do you have any idea what might be wrong with my data?

Thanks and best regards,

Mehrdad

@SteffenMoritz
Copy link
Owner

SteffenMoritz commented Mar 2, 2021

Thanks for reporting! 👍

Oh, strange error. On first sight I'd assume it has something to do with the xts object.

Can you try

    test <-  as.data.frame(coredata(SCADA_xts))
    na_kalman(test)

To see if it works, when it is not a xts object.

@MehrdadVaredi
Copy link
Author

You were right Steffen! I get no errors if I apply na_kalman on the data.frame ! Thank you!

Kind regards,
Mehrdad

@SteffenMoritz
Copy link
Owner

Sounds great 👍
Always complicated, everybody uses different time series objects in R....zoo, xts, tsibble, tibble, data.frame, vector.

imputeTS is written for vector, data.frame and ts inputs.
But I try to keep it compatible with all of the different possible time series objects.

Still, as you can see, for time to time errors occur for certain edge cases. This one seems to be present specifically for na_kalman in combination with xts objects. I'll additionally have a look in the upcoming days if I can prevent this error for xts objects.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants