Skip to main content
edited tags
Source Link
kjetil b halvorsen
  • 82.8k
  • 32
  • 201
  • 663
  1. I have 36 months data and many of the series has leading NAs as not for all the series data is observed from the beginning I am working on hierarchical time series data and interested in interactions also.
    Just to elaborate more - The 2 hierarchies are Geo hierarchy - Area  ->Subregion> Subregion ->Subsidiary> Subsidiary and Business HoerarchyHierarchy - Business sector -> Business Sub-sector Requirement is to do the predictions at area level, sector level and also wants to know how the sector A is likely to perform in Area1 After reading the couple of posts on hierarchical time series I got to know that group time series can solve this problem.

But I couldntcouldn't get any examples with code  (R) on this, if any sample code is available that would help.

  1. I have 36 months data starting from Jan-2014 and many of the series data is not observed from Jan-2014 i.e it starts from Aug-2014, July-2015 so I have leading NAs for these series

    I have 36 months data starting from Jan-2014 and many of the series data is not observed from Jan-2014 i.e it starts from Aug-2014, July-2015 so I have leading NAs for these series how to handle it as I am getting error in gts function while executing

    how to handle it as I am getting error in gts function while executing
  2. By default it supports only ("ets","arima") models for future predictions - what if I have to use other methods?

    By default it supports only ("ets","arima") models for future predictions - what if I have to use other methods?

  3. while using the accuracy.gts function getting the

    1. while using the accuracy.gts function getting the error - Error in colnames<-(*tmp*, value = unlist(labels[levels])) : length of 'dimnames' [2] not equal to array extent

    error - Error in colnames<-(*tmp*, value = unlist(labels[levels])) : length of 'dimnames' [2] not equal to array extent

r-code --------enter link description here------------------

library(hts)

data <- read.csv("test_data_gts.csv", header = TRUE)

traning_data <- data[ data$Month_Num<31, -1 ]

gy <- gts(traning_data, characters = list(c(4,4,4),c(5,4)) )

 
## after removing the columns with leading NAs , I can create the group time series but I dont want to exlude those columns 

na_cols <- c()
for( i in 2:dim(traning_data)[2]){
  if(any(is.na(traning_data[,i]))){ na_cols <- c( na_cols, i) }
}

traning_data_1 <- traning_data[ , -(na_cols)]

y <- gts(traning_data_1, characters = list(c(4,4,4),c(5,4)) )


## Continued with this series to explore on gts - forecast using forecast.gts

fcast <- forecast(y, h=6, method = "bu",fmethod= "ets" )

holdout_data <- data[data$Month_Num >30, -c(1,na_cols)]

h <- gts(holdout_data,characters = list(c(4,4,4),c(5,4)) )

accuracy.gts(fcast, h ) # gives error - Error in `colnames<-`(`*tmp*`, value = unlist(labels[levels])) : length of 'dimnames' [2] not equal to array extent

Sample data set -

enter link description hereSample data set

  1. I have 36 months data and many of the series has leading NAs as not for all the series data is observed from the beginning I am working on hierarchical time series data and interested in interactions also.
    Just to elaborate more - The 2 hierarchies are Geo hierarchy - Area->Subregion->Subsidiary and Business Hoerarchy - Business sector -> Business Sub-sector Requirement is to do the predictions at area level, sector level and also wants to know how the sector A is likely to perform in Area1 After reading the couple of posts on hierarchical time series I got to know that group time series can solve this problem.

But I couldnt get any examples with code(R) on this, if any sample code is available that would help.

  1. I have 36 months data starting from Jan-2014 and many of the series data is not observed from Jan-2014 i.e it starts from Aug-2014, July-2015 so I have leading NAs for these series how to handle it as I am getting error in gts function while executing
  2. By default it supports only ("ets","arima") models for future predictions - what if I have to use other methods?
    1. while using the accuracy.gts function getting the error - Error in colnames<-(*tmp*, value = unlist(labels[levels])) : length of 'dimnames' [2] not equal to array extent

r-code --------enter link description here

library(hts)

data <- read.csv("test_data_gts.csv", header = TRUE)

traning_data <- data[ data$Month_Num<31, -1 ]

gy <- gts(traning_data, characters = list(c(4,4,4),c(5,4)) )

 
## after removing the columns with leading NAs , I can create the group time series but I dont want to exlude those columns 

