config-i1 / smooth

The set of functions used for time series analysis and in forecasting.
89 stars 20 forks source link

Error with smooth::sma when using ts() with v3.2.0 #202

Closed stubberf closed 1 year ago

stubberf commented 1 year ago

Hello, I am new to submitting potential bugs so please forgive any mistakes. The below code now produces an error with sma().

Version: v3.2.0

y <- c(503.5, 670.4, 589.0, 600.3)

require(stats)
y <- ts(y, freq=12, start=c(2022, 10) )

require(smooth)
sma( y, interval="prediction", h=12 )

Output

Error in `[<-`(`*tmp*`, 1, 1:order, value = rep(mean(yInSample[1:order]),  : 
  subscript out of bounds
Some(<code style = 'font-size:10pt'> Error in `[&lt;-`(`*tmp*`, 1, 1:order, value = rep(mean(yInSample[1:order]), : subscript out of bounds </code>)
Error in `[<-`(`*tmp*`, 1, 1:order, value = rep(mean(yInSample[1:order]), : subscript out of bounds
config-i1 commented 1 year ago

Thanks for reporting this bug! This is now fixed in 0fa2ab20f86e4cde8ab0b70f5f8e8903bbd75292 In the meantime, if you cannot install the package from github, you can use either sma_old() function or sma() with fast=FALSE

stubberf commented 1 year ago

Thank you @config-i1.