Skip to content

Commit bb3891c

Browse files
committed
ets() robust to non-integer seasonality
1 parent 97a0a4a commit bb3891c

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

R/HoltWintersNew.R

+7
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,13 @@ zzhw <- function(x, lenx, alpha=NULL, beta=NULL, gamma=NULL, seasonal="additive"
272272
phi <- 1
273273
}
274274

275+
if(abs(m - round(m)) > 1e-4) {
276+
# Ignore seasonality
277+
m <- 1
278+
} else {
279+
m <- round(m)
280+
}
281+
275282
# initialise array of l, b, s
276283
level <- trend <- season <- xfit <- residuals <- numeric(lenx)
277284
SSE <- 0

R/ets.R

+5
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,11 @@ ets <- function(y, model="ZZZ", damped=NULL,
142142
stop("nmse out of range")
143143
}
144144
m <- frequency(y)
145+
if(abs(m - round(m)) > 1e-4) {
146+
warning("Non-integer seasonal period. Only non-seasonal models will be considered.")
147+
} else {
148+
m <- round(m)
149+
}
145150

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

0 commit comments

Comments
 (0)