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

Error in as.POSIXlt.numeric(x, tz = tz(x)) : 'origin' must be supplied #51

Closed
MislavSag opened this issue Feb 25, 2020 · 9 comments
Closed

Comments

@MislavSag
Copy link

MislavSag commented Feb 25, 2020

Data:

data <- structure(list(date = structure(c(885394380, 885394440, 885394500, 
                                          885394560, 885394620, 885394680, 885394740, 885394800, 885394860, 
                                          885394920, 885394980, 885395040, 885395100, 885395220, 885395280, 
                                          885395400, 885395520, 885395640, 885395700, 885395760, 885395820, 
                                          885398400, 885457980, 885458040, 885458100, 885458160, 885458220, 
                                          885458280, 885458340, 885458400), class = c("POSIXct", "POSIXt"
                                          ), tzone = ""), close = c(96.96875, 96.875, 96.9375, 97.03125, 
                                                                    96.9375, 97, 97.15625, 97.0625, 97.15625, 97.0625, 97.1875, 97.09375, 
                                                                    97.125, 97.125, 97, 97.0625, 97.03125, 97, 96.9375, 96.9375, 
                                                                    97, 96.9375, 96.15625, 96.15625, 96.25, 96.15625, 96.15625, 96.1875, 
                                                                    96.25, 96.40625)), row.names = c(NA, 30L), class = "data.frame")

If I try AutoTs fucntion:

output <- AutoTS(
  data = data,
  TargetName = 'close',
  DateName = 'date',
  FCPeriods = 14,
  HoldOutPeriods = 1,
  EvaluationMetric = 'MAPE',
  TimeUnit = '1Min',
  Lags = 10,
  NumCores = 16
)

I get error
Error in as.POSIXlt.numeric(x, tz = tz(x)) : 'origin' must be supplied

I tried to set origin but doesn't help:
data$date <- as.POSIXct(data$date, format='%Y-%m-%d %H:%M:%S', origin='1970-01-01 00:00.00 UTC', tzone='GMT')

@AdrianAntico
Copy link
Owner

@MislavSag You should be good to go now. I was able to get your code running. You'll have to reinstall and restart R to get it going.

@MislavSag
Copy link
Author

MislavSag commented Mar 3, 2020

Now it returns:

Error in attr(data, "tsp") <- c(start, end, frequency) :
invalid time series parameters specified

Sample:

data <- structure(list(date = structure(c(885394380, 885394440, 885394500, 
                                          885394560, 885394620, 885394680, 885394740, 885394800, 885394860, 
                                          885394920, 885394980, 885395040, 885395100, 885395220, 885395280, 
                                          885395400, 885395520, 885395640, 885395700, 885395760, 885395820, 
                                          885398400, 885457980, 885458040, 885458100, 885458160, 885458220, 
                                          885458280, 885458340, 885458400, 885458460, 885458520, 885458580, 
                                          885458640, 885458700, 885458760, 885458820, 885458880, 885458940, 
                                          885459000, 884779620, 884779680, 884779860, 884780040, 884780160, 
                                          884780220, 884780280, 884780340, 884780400, 884780460, 884780520, 
                                          884780580, 884780640, 884780700, 884780760, 884780820, 884780880, 
                                          884781000, 884781060, 884781240, 884781300, 884781360), class = c("POSIXct", 
                                                                                                            "POSIXt"), tzone = ""), close = c(96.96875, 96.875, 96.9375, 
                                                                                                                                              97.03125, 96.9375, 97, 97.15625, 97.0625, 97.15625, 97.0625, 
                                                                                                                                              97.1875, 97.09375, 97.125, 97.125, 97, 97.0625, 97.03125, 97, 
                                                                                                                                              96.9375, 96.9375, 97, 96.9375, 96.15625, 96.15625, 96.25, 96.15625, 
                                                                                                                                              96.15625, 96.1875, 96.25, 96.40625, 96.375, 96.3125, 96.40625, 
                                                                                                                                              96.5, 96.625, 96.59375, 96.5625, 96.53125, 96.46875, 96.4375, 
                                                                                                                                              95.1875, 95.1875, 95.25, 95.125, 95.15625, 95.0625, 95.125, 95.1875, 
                                                                                                                                              95.09375, 95.09375, 95.09375, 95.21875, 95.125, 95.25, 95.25, 
                                                                                                                                              95.25, 95.1875, 95.25, 95.25, 95.25, 95.25, 95.28125)), row.names = c(NA, 
                                                                                                                                                                                                                    -62L), class = c("data.table", "data.frame"))

