# SuanShu, a Java numerical and statistical library

com.numericalmethod.suanshu.stats.timeseries.linear.univariate.stationaryprocess

• java.lang.Object

• public class MADecomposition
extends Object
This class decomposes a time series into the trend, seasonal and stationary random components using the Moving Average Estimation method with symmetric window. That is,
Xt = mt + st + Yt
We have
• EYt = 0
• st+d = st
• Σ(sj) = 0
The R equivalent function is decompose.
"P. J. Brockwell and R. A. Davis, "p. 23, Chapter 1.4, Elimination of both Trend and Seasonality," Time Series: Theory and Methods, 2nd ed, Springer, 2006."
• ### Constructor Summary

Constructors
Constructor and Description
MADecomposition(double[] xt, double[] MAFilter, int period)
Decompose a time series into the trend, seasonal and stationary random components using the Moving Average Estimation method.
MADecomposition(double[] xt, int period)
Decompose a periodic time series into the seasonal and stationary random components using no MA filter.
MADecomposition(double[] xt, int MAOrder, int period)
Decompose a time series into the trend, seasonal and stationary random components using the default filter.
• ### Method Summary

All Methods
Modifier and Type Method and Description
double[] getRandom()
Get the estimated seasonal effect of the time series.
double[] getSeasonal()
Get the stationary random component of the time series after the trend and seasonal components are removed.
double[] getTrend()
Get the estimated trend of the time series.
• ### Methods inherited from class java.lang.Object

clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
• ### Constructor Detail

public MADecomposition(double[] xt,
double[] MAFilter,
int period)
Decompose a time series into the trend, seasonal and stationary random components using the Moving Average Estimation method.
Parameters:
xt - a time series
MAFilter - the moving average filter to smooth the time series
period - the period of the time series; if aperiodic, use 1

public MADecomposition(double[] xt,
int MAOrder,
int period)
Decompose a time series into the trend, seasonal and stationary random components using the default filter.
Parameters:
xt - a time series
MAOrder - the length of the MA filter (automatically increased by 1 for even MAOrder)
period - the period of the time series; if aperiodic, use 0
"P. J. Brockwell and R. A. Davis, "Eq. 1.4.16, Chapter 1.4, Elimination of both Trend and Seasonality," Time Series: Theory and Methods, 2nd ed, Springer, 2006."

public MADecomposition(double[] xt,
int period)
Decompose a periodic time series into the seasonal and stationary random components using no MA filter.
Parameters:
xt - a time series
period - the period of the time series; if aperiodic, use 0
• ### Method Detail

• #### getTrend

public double[] getTrend()
Get the estimated trend of the time series.
Returns:
the estimated trend
• #### getSeasonal

public double[] getSeasonal()
Get the stationary random component of the time series after the trend and seasonal components are removed.
Returns:
the stationary random component
• #### getRandom

public double[] getRandom()
Get the estimated seasonal effect of the time series.
Returns:
the estimated seasonal effect