na_cols <- c()
for( i in 2:dim(traning_data)[2]){
  if(any(is.na(traning_data[,i]))){ na_cols <- c( na_cols, i) }
}

traning_data_1 <- traning_data[ , -(na_cols)]

y <- gts(traning_data_1, characters = list(c(4,4,4),c(5,4)) )


## Continued with this series to explore on gts - forecast using forecast.gts

fcast <- forecast(y, h=6, method = "bu",fmethod= "ets" )

holdout_data <- data[data$Month_Num >30, -c(1,na_cols)]

h <- gts(holdout_data,characters = list(c(4,4,4),c(5,4)) )

accuracy.gts(fcast, h ) # gives error - Error in `colnames<-`(`*tmp*`, value = unlist(labels[levels])) : length of 'dimnames' [2] not equal to array extent

Sample data set -

enter link description here

  1. I have 36 months data and many of the series has leading NAs as not for all the series data is observed from the beginning I am working on hierarchical time series data and interested in interactions also.
    Just to elaborate more - The 2 hierarchies are Geo hierarchy - Area  -> Subregion -> Subsidiary and Business Hierarchy - Business sector -> Business Sub-sector Requirement is to do the predictions at area level, sector level and also wants to know how the sector A is likely to perform in Area1 After reading the couple of posts on hierarchical time series I got to know that group time series can solve this problem.

But I couldn't get any examples with code  (R) on this, if any sample code is available that would help.

  1. I have 36 months data starting from Jan-2014 and many of the series data is not observed from Jan-2014 i.e it starts from Aug-2014, July-2015 so I have leading NAs for these series how to handle it as I am getting error in gts function while executing

  2. By default it supports only ("ets","arima") models for future predictions - what if I have to use other methods?

  3. while using the accuracy.gts function getting the

    error - Error in colnames<-(*tmp*, value = unlist(labels[levels])) : length of 'dimnames' [2] not equal to array extent

r-code --------------------------

library(hts)

data <- read.csv("test_data_gts.csv", header = TRUE)

traning_data <- data[ data$Month_Num<31, -1 ]

gy <- gts(traning_data, characters = list(c(4,4,4),c(5,4)) )

 
## after removing the columns with leading NAs , I can create the group time series but I dont want to exlude those columns 

na_cols <- c()
for( i in 2:dim(traning_data)[2]){
  if(any(is.na(traning_data[,i]))){ na_cols <- c( na_cols, i) }
}

traning_data_1 <- traning_data[ , -(na_cols)]

y <- gts(traning_data_1, characters = list(c(4,4,4),c(5,4)) )


## Continued with this series to explore on gts - forecast using forecast.gts

fcast <- forecast(y, h=6, method = "bu",fmethod= "ets" )

holdout_data <- data[data$Month_Num >30, -c(1,na_cols)]

h <- gts(holdout_data,characters = list(c(4,4,4),c(5,4)) )

accuracy.gts(fcast, h ) # gives error - Error in `colnames<-`(`*tmp*`, value = unlist(labels[levels])) : length of 'dimnames' [2] not equal to array extent 

Sample data set

edited tags
Link
kjetil b halvorsen
  • 82.8k
  • 32
  • 201
  • 663
less to the data file so that others can access it
Source Link
Ferdi
  • 5.3k
  • 10
  • 47
  • 64

I am looking for group time series examples ,. I am working on two hierarchies and interested in interactions also. Couple of challenges I am facing -

r-code --------enter link description here

library(hts)

data <- read.csv("test_data_gts.csv", header = TRUE)

traning_data <- data[ data$Month_Num<31, -1 ]

gy <- gts(traning_data, characters = list(c(4,4,4),c(5,4)) )

after removing the columns with leading NAs , I can create the group time series but I dont want to exlude those columns

na_cols <- c() for( i in 2:dim(traning_data)[2]){ if(any(is.na(traning_data[,i]))){ na_cols <- c( na_cols, i) } }

traning_data_1 <- traning_data[ , -(na_cols)]

y <- gts(traning_data_1, characters = list(c(4,4,4),c(5,4)) )

Continued with this series to explore on gts - forecast using forecast.gts

fcast <- forecast(y, h=6, method = "bu",fmethod= "ets" )