@AdrianAntico
Copy link
Owner

@MislavSag Alright... I fixed the issue. Had to wrap a few tryCatch's around a few more of the forecast:: functions. The problem was that if any of those failed it caused the function to fail. Hasn't been an issue till now. Nonetheless, it should be good to go!

@MislavSag
Copy link
Author

I am still geting the same error after installing the package again.

@AdrianAntico
Copy link
Owner

@MislavSag I'm not sure how you setup AutoTS to run, but this is working for me.

data <- structure(list(date = structure(c(885394380, 885394440, 885394500, 
                                          885394560, 885394620, 885394680, 885394740, 885394800, 885394860, 
                                          885394920, 885394980, 885395040, 885395100, 885395220, 885395280, 
                                          885395400, 885395520, 885395640, 885395700, 885395760, 885395820, 
                                          885398400, 885457980, 885458040, 885458100, 885458160, 885458220, 
                                          885458280, 885458340, 885458400, 885458460, 885458520, 885458580, 
                                          885458640, 885458700, 885458760, 885458820, 885458880, 885458940, 
                                          885459000, 884779620, 884779680, 884779860, 884780040, 884780160, 
                                          884780220, 884780280, 884780340, 884780400, 884780460, 884780520, 
                                          884780580, 884780640, 884780700, 884780760, 884780820, 884780880, 
                                          884781000, 884781060, 884781240, 884781300, 884781360), class = c("POSIXct", 
                                                                                                            "POSIXt"), tzone = ""), close = c(96.96875, 96.875, 96.9375, 
                                                                                                                                              97.03125, 96.9375, 97, 97.15625, 97.0625, 97.15625, 97.0625, 
                                                                                                                                              97.1875, 97.09375, 97.125, 97.125, 97, 97.0625, 97.03125, 97, 
                                                                                                                                              96.9375, 96.9375, 97, 96.9375, 96.15625, 96.15625, 96.25, 96.15625, 
                                                                                                                                              96.15625, 96.1875, 96.25, 96.40625, 96.375, 96.3125, 96.40625, 
                                                                                                                                              96.5, 96.625, 96.59375, 96.5625, 96.53125, 96.46875, 96.4375, 
                                                                                                                                              95.1875, 95.1875, 95.25, 95.125, 95.15625, 95.0625, 95.125, 95.1875, 
                                                                                                                                              95.09375, 95.09375, 95.09375, 95.21875, 95.125, 95.25, 95.25, 
                                                                                                                                              95.25, 95.1875, 95.25, 95.25, 95.25, 95.25, 95.28125)), row.names = c(NA, 
                                                                                                                                                                                                                    -62L), class = c("data.table", "data.frame"))


RemixAutoML::AutoTS(
  data,
  TargetName              = "close",
  DateName                = "date",
  FCPeriods               = 5,
  HoldOutPeriods          = 5,
  EvaluationMetric        = "MAPE",
  InnerEval               = "AICc",
  TimeUnit                = "day",
  Lags                    = 2,
  SLags                   = 1,
  MaxFourierPairs         = 0,
  NumCores                = 4,
  SkipModels              = NULL, #c("NNET","TBATS","ETS","TSLM","ARFIMA","DSHW"),
  StepWise                = TRUE,
  TSClean                 = FALSE,
  ModelFreq               = TRUE,
  PlotPredictionIntervals = TRUE,
  PrintUpdates            = FALSE)

$Forecast
                  Date Forecast_ETS ETS_Low80 ETS_Low95 ETS_High80 ETS_High95
1: 1998-01-23 01:50:00     96.43896  96.11721  95.94688   96.76071   96.93104
2: 1998-01-24 01:50:00     96.43896  95.99359  95.75783   96.88433   97.12009
3: 1998-01-25 01:50:00     96.43896  95.89750  95.61086   96.98042   97.26705
4: 1998-01-26 01:50:00     96.43896  95.81605  95.48631   97.06186   97.39161
5: 1998-01-27 01:50:00     96.43896  95.74409  95.37625   97.13382   97.50166

$EvaluationMetrics
         ModelName MeanResid MeanPercError    MAPE    MAE    MSE ID
