**[TS] tssmooth shwinters** -- Holt-Winters seasonal smoothing

__Syntax__

**tssmooth** __s__**hwinters** [*type*] *newvar* **=** *exp* [*if*] [*in*] [**,** *options*]

*options* Description
-------------------------------------------------------------------------
Main
**replace** replace *newvar* if it already exists
__p__**arms(***#a #b #g***)** use *#a*, *#b*, and *#g* as smoothing parameters
__sa__**mp0(***#***)** use *#* observations to obtain initial values for
recursions
**s0(***#*cons *#*1t**)** use *#*cons and *#*lt as initial values for recursions
__f__**orecast(***#***)** use *#* periods for the out-of-sample forecast
__per__**iod(***#***)** use *#* period of the seasonality
__add__**itive** use additive seasonal Holt-Winters method

Options
**sn0_0(***varname***)** use initial seasonal values in *varname*
**sn0_v(***newvar***)** store estimated initial values for seasonal terms
in *newvar*
**snt_v(***newvar***)** store final year's estimated seasonal terms in
*newvar*
__n__**ormalize** normalize seasonal values
__alt__**starts** use alternative method for computing the starting
values

Maximization
*maximize_options* control the maximization process; seldom used
__fr__**om(***#a #b #g***)** use *#a*, *#b*, and *#g* as starting values for the
parameters
-------------------------------------------------------------------------
You must **tsset** your data before using **tssmooth shwinters**; see **[TS] tsset**.
*exp* may contain time-series operators; see tsvarlist.

__Menu__

**Statistics > Time series > Smoothers/univariate forecasters >**
**Holt-Winters seasonal smoothing**

__Description__

**tssmooth shwinters** performs the seasonal Holt-Winters method on a
user-specified expression, which is usually just a variable name, and
generates a new variable containing the forecasted series.

__Options__

+------+
----+ Main +-------------------------------------------------------------

**replace** replaces *newvar* if it already exists.

**parms(***#a #b #g***)**, **0** __<__ *#a* __<__ **1**, **0** __<__ *#b* __<__ **1**, and **0** __<__ *#g* __<__ **1**, specifies the
parameters. If **parms()** is not specified, the values are chosen by an
iterative process to minimize the in-sample sum-of-squared prediction
errors.

If you experience difficulty converging (many iterations and "not
concave" messages), try using **from()** to provide better starting
values.

**samp0(***#***)** and **s0(***#*cons *#*lt**)** have to do with how the initial values *#*cons
and *#*lt for the recursion are obtained.

**s0(***#*cons *#*lt**)** specifies the initial values to be used.

**samp0(***#***)** specifies that the initial values be obtained using the
first *#* observations of the sample. This calculation is described
under *Methods and formulas* in **[TS] tssmooth shwinters** and depends on
whether the **altstart** and **additive** options are also specified.

If neither option is specified, the first half of the sample is used
to obtain initial values.

**forecast(***#***)** specifies the number of periods for the out-of-sample
prediction; **0** __<__ *#* __<__ **500**. The default is **forecast(0)**, which is
equivalent to not performing an out-of-sample forecast.

**period(***#***)** specifies the period of the seasonality. If **period()** is not
specified, the seasonality is obtained from the **tsset** options **daily**,
**weekly**, ..., **yearly**. If you did not specify one of those options
when you **tsset** the data, you must specify the **period()** option. For
instance, if your data are quarterly and you did not specify **tsset**'s
**quarterly** option, you must now specify **period(4)**.

By default, seasonal values are calculated, but you may specify the
initial seasonal values to be used via the **sn0_0(***varname***)** option.
The first **period()** observations of *varname* are to contain the initial
seasonal values.

**additive** uses the additive seasonal Holt-Winters method instead of the
default multiplicative seasonal Holt-Winters method.

+---------+
----+ Options +----------------------------------------------------------

**sn0_0(***varname***)** specifies the initial seasonal values to use. *varname*
must contain a complete year's worth of seasonal values, beginning
with the first observation in the estimation sample. For example, if
you have monthly data, the first 12 observations of *varname* must
contain nonmissing data. **sn0_0()** cannot be used with **sn0_v()**.

**sn0_v(***newvar***)** stores in *newvar* the initial seasonal values after they
have been estimated. **sn0_v()** cannot be used with **sn0_0()**.

**snt_v(***newvar***)** stores in *newvar* the seasonal values for the final year's
worth of data.

**normalize** specifies that the seasonal values be normalized. In the
multiplicative model, they are normalized to sum to one. In the
additive model, the seasonal values are normalized to sum to zero.

**altstarts** uses an alternative method to compute the starting values for
the constant, the linear, and the seasonal terms. The default and
the alternative methods are described in *Methods and formulas* in **[TS]**
**tssmooth shwinters**. **altstarts** may not be specified with **s0()**.

+--------------+
----+ Maximization +-----------------------------------------------------

*maximize_options* controls the process for solving for the optimal alpha,
beta, and gamma when the **parms()** option is not specified.

*maximize_options*: __nodif__**ficult**, __tech__**nique(***algorithm_spec***)**, __iter__**ate(***#***)**,
[__no__]__lo__**g**, __tr__**ace**, __grad__**ient**, **showstep**, __hess__**ian**, __showtol__**erance**,
__tol__**erance(***#***)**, __ltol__**erance(***#***)**, __nrtol__**erance(***#***)**, and __nonrtol__**erance**; see
**[R] maximize**. These options are seldom used.

**from(***#a #b #g***)**, **0** < *#a* < **1**, **0** < *#b* < **1**, and **0** < *#g* < **1**, specifies
starting values from which the optimal values of alpha, beta, and
gamma will be obtained. If **from()** is not specified, **from(.5 .5 .5)**
is used.

__Examples__

Setup
**. webuse turksales**

Perform Holt-Winters seasonal smoothing on **sales**
**. tssmooth shwinters shw1=sales**

Same as above, but perform out-of-sample forecast using 4 periods
**. tssmooth shwinters shw2=sales, forecast(4)**

Same as above, but use additive seasonal Holt-Winters method
**. tssmooth shwinters shw3=sales, forecast(4) additive**

Same as above, but normalize seasonal values
**. tssmooth shwinters shw4=sales, forecast(4) additive normalize**

Same as above, but store final year's estimated seasonal terms in **seas**
**. tssmooth shwinters shw5=sales, forecast(4) additive normalize**
**snt_v(seas)**

__Stored results__

**tssmooth shwinters** stores the following in **r()**:

Scalars
**r(N)** number of observations
**r(alpha)** alpha smoothing parameter
**r(beta)** beta smoothing parameter
**r(gamma)** gamma smoothing parameter
**r(prss)** penalized sum-of-squared errors
**r(rss)** sum-of-squared errors
**r(rmse)** root mean squared error
**r(N_pre)** number of seasons used in calculating starting values
**r(s2_0)** initial value for linear term
**r(s1_0)** initial value for constant term
**r(linear)** final value of linear term
**r(constant)** final value of constant term
**r(period)** **period**, if filter is seasonal

Macros
**r(method)** **shwinters, additive** or **shwinters, multiplicative**
**r(normalize)** **normalize**, if specified
**r(exp)** expression specified
**r(timevar)** time variable specified in **tsset**
**r(panelvar)** panel variable specified in **tsset**