# HoltWinters with a non-FALSE Gamma

Hi, am using HoltWinters function for a hypothetical univariate dataset with clear seasonality:
A <- c(1,2,3,4,5,4,3,2,3,4,5,6,5,4,3,4,5,6,7,6,5,4,5,6,7,8,7,6,5,6,7,8,9,8,7,6,7,8,9,10)

AForecast <- HoltWinters(A, beta=NULL, gamma=FALSE, l.start=1)
works perfectly well.

But when I introduce a gamma parameter that is not false as per below, I get an error.

AForecast <- HoltWinters(A, beta=NULL, gamma=NULL, l.start=1)
Error in decompose(ts(x[1L:wind], start = start(x), frequency = f), seasonal) :
time series has no or less than 2 periods

Same when gamma is a numeric value between zero and 1. Any Idea what this could be? I thank you in advance.

``````A <- ts(c(1,2,3,4,5,4,3,2,3,4,5,6,5,4,3,4,5,6,7,6,5,4,5,6,7,8,7,6,5,6,7,8,9,8,7,6,7,8,9,10), start = c(2020,1), frequency = 1)

AForecast <- HoltWinters(A, beta=NULL, gamma=TRUE, l.start=1)
#> Error in decompose(ts(x[1L:wind], start = start(x), frequency = f), seasonal): time series has no or less than 2 periods

fabletools::common_periods(tsibble::as_tsibble(A))
#> year
#>    1

A <- ts(c(1,2,3,4,5,4,3,2,3,4,5,6,5,4,3,4,5,6,7,6,5,4,5,6,7,8,7,6,5,6,7,8,9,8,7,6,7,8,9,10), start = c(2020,1), frequency = 10)

AForecast <- HoltWinters(A, beta=NULL, gamma=TRUE, l.start=1)
AForecast
#> Holt-Winters exponential smoothing with trend and additive seasonal component.
#>
#> Call:
#> HoltWinters(x = A, beta = NULL, gamma = TRUE, l.start = 1)
#>
#> Smoothing parameters:
#>  alpha: 0.815026
#>  beta : 0
#>  gamma: TRUE
#>
#> Coefficients:
#>           [,1]
#> a   10.1888216
#> b    0.1418182
#> s1   1.0948149
#> s2   1.8839601
#> s3   1.5453455
#> s4   0.1010440
#> s5  -1.2276309
#> s6  -0.1239793
#> s7  -0.0738190
#> s8  -0.9525811
#> s9  -0.9384756
#> s10 -0.1888216
``````

Thanks a lot. It works. What does the start = c(2020,1), frequency = 10 do. Does the 2020 refer to a year? What influences the choice of the frequency number?

Thanks once again and regards.

`start = (year,month)` provides the `ts` object with a reference point. Frequency = 10 was a typo (corrected below). Frequency is the number of observations per unit time.

Data frequency
Annual 1
Quarterly 4
Monthly 12
Weekly 52
``````A <- ts(c(1,2,3,4,5,4,3,2,3,4,5,6,5,4,3,4,5,6,7,6,5,4,5,6,7,8,7,6,5,6,7,8,9,8,7,6,7,8,9,10), start = c(2020,1), frequency = 12)

AForecast <- HoltWinters(A, beta=NULL, gamma=TRUE, l.start=1)
AForecast
#> Holt-Winters exponential smoothing with trend and additive seasonal component.
#>
#> Call:
#> HoltWinters(x = A, beta = NULL, gamma = TRUE, l.start = 1)
#>
#> Smoothing parameters:
#>  alpha: 0.2221813
#>  beta : 0
#>  gamma: TRUE
#>
#> Coefficients:
#>           [,1]
#> a    7.6897598
#> b    0.1337413
#> s1  -0.5438079
#> s2   0.6433722
#> s3   1.6069842
#> s4   1.9804298
#> s5   2.0236392
#> s6   0.3586492
#> s7  -0.6526115
#> s8  -1.1731935
#> s9   0.2373040
#> s10  1.4528609
#> s11  2.0660924
#> s12  2.3102402
``````

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.