1:             ETS     -0.10      -0.01127 0.01127 0.1006 0.0135  1
2:   ETS_ModelFreq     -0.10      -0.01127 0.01127 0.1006 0.0135  2
3:           TBATS     -0.10      -0.01127 0.01127 0.1006 0.0135  3
4: TBATS_ModelFreq     -0.10      -0.01127 0.01127 0.1006 0.0135  4
5:           ARIMA     -0.11      -0.01133 0.01133 0.1062 0.0146  5
6: ARIMA_ModelFreq     -0.11      -0.01133 0.01133 0.1062 0.0146  6

$TimeSeriesModel
ETS(A,N,N) 

Call:
 forecast::ets(y = dataTSTrain, model = "ZZN", lambda = TRUE,  

 Call:
     biasadj = TRUE, restrict = TRUE, allow.multiplicative.trend = TRUE) 

  Box-Cox transformation: lambda= 1 

  Smoothing parameters:
    alpha = 0.9571 

  Initial states:
    l = 94.1875 

  sigma:  0.2511

     AIC     AICc      BIC 
88.47561 88.88940 94.85701 

$ChampionModel
[1] "ETS"

$TimeSeriesPlot

Warning messages:
1: Removed 5 rows containing missing values (geom_path). 
2: Removed 62 rows containing missing values (geom_path). 
3: Removed 62 rows containing missing values (geom_path). 
4: Removed 62 rows containing missing values (geom_path). 
5: Removed 62 rows containing missing values (geom_path). 
6: Removed 62 rows containing missing values (geom_path). 

@MislavSag
Copy link
Author

MislavSag commented Mar 9, 2020

@AdrianAntico , doesn't work with this data:

data <- structure(list(date = structure(c(884779620, 884779680, 884779860, 
                                          884780040, 884780160, 884780220, 884780280, 884780340, 884780400, 
                                          884780460, 884780520, 884780580, 884780640, 884780700, 884780760, 
                                          884780820, 884780880, 884781000, 884781060, 884781240, 884781300, 
                                          884781360, 884781420, 884781480, 884781600, 884781660, 884781720, 
                                          884781840, 884781900, 884781960, 885394380, 885394440, 885394500, 
                                          885394560, 885394620, 885394680, 885394740, 885394800, 885394860, 
                                          885394920, 885394980, 885395040, 885395100, 885395220, 885395280, 
                                          885395400, 885395520, 885395640, 885395700, 885395760, 885395820, 
                                          885398400, 885457980, 885458040, 885458100, 885458160, 885458220, 
                                          885458280, 885458340, 885458400, 885458460, 885458520, 885458580, 
                                          885458640, 885458700, 885458760, 885458820, 885458880, 885458940, 
                                          885459000), class = c("POSIXct", "POSIXt"), tzone = ""), close = c(95.1875, 
                                                                                                             95.1875, 95.25, 95.125, 95.15625, 95.0625, 95.125, 95.1875, 95.09375, 
                                                                                                             95.09375, 95.09375, 95.21875, 95.125, 95.25, 95.25, 95.25, 95.1875, 
                                                                                                             95.25, 95.25, 95.25, 95.25, 95.28125, 95.3125, 95.3125, 95.3125, 
                                                                                                             95.3125, 95.3125, 95.3125, 95.25, 95.28125, 96.96875, 96.875, 
                                                                                                             96.9375, 97.03125, 96.9375, 97, 97.15625, 97.0625, 97.15625, 
                                                                                                             97.0625, 97.1875, 97.09375, 97.125, 97.125, 97, 97.0625, 97.03125, 
                                                                                                             97, 96.9375, 96.9375, 97, 96.9375, 96.15625, 96.15625, 96.25, 
                                                                                                             96.15625, 96.15625, 96.1875, 96.25, 96.40625, 96.375, 96.3125, 
                                                                                                             96.40625, 96.5, 96.625, 96.59375, 96.5625, 96.53125, 96.46875, 
                                                                                                             96.4375)), row.names = c(NA, -70L), class = c("data.table", "data.frame"
                                                                                                             ))

It is an irregular 1 minute data, maybe that's the problem?

@AdrianAntico
Copy link
Owner

@MislavSag I made another change and it should run for the data above that you posted.

@MislavSag
Copy link
Author

@AdrianAntico , now I get the following error (message):

"Cannot convert your data to a time series object with that TimeUnit"

I can't send you data because it has around 4200 rows. Maybe I can send you via email?

@AdrianAntico
Copy link
Owner

I would start with sharing the setup of the function... First I need to see if the TimeUnit you supplied is correct and if it is, then I'd need to see if there is anything wrong with the data. If nothing is wrong with the data, then it has to be something about converting the data to a time series object... Feel free to email me though: adrianantico@gmail.com

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