Stata 15 help for tssmooth nl

[TS] tssmooth nl -- Nonlinear filter


tssmooth nl [type] newvar = exp [if] [in], smoother(smoother[, twice ]) [replace]

where smoother is specified as Sm[Sm[...]] and Sm is one of

{1|2|3|4|5|6|7|8|9}[R] 3[R]S[S|R][S|R]... E H

The numbers specified in smoother represent the span of a running median smoother. For example, a number 3 specifies that each value be replaced by the median of the point and the two adjacent data values. The letter H indicates that a Hanning linear smoother, which is a span-3 smoother with binomial weights, be applied.

The letters E, S, and R are three refinements that can be combined with the running median and Hanning smoothers. First, the end points of a smooth can be given special treatment. This is specified by the E operator. Second, smoothing by 3, the span-3 running median, tends to produce flat-topped hills and valleys. The splitting operator, S, "splits" these repeated values, applies the end-point operator to them, and then "rejoins" the series. Third, it is sometimes useful to repeat an odd-span median smoother or the splitting operator until the smooth no longer changes. Following a digit or an S with an R specifies this type of repetition.

Finally, the twice operator specifies that after smoothing, the smoother be reapplied to the resulting rough, and any recovered signal be added back to the original smooth.

Letters may be specified in lowercase, if preferred. Examples of smoother[, twice] include

3RSSH 3RSSH,twice 4253H 4253H,twice 43RSR2H,twice 3rssh 3rssh,twice 4253h 4253h,twice 43rsr2h,twice

You must tsset your data before using tssmooth nl; see [TS] tsset. exp may contain time-series operators; see tsvarlist.


Statistics > Time series > Smoothers/univariate forecasters > Nonlinear filter


tssmooth nl uses nonlinear smoothers to identify the underlying trend in a series.


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

smooth(smoother[, twice]) is required; it specifies the nonlinear smoother to be used.

replace replaces newvar if it already exists.


Setup . webuse sales2

Perform nonlinear smoothing to sales using a median smoother of span 5 . tssmooth nl nl1=sales, smoother(5)

Perform nonlinear smoothing to sales by applying span-3 median smoother twice, then applying the split operator to repeated values twice, and finally applying a Hanning smoother . tssmooth nl nl2=sales, smoother(3RSSH)

Same as above, except after smoothing, reapply the smoother to the resulting rough, and add any recovered signal back to the original smooth . tssmooth nl nl3=sales, smoother(3RSSH, twice)

Stored results

tssmooth nl stores the following in r():

Scalars r(N) number of observations

Macros r(method) nl r(smoother) specified smoother r(timevar) time variable specified in tsset r(panelvar) panel variable specified in tsset

© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index