hierarchy - R HTS package: combinef and aggts not working with gts object -


i'm trying apply combinef , aggts functions r hts package time series matrix in order obtain optimized set of forecasts across hierarchy. i've run same code every month without issue, , seeing errors after upgrading hts package v4.5.

reproducible example (i can share data file offline if needed)

    #read in forecast data levels of hierarchy#  fcast<-read.csv("samplehierarchyforecast.csv", header = true, check.names = false)  #convert time series#  fcast<-ts(fcast, start = as.numeric(2010.25) + (64)/12, end = as.numeric(2010.25) + (75)/12, f= 12)  #create time series of bottom level of hierarchy# index<-c()  fcastbottom<-fcast (i in 1:length(fcastbottom [1,])) {     if(nchar(colnames(fcastbottom)[i])!=28)     index[i]<-i     else     index[i]<-0 } fcastbottom<-fcastbottom[,-index]  #create grouped time series bottom level forecast # gtsforecast <- gts(fcastbottom, characters = list(c(12,12), c(4)), gnames = c("category", "item", "customer", "category-customer")) #use combinef function optimally combine full hierarchy forecast using groups full hierarchy gts# combo <- combinef(fcast, groups = gtsforecast$groups) *warning message: in mapply(rep, as.list(gnames), times, simplify = false) :   longer argument not multiple of length of shorter* traceback() 2: stop("argument fcasts requires forecasts.") 1: combinef(fcast, groups = gtsforecast$groups) 

there's little bug when comebinef() function calls gts(). i've fixed on github. can run own code above without trouble after updating the development version.

alternatively, need tweak code bit if don't want install newest version.

combo <- combinef(fcast, groups = gtsforecast$groups, keep = "bottom") combo <- ts(combo, start = as.numeric(2010.25) + (64)/12,              end = as.numeric(2010.25) + (75)/12, f = 12) colnames(combo) <- colnames(fcastbottom) newgtsforecast <- gts(combo, characters = list(c(12,12), c(4)),                    gnames = c("category", "item", "customer",                               "category-customer")) aggregate <- aggts(newgtsforecast) 

hope helps.


Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

Rendering JButton to get the JCheckBox behavior in a JTable by using images does not update my table -