Apply - Maple Help

TimeSeriesAnalysis

 Apply
 apply a transformation
 Unapply
 unapply a transformation

 Calling Sequence Apply(trafo, timeseries) Unapply(trafo, forecast)

Parameters

 trafo - TimeSeries transformation object, such as BoxCoxTransform or Difference timeseries - forecast - TimeSeries data set, typically obtained from a forecasting method

Description

 • The Apply and Unapply commands are used with transformation objects, and are explained on the help pages of these transformation objects.
 • Transformation objects are created by the Difference and BoxCoxTransform commands. The LogTransform command is a special case of the BoxCoxTransform command.

Examples

 > $\mathrm{with}\left(\mathrm{TimeSeriesAnalysis}\right):$
 > $\mathrm{sales}≔\mathrm{TimeSeries}\left(\left[150,147,114,113,91,164,56,39,32,86\right],\mathrm{startdate}="2010-01-01",\mathrm{frequency}="weekly",\mathrm{header}="Weekly Sales"\right)$
 ${\mathrm{sales}}{≔}\left[\begin{array}{c}{\mathrm{Time series}}\\ {\mathrm{Weekly Sales}}\\ {\mathrm{10 rows of data:}}\\ {\mathrm{2010-01-01 - 2010-03-05}}\end{array}\right]$ (1)
 > $\mathrm{GetData}\left(\mathrm{sales}\right)\left[..4\right]$
 $\left[\begin{array}{c}{150.}\\ {147.}\\ {114.}\\ {113.}\end{array}\right]$ (2)

Here are the log-transformed data.

 > $\mathrm{log_sales}≔\mathrm{Apply}\left(\mathrm{LogTransform},\mathrm{sales}\right)$
 ${\mathrm{log_sales}}{≔}\left[\begin{array}{c}{\mathrm{Time series}}\\ {\mathrm{Logarithm of Weekly Sales}}\\ {\mathrm{10 rows of data:}}\\ {\mathrm{2010-01-01 - 2010-03-05}}\end{array}\right]$ (3)
 > $\mathrm{GetData}\left(\mathrm{log_sales}\right)\left[..4\right]$
 $\left[\begin{array}{c}{5.01063529409626}\\ {4.99043258677874}\\ {4.73619844839450}\\ {4.72738781871234}\end{array}\right]$ (4)

Reconstructing the original data:

 > $\mathrm{original}≔\mathrm{Unapply}\left(\mathrm{LogTransform},\mathrm{log_sales}\right)$
 ${\mathrm{original}}{≔}\left[\begin{array}{c}{\mathrm{Time series}}\\ {\mathrm{Weekly Sales}}\\ {\mathrm{10 rows of data:}}\\ {\mathrm{2010-01-01 - 2010-03-05}}\end{array}\right]$ (5)
 > $\mathrm{GetData}\left(\mathrm{original}\right)\left[..4\right]$
 $\left[\begin{array}{c}{150.000000000000}\\ {147.000000000000}\\ {114.000000000000}\\ {113.000000000000}\end{array}\right]$ (6)

Here are the differences in sales from week to week.

 > $\mathrm{differenced}≔\mathrm{Apply}\left(\mathrm{Difference},\mathrm{sales}\right)$
 ${\mathrm{differenced}}{≔}\left[\begin{array}{c}{\mathrm{Time series}}\\ {\mathrm{Weekly Sales \left(differenced\right)}}\\ {\mathrm{9 rows of data:}}\\ {\mathrm{2010-01-08 - 2010-03-05}}\end{array}\right]$ (7)
 > $\mathrm{GetData}\left(\mathrm{differenced}\right)\left[..4\right]$
 $\left[\begin{array}{c}{-3.}\\ {-33.}\\ {-1.}\\ {-22.}\end{array}\right]$ (8)

Reconstructing the original data (except for the first row):

 > $\mathrm{original}≔\mathrm{Unapply}\left(\mathrm{Difference},\mathrm{differenced}\right)$
 ${\mathrm{original}}{≔}\left[\begin{array}{c}{\mathrm{Time series}}\\ {\mathrm{Weekly Sales}}\\ {\mathrm{9 rows of data:}}\\ {\mathrm{2010-01-08 - 2010-03-05}}\end{array}\right]$ (9)
 > $\mathrm{GetData}\left(\mathrm{original}\right)\left[..4\right]$
 $\left[\begin{array}{c}{147.}\\ {114.}\\ {113.}\\ {91.}\end{array}\right]$ (10)

Compatibility

 • The TimeSeriesAnalysis[Apply] and TimeSeriesAnalysis[Unapply] commands were introduced in Maple 18.
 • For more information on Maple 18 changes, see Updates in Maple 18.