Skip to content

Commit

Permalink
ets() robust to non-integer seasonality
Browse files Browse the repository at this point in the history
  • Loading branch information
robjhyndman committed Jul 23, 2024
1 parent 97a0a4a commit bb3891c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
7 changes: 7 additions & 0 deletions R/HoltWintersNew.R
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,13 @@ zzhw <- function(x, lenx, alpha=NULL, beta=NULL, gamma=NULL, seasonal="additive"
phi <- 1
}

if(abs(m - round(m)) > 1e-4) {
# Ignore seasonality
m <- 1
} else {
m <- round(m)
}

# initialise array of l, b, s
level <- trend <- season <- xfit <- residuals <- numeric(lenx)
SSE <- 0
Expand Down
5 changes: 5 additions & 0 deletions R/ets.R
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,11 @@ ets <- function(y, model="ZZZ", damped=NULL,
stop("nmse out of range")
}
m <- frequency(y)
if(abs(m - round(m)) > 1e-4) {
warning("Non-integer seasonal period. Only non-seasonal models will be considered.")
} else {
m <- round(m)
}

if (any(upper < lower)) {
stop("Lower limits must be less than upper limits")
Expand Down

0 comments on commit bb3891c

Please sign in to comment.