I have a time series starting on January 30th 2018 and ending on June 14th 2020 that I would like to seasonnally adjust with the Indian holidays. To do so, I wanted to use the DSA package and the dsa function, based on the research that I made (It is a model that can deal with daily time series unlike X-13 for instance).
First of all, I import my csv file with 2 columns and 867 rows and I convert it into a xts object (necessary form for the use of the dsa function).
library(dsa)
library(xts)
daily_demand_df = read.table(file = file.path(file_path,"Demand data - daily.csv"),
sep = ";", row.names = NULL, header = FALSE,
encoding = 'utf-8', skip = 1,
colClasses = c("character", "character"),
col.names = c("Date","Demand_Value"))
daily_demand_df$Demand_Value <- as.numeric(gsub(',', '.', daily_demand_df$Demand_Value))
daily_demand_df$Date<-as.Date(daily_demand_df$Date, format = "%d/%m/%Y")
daily_demand_df <- daily_demand_df[order(daily_demand_df$Date),]
rownames(daily_demand_df) <- 1:nrow(daily_demand_df)
head(x = daily_demand_df)
Date Demand_Value
1 2018-01-29 3242.5
2 2018-01-30 3269.5
3 2018-01-31 3276.9
4 2018-02-01 3274.1
5 2018-02-02 3291.3
6 2018-02-03 3286.1
daily_demand_timeserie <- xts(x = daily_demand_df$Demand_Value,
order.by = daily_demand_df$Date,
frequency=365.2425)
Then I tried to apply the dsa function (without the holidays effect for now) on the time series, but I got the following error:
adjusted <- dsa(series = daily_demand_timeserie)
Error in xts::xts(s1, order.by = xts::last(times, n = length(s1))) : NROW(x) must match length(order.by)
I tried to explore the DSA function source code in order to understand where the probleme might lie, and I found out that in the function, at some point, February 29th is removed from the time series. Then I modified the source code of the dsa function to print the length of the s1
and the time
series used in the dsa function and it returned 869 and 868, hence the length issue.
Does anyone know how to solve this issue ?
Thank you in advance, here is the documentation that I used.