holdout_data <- data[data$Month_Num >30, -c(1,na_cols)]

h <- gts(holdout_data,characters = list(c(4,4,4),c(5,4)) )

accuracy.gts(fcast, h ) # gives error - Error in colnames<-(*tmp*, value = unlist(labels[levels])) : length of 'dimnames' [2] not equal to array extent

Sample data set -

library(hts)

data <- read.csv("test_data_gts.csv", header = TRUE)

traning_data <- data[ data$Month_Num<31, -1 ]

gy <- gts(traning_data, characters = list(c(4,4,4),c(5,4)) )

 
## after removing the columns with leading NAs , I can create the group time series but I dont want to exlude those columns 

na_cols <- c()
for( i in 2:dim(traning_data)[2]){
  if(any(is.na(traning_data[,i]))){ na_cols <- c( na_cols, i) }
}

traning_data_1 <- traning_data[ , -(na_cols)]

y <- gts(traning_data_1, characters = list(c(4,4,4),c(5,4)) )


## Continued with this series to explore on gts - forecast using forecast.gts

fcast <- forecast(y, h=6, method = "bu",fmethod= "ets" )

holdout_data <- data[data$Month_Num >30, -c(1,na_cols)]

h <- gts(holdout_data,characters = list(c(4,4,4),c(5,4)) )

accuracy.gts(fcast, h ) # gives error - Error in `colnames<-`(`*tmp*`, value = unlist(labels[levels])) : length of 'dimnames' [2] not equal to array extent

Sample data set -

looking for group time series examples , I am working on two hierarchies and interested in interactions also. Couple of challenges I am facing -

r-code --------enter link description here

library(hts)

data <- read.csv("test_data_gts.csv", header = TRUE)

traning_data <- data[ data$Month_Num<31, -1 ]

gy <- gts(traning_data, characters = list(c(4,4,4),c(5,4)) )

after removing the columns with leading NAs , I can create the group time series but I dont want to exlude those columns

na_cols <- c() for( i in 2:dim(traning_data)[2]){ if(any(is.na(traning_data[,i]))){ na_cols <- c( na_cols, i) } }

traning_data_1 <- traning_data[ , -(na_cols)]

y <- gts(traning_data_1, characters = list(c(4,4,4),c(5,4)) )

Continued with this series to explore on gts - forecast using forecast.gts

fcast <- forecast(y, h=6, method = "bu",fmethod= "ets" )

holdout_data <- data[data$Month_Num >30, -c(1,na_cols)]

h <- gts(holdout_data,characters = list(c(4,4,4),c(5,4)) )

accuracy.gts(fcast, h ) # gives error - Error in colnames<-(*tmp*, value = unlist(labels[levels])) : length of 'dimnames' [2] not equal to array extent

Sample data set -

I am looking for group time series examples. I am working on two hierarchies and interested in interactions also. Couple of challenges I am facing

r-code --------enter link description here

library(hts)

data <- read.csv("test_data_gts.csv", header = TRUE)

traning_data <- data[ data$Month_Num<31, -1 ]

gy <- gts(traning_data, characters = list(c(4,4,4),c(5,4)) )

 
## after removing the columns with leading NAs , I can create the group time series but I dont want to exlude those columns 

na_cols <- c()
for( i in 2:dim(traning_data)[2]){
  if(any(is.na(traning_data[,i]))){ na_cols <- c( na_cols, i) }
}

traning_data_1 <- traning_data[ , -(na_cols)]

y <- gts(traning_data_1, characters = list(c(4,4,4),c(5,4)) )


## Continued with this series to explore on gts - forecast using forecast.gts

fcast <- forecast(y, h=6, method = "bu",fmethod= "ets" )

holdout_data <- data[data$Month_Num >30, -c(1,na_cols)]

h <- gts(holdout_data,characters = list(c(4,4,4),c(5,4)) )

accuracy.gts(fcast, h ) # gives error - Error in `colnames<-`(`*tmp*`, value = unlist(labels[levels])) : length of 'dimnames' [2] not equal to array extent

Sample data set -
given access to the data file so that others can access it
Source Link
Loading
Post Reopened by kjetil b halvorsen, Peter Flom
Elaborated the problem statement and added the code and dataset I am working on
Source Link
Loading
Post Closed as "Needs details or clarity" by Peter Flom
Source Link
Loading