BoxCoxTransform - Maple Help
For the best experience, we recommend viewing online help using Google Chrome or Microsoft Edge.

Online Help

All Products    Maple    MapleSim


TimeSeriesAnalysis

  

BoxCoxTransform

  

Box-Cox transformation

  

LogTransform

  

Log transformation

 

Calling Sequence

Parameters

Description

Examples

Compatibility

Calling Sequence

Apply(BoxCoxTransform, timeseries)

Apply(BoxCoxTransform(lambda = lm, base = b, geometricmean = g, shift = s), timeseries)

Apply(LogTransform, timeseries)

Apply(LogTransform(base = b, geometricmean = g, shift = s), timeseries)

Unapply(BoxCoxTransform, forecast)

Unapply(BoxCoxTransform(lambda = lm, base = b, geometricmean = g, shift = s), forecast)

Unapply(LogTransform, forecast)

Unapply(LogTransform(base = b, geometricmean = g, shift = s), forecast)

Parameters

timeseries

-

TimeSeries data set

forecast

-

TimeSeries data set, typically obtained from a forecasting method

lm

-

(optional) parameter of the Box-Cox transform, typically between −2 and 2

b

-

(optional) if lm is 0, the base of the logarithm

g

-

(optional) true or false, indicating whether or not to correct the scale of the results using the geometric mean

s

-

(optional) constant shift applied before the Box-Cox transform is applied

Description

• 

The Box-Cox transformation takes a time series and replaces each value Ti with the value Tiλ1λ. If the parameter λ is set to 0, the resulting value is limλ0Tiλ1λ=lnTi.

• 

Apply this transformation to a time series using the Apply command. Translate transformed information, such as a forecast from transformed data, back to the original domain by using the Unapply command.

• 

By default, the λ parameter has value 0, and the transformation is the log transformation (the natural logarithm, with base ⅇ). By supplying the λ option, you can set this parameter to a different value. The command LogTransform is the same as BoxCoxTransform, except you cannot supply the lambda parameter: it is fixed to always be 0.

• 

If λ=0, then you can choose to use a different base for the logarithm by supplying the base option. For example, to obtain the common logarithm, supply the option base=10. It is an error to supply the base option if λ is set to a value different from 0. The default base is ⅇ.

• 

Negative data points result in undefined values. To prevent this from happening, you can supply the shift=s option. The value s is added to each data point before the transformation is applied. By default, s is 0.

• 

Applying a Box-Cox transformation may have the transformed time series being of a different order of magnitude than the original time series, and Box-Cox transformations with different values for the parameter λ may also have different orders of magnitude. If this is undesirable, for example when comparing an absolute measure of error involving the results of different Box-Cox transformations, you can supply the geometricmean = true option. This computes the geometric mean of each data set after the shift is applied but before the transformation is applied; then after applying the transformation, each data value is multiplied by this geometric mean, raised to the power 1λ. This can be viewed as preserving the units of measurement that the time series data is expressed in.

Examples

withTimeSeriesAnalysis:

salesTimeSeries150,147,114,113,91,164,56,39,32,86,startdate=2010-01-01,frequency=weekly,header=Weekly Sales

salesTime seriesWeekly Sales10 rows of data:2010-01-01 - 2010-03-05

(1)

GetDatasales..4

150.147.114.113.

(2)

Here are the log-transformed data.

log_salesApplyLogTransform,sales

log_salesTime seriesLogarithm of Weekly Sales10 rows of data:2010-01-01 - 2010-03-05

(3)

GetDatalog_sales..4

5.010635294096264.990432586778744.736198448394504.72738781871234

(4)

Reconstructing the original data:

originalUnapplyLogTransform,log_sales

originalTime seriesWeekly Sales10 rows of data:2010-01-01 - 2010-03-05

(5)

GetDataoriginal..4

150.000000000000147.000000000000114.000000000000113.000000000000

(6)

Apply the logarithm with base 10 instead.

common_log_salesApplyLogTransformbase=10,sales

common_log_salesTime seriesLogarithm of Weekly Sales10 rows of data:2010-01-01 - 2010-03-05

(7)

GetDatacommon_log_sales..4

2.176091259055682.167317334748182.056904851336472.05307844348342

(8)

original_2UnapplyLogTransformbase=10,common_log_sales

original_2Time seriesWeekly Sales10 rows of data:2010-01-01 - 2010-03-05

(9)

GetDataoriginal_2..4

150.000000000000147.000000000000114.000000000000113.000000000000

(10)

We now apply the Box-Cox transformation with parameter λ=23 to the sales data. We also apply the geometric mean correction.

boxcoxApplyBoxCoxTransformλ=23,geometricmean=true,sales

boxcoxTime seriesBox-Cox transform of Weekly Sales10 rows of data:2010-01-01 - 2010-03-05

(11)

GetDataboxcox..4

181.145998663384178.633601318965149.746747925208148.830791928663

(12)

original_3UnapplyBoxCoxTransformλ=23,geometricmean=true,boxcox

original_3Time seriesWeekly Sales10 rows of data:2010-01-01 - 2010-03-05

(13)

GetDataoriginal_3..4

150.000000000000147.000000000000114.000000000000113.000000000000

(14)

Temperature data in Celsius is sometimes negative. These were the daily minimum and maximum temperatures in Waterloo, Ontario, Canada, averaged over a month.

average_temperature_matrix12|5,11|2,6|2,1|11,9|18,12|23,16|29,14|26,10|21,4|14,1|10,4|3,7|1,5|2,0|12,0|12,9|22,13|25,15|29,13|26,9|21,5|13,2|6,3|3

average_temperaturesTimeSeriesaverage_temperature_matrix,startdate=2011-01-01,frequency=monthly,headers=average minimum temperature,average maximum temperature

average_temperaturesTime seriesaverage minimum temperature, average maximum temperature24 rows of data:2011-01-01 - 2012-12-01

(15)

GetDataaverage_temperatures..4

−12.−5.−11.−2.−6.2.1.11.

(16)

In order to apply the Box-Cox transform, we need to shift the data by a number greater than minus the minimum value, 12.

transformationBoxCoxTransformshift=20,λ=12,geometricmean

transformation<< Box-Cox transformation with parameter 1/2 >>

(17)

transformed_temperaturesApplytransformation&comma;average_temperatures

transformed_temperaturesTime seriesBox-Cox transform of average minimum temperature, Box-Cox transform of average maximum temperature24 rows of data:2011-01-01 - 2012-12-01

(18)

GetDatatransformed_temperatures..4

17.011378367377732.353547586475518.607663534568436.516372402592125.507919090076841.558904981799533.331681559430551.4389969826016

(19)

original_temperaturesUnapplytransformation&comma;transformed_temperatures

original_temperaturesTime seriesaverage minimum temperature, average maximum temperature24 rows of data:2011-01-01 - 2012-12-01

(20)

GetDataoriginal_temperatures..4

−12.0000000000000−5.00000000000000−11.−2.00000000000001−6.1.999999999999990.99999999999998911.0000000000000

(21)

Compatibility

• 

The TimeSeriesAnalysis[BoxCoxTransform] and TimeSeriesAnalysis[LogTransform] commands were introduced in Maple 18.

• 

For more information on Maple 18 changes, see Updates in Maple 18.

See Also

TimeSeriesAnalysis

TimeSeriesAnalysis[Difference]