**[TS] tssmooth hwinters** -- Holt-Winters nonseasonal smoothing

__Syntax__

**tssmooth** __h__**winters** [*type*] *newvar* **=** *exp* [*if*] [*in*] [**,** *options*]

*options* Description
-------------------------------------------------------------------------
Main
**replace** replace *newvar* if it already exists
__p__**arms(***#a #b***)** use *#a* and *#b* as smoothing parameters
__sa__**mp0(***#***)** use *#* observations to obtain initial values for
recursion
**s0(***#*cons *#*lt**)** use *#*cons and *#*lt as initial values for recursion
__f__**orecast(***#***)** use *#* periods for the out-of-sample forecast

Options
__d__**iff** alternative initial-value specification; see
*Options*

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

__Menu__

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

__Description__

**tssmooth hwinters** is used in smoothing or forecasting a series that can
be modeled as a linear trend in which the intercept and the coefficient
on time vary over time.

__Options__

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

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

**parms(***#a #b***)**, **0** __<__ *#a* __<__ **1** and **0** __<__ *#b* __<__ **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**)** specify how the initial values *#*cons and *#*lt
for the recursion are obtained.

By default, initial values are obtained by fitting a linear
regression with a time trend using the first half of the observations
in the dataset.

**samp0(***#***)** specifies that the first *#* observations be used in that
regression.

**s0(***#*cons *#*lt**)** specifies that *#*cons and *#*lt be used as 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.

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

**diff** specifies that the linear term is obtained by averaging the first
difference of *exp_t* and the intercept is obtained as the difference
of *exp* in the first observation and the mean of **D**.*exp_t*.

If the **diff** option is not specified, a linear regression of *exp_t* on
a constant and *t* is fit.

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

*maximize_options* controls the process for solving for the optimal alpha
and beta when **parms()** 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***)**, **0** < *#a* < **1** and **0** < *#b* < **1**, specifies starting values from
which the optimal values of alpha and beta will be obtained. If
**from()** is not specified, **from(.5 .5)** is used.

__Examples__

Setup
**. webuse bsales**

Perform Holt-Winters nonseasonal smoothing on **sales**
**. tssmooth hwinters hw1=sales**

Same as above, but use .7 and .3 as smoothing parameters
**. tssmooth hwinters hw2=sales, parms(.7 .3)**

Same as above, but perform out-of-sample forecast using 3 periods
**. tssmooth hwinters hw3=sales, parms(.7 .3) forecast(3)**

__Stored results__

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

Scalars
**r(N)** number of observations
**r(alpha)** alpha smoothing parameter
**r(beta)** beta smoothing parameter
**r(rss)** sum-of-squared errors
**r(prss)** penalized sum-of-squared errors, if **parms()** not
specified
**r(rmse)** root mean squared error
**r(N_pre)** number of observations 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

Macros
**r(method)** smoothing method
**r(exp)** expression specified
**r(timevar)** time variables specified in **tsset**
**r(panelvar)** panel variables specified in **tsset**