TransWikia.com

How can I split hourly time series?

Data Science Asked by Dario_Della on May 9, 2021

I’m newbie in R and time series analysis. I’m trying to build an Arima model.
My dataset has this structure:

DATA         Ora    VALORE
<chr>       <dbl>    <dbl>
      
2018-09-01    1      3646742    
2018-09-01    2      3273110    
2018-09-01    3      3069245    
2018-09-01    4      2969621    

I’ve converted this dataset in a hourly time series and split it in a training set and a test set with this code:

y <- ts(data$VALORE,start=c(2018,09, 00:00), frequency=24*365)

y_train <- window(y, c(2018, 09), c(2020, 06))

y_test <- window(y,c(2020, 07), c(2020, 08))

Problems:

  1. test set contains two observations (instead 1488 = all July and all August 2020);

  2. training set contains 17518 observations (instead 16032).

Can I solve these problems?

One Answer

The Solution that I have found:

y <- ts(data$VALORE,
               frequency = 24,   
               start = 1)        

train <- ts(y[1:12264], frequency=24) #70%
val <- ts(y[12265:17520], frequency=24) #30%

Correct answer by Dario_Della on May 9, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP