Skip to content

Commit 4ffe4eb

Browse files
committed
bug fix holtWinters
1 parent f660ecf commit 4ffe4eb

4 files changed

Lines changed: 5 additions & 5 deletions

File tree

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "TrendDecomposition"
22
uuid = "d73ad930-938d-4709-8eff-50e740f82fcd"
33
authors = ["Stefan Brinkmann <sdbrinkmann@outlook.com>"]
4-
version = "0.5.0"
4+
version = "0.5.1"
55

66

77
[deps]

docs/src/assets/airforecast24.png

1.12 KB
Loading

docs/src/man/start.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,8 @@ plot([data D1 residual], layout = (5, 1), ylabel = ["y" "level" "slope" "season"
124124
The damping factor ``\varphi`` can be typed in julia with the keyboard as follows: \varphi`<tab>`
125125
``` Julia
126126

127-
# Forecast horizon h = 24 and damping factor \varphi = 0.95
128-
f2, D2, p2 = holtWinters(data, seasons, h=24, model=:mul, φ = 0.95)
127+
# Forecast horizon h = 24 and damping factor \varphi = 1
128+
f2, D2, p2 = holtWinters(data, seasons, h=24, model=:mul, φ = 1)
129129

130130
n = length(data)
131131
steps = (n+1):(n+24)

src/expSmoothing.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -269,10 +269,10 @@ function holtWinters(y :: Vector, λ₁ :: Real, λ₂ :: Real, λ₃ :: Real, s
269269
if model == :add
270270
S[1:s] = maSeason(y[1:(2*s)] .- rollingAverage(y[1:(2*s)], p), s)
271271
for t in start:T
272+
F[t] = lvl[t-1] + b[t-1] * φ + S[(t-s < 1 ? t : t-s)]
272273
lvl[t] = λ₁*(y[t] - S[(t-s < 1 ? t : t-s)]) + (1. - λ₁)*(lvl[t-1] + b[t-1] * φ)
273274
b[t] = λ₂ * (lvl[t] - lvl[t-1]) + (1. - λ₂) * b[t-1] * φ
274275
S[t] = λ₃ * (y[t] - lvl[t]) + (1. - λ₃) * S[(t-s < 1 ? t : t-s)]
275-
F[t] = lvl[t-1] + b[t-1] * φ + S[(t-s-1 < 1 ? t-1 : t-s-1)]
276276
end
277277

278278
if φ == 1.0
@@ -291,10 +291,10 @@ function holtWinters(y :: Vector, λ₁ :: Real, λ₂ :: Real, λ₃ :: Real, s
291291
elseif model == :mul
292292
S[1:s] = maSeason(y[1:(2*s)] ./ rollingAverage(y[1:(2*s)], p), s)
293293
for t in start:T
294+
F[t] = (lvl[t-1] + b[t-1] * φ) * S[(t-s < 1 ? t : t-s)]
294295
lvl[t] = λ₁*(y[t] / S[(t-s < 1 ? t : t-s)]) + (1. - λ₁)*(lvl[t-1] + b[t-1] * φ)
295296
b[t] = λ₂ * (lvl[t] - lvl[t-1]) + (1. - λ₂) * b[t-1] * φ
296297
S[t] = λ₃ * (y[t] / lvl[t]) + (1. - λ₃) * S[(t-s < 1 ? t : t-s)]
297-
F[t] = (lvl[t-1] + b[t-1] * φ) * S[(t-s-1 < 1 ? t-1 : t-s-1)]
298298
end
299299

300300
if φ == 1.0

0 commit comments

Comments
 (0)