Box-Cox transformations for time series
Here, you will use a Box-Cox transformation to stabilize the variance of the pre-loaded a10
series, which contains monthly anti-diabetic drug sales in Australia from 1991-2008.
In this exercise, you will need to experiment to see the effect of the lambda
(\(\lambda\)) argument on the transformation. Notice that small changes in \(\lambda\) make little difference to the resulting series. You want to find a value of \(\lambda\) that makes the seasonal fluctuations of roughly the same size across the series.
Recall from the video that the recommended range for lambda
values is \(-1 ≤ \lambda ≤ 1\).
This is a part of the course
“Forecasting in R”
Exercise instructions
- Plot the
a10
series and observe the increasing variance as the level of the series increases. - Try transforming the series using
BoxCox()
in the format of the sample code. Experiment with four values oflambda
:0.0
,0.1
,0.2
, and0.3
. Can you determine which lambda value approximately stabilizes the variance? - Now compare your chosen value of
lambda
with the one returned byBoxCox.lambda()
.
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
# Plot the series
___
# Try four values of lambda in Box-Cox transformations
a10 %>% BoxCox(lambda = ___) %>% autoplot()
___
___
___
# Compare with BoxCox.lambda()
___