---
abstract: |
    The Box-Cox transformation can sometimes yield noticeable improvements in model simplicity, variance homogeneity and precision of estimation, such as in modeling and forecasting age-specific fertility. Despite its importance, there have been only few studies focusing on the optimal selection of Box-Cox transformation parameter in demographic forecasting. A simple method is proposed for selecting the optimal Box-Cox transformation parameter, along with an algorithm based on an in-sample forecast error measure. Illustrated by Australian age-specific fertility, the out-of-sample accuracy of a forecasting method can be improved with the selected Box-Cox transformation parameter. Furthermore, the log transformation is not adequate for modeling and forecasting age-specific fertility. It is recommended to embed the selection of Box-Cox transformation parameter into statistical analysis of age-specific demographic data, in order to fully capture forecast uncertainties.

    Keywords: age-specific fertility rates; data transformation; principal component analysis; mean absolute forecast error; interval score
bibliography:
- 'BoxCox.bib'
---

On the selection of optimal Box-Cox transformation parameter for modeling and forecasting age-specific fertility

Han Lin Shang[^1]\
Australian National University

Introduction
============

In the demographic literature, forecasting methods for age-specific fertility can be generally grouped into parametric, semi-parametric and nonparametric models. Parametric models used in forecasting include the beta, gamma, double exponential and Hadwiger functions [@KMR93; @TBL+89; @Congdon90; @Congdon93; @KP00], while semi-parametric models include the Coale-Trussell and Relational Gompertz models [@CT74; @Brass81; @Murphy82; @Booth84; @ZWM+00]. The use of these models is variously limited by parameter uninterpretability, over-parameterization and the need for vector autoregression; structural change also limits their utility, especially where vector autoregression is involved [@Booth06]. To address this problem, nonparametric methods use a dimension-reduction technique, such as principal components analysis, to linearly transform age-specific fertility rates to extract a series of time-varying indexes to be forecast [see @BB87; @Bell92; @Lee93; @HU07].

The Box-Cox transformation can sometimes yield noticeable improvements in model simplicity, variance homogeneity and precision of estimation. Despite the rapid development in demographic forecasting models, there have been only few studies focusing on the optimal selection of the Box-Cox transformation parameter, with an noticeable exception of @HB08. As noted in early work by @BC64 and @Box88, the careful selection of a data transformation is often treated as a prerequisite before any serious modeling takes place.

An example of data transformation is the log transformation for modeling and forecasting age-specific mortality. Such a transformation allows researchers to visualize and model patterns associated with the so-called "accident bump" and to exploit near-linearities in the log mortality rates for the ages 40 to 80 years. The log transformation is a special case of the Box-Cox transformation, which can be defined as $$z_{t,i} = \left\{ \begin{array}{ll}
         \frac{1}{\lambda}\left[(f_{t,i})^{\lambda}-1\right] & \mbox{if $\lambda \neq 0$}\\
        \ln (f_{t,i}) & \mbox{if $\lambda = 0$}\end{array} \right.$$ where $f_{t,i}>0$ denotes the observed age-specific data at age $i$ in year $t$, whereas $z_{t,i}$ denotes the transformed data, and $\lambda$ is the transformation parameter. For instance, when $\lambda=1$, the transformation is essentially the identity, and the logarithm when $\lambda=0$. In this work, we restrict it to lie in the unit interval [see also @HB08].

We propose a simple and instructive way of selecting the optimal Box-Cox transformation parameter based on an in-sample forecast error measure, and to demonstrate this idea in the context of modeling and forecasting age-specific fertility. The effect of the Box-Cox transformation on fertility is mainly manifested by a different shape of age profile. With the optimal transformation parameter, the age profile of the transformed data may reveal age patterns that are not obvious in the raw data.

This paper is organized as follows. In Section \[sec:2\], we present the Australian age-specific fertility from 1921 to 2006. In Section \[sec:3\], we present the methodology and optimization algorithm. Results are collated in Section \[sec:4\]. Section \[sec:5\] concludes, along with some thoughts on how the method developed here might be further extended.

Data and design {#sec:2}
===============

Data set
--------

We consider annual Australian age-specific fertility rates from 1921 to 2006. The data set has been obtained from the Australian Bureau of Statistics (Cat. No. 393.241.143.245, Table 38), and is also available in the *rainbow* package [@SH13] in

[@Team13]. The data consist of annual fertility rates by single-year age of mother aged from 15 to 49 years. A graphical data display is given in Figure \[fig:1\]. From the rainbow plot in Figure \[fig:1a\], we see the phenomenon of fertility postponement in the most recent years. From the contour plot in Figure \[fig:1b\], we see the increases in fertility between ages 20 and 30 from 1940 to 1980, this reflects the baby boom period.

As a demonstration, Figure \[fig:BC\_example\] presents the Box-Cox transformed fertility rates for years 1921 and 2006. With different values of $\lambda$, the age profiles change accordingly. The goal is to select the optimal $\lambda$ that improves model estimation and prediction accuracy for a chosen model.

![Box-Cox transformed fertility rates with different values of $\lambda$ in years 1921 and 2006, as two examples.<span data-label="fig:BC_example"></span>](BC_transformation "fig:"){width="7.52cm"} ![Box-Cox transformed fertility rates with different values of $\lambda$ in years 1921 and 2006, as two examples.<span data-label="fig:BC_example"></span>](BC_transformation_2006 "fig:"){width="7.52cm"}

Study design
------------

Since the optimal Box-Cox transformation parameter is selected based on an in-sample forecast error measure, we divide the data into a training sample, a validation sample and a testing sample. Customarily, the testing sample consists of the last 20% of the data, which are used to examine the out-of-sample forecast accuracy with the selected Box-Cox transformation parameter. The validation sample, which has the same number of data as the testing sample, is used to select the optimal Box-Cox transformation parameter. As in the case of Australian fertility rates, the training sample is from 1921 to 1972, the validation sample is from 1973 to 1989, and the testing sample is from 1990 to 2006.

There are various ways to measure the forecast accuracy. Following the early work by [-@SBH11], we use mean absolute forecast error (MAFE) for measuring point forecast accuracy. This is given by $$\begin{aligned}
  \text{MAFE}_h &= \frac{1}{(18-h)\times 35} \sum^{18-h}_{s=1}\sum^{49}_{i=15}\left|f_{i,s}-\widehat{f}_{i,s}\right|, \qquad h=1,\dots,17. \label{eq:mafe}\end{aligned}$$ The MAFE is the average of absolute error across ages and years in the forecasting period; it measures forecast precision regardless of sign and is not sensitive to large relative errors of small rates. Since the back-transformed forecasts are median forecasts on the original scale, this makes them suitable for evaluation using MAFE.

In order to evaluate the interval forecast accuracy, we utilize the interval score of @GR07 and @GK14. For each year in the forecasting period, the one-step-ahead to 17-step-ahead prediction intervals were calculated at the $(1-\alpha)\times 100\%$ nominal coverage probability. We consider the common case of the symmetric $(1-\alpha)\times 100\%$ prediction interval, with lower and upper bounds that are predictive quantiles at $\alpha/2$ and $1-\alpha/2$, denoted by $l$ and $u$. As defined by @GR07, a scoring rule is given by the associated interval forecast $S_{\alpha}(l,u;i)$. This can be expressed as $$S_{\alpha}(l,u;i) = (u-l)+\frac{2}{\alpha}\left[(l-i)I\{i<l\}+(i-u)I\{i>u\}\right],\label{eq:int_score}$$ where $I\{\cdot\}$ represents the binary indicator function which takes the value of 1 when the condition is met, and $\alpha$ denotes the level of significance. In this paper, $\alpha=0.2$ since we construct 80% prediction interval. The optimal score is achieved when $i$ lies between $l$ and $u$, and the distance between $l$ and $u$ is minimal. The interval score can be interpreted as: a forecaster is rewarded for narrow width of a prediction interval, if and only if the true observation lies within the prediction interval. The smaller the interval score is, the better the method is for producing interval forecasts.

For different ages and years in the forecasting period, the averaged interval score is defined by $$S_{\alpha}^{\text{ave}}(l,u;i) = \frac{1}{(18-h)\times 35}\sum_{s=1}^{18-h}\sum^{49}_{i=15}S_{\alpha,s}(l,u;i), \qquad h=1,\dots, 17.$$

Methodology {#sec:3}
===========

Many methods have been proposed for modeling age-specific fertility [see @Booth06 for reviews]. To demonstrate our main idea, we model the observed period age-specific fertility, using the well-known Lee-Carter model [@LC92]. Instead of retaining only the first component, we retain more than one principal component [see also @CBD06]. The modified Lee-Carter model can be defined by $$z_{t,i}=\mu_i + \sum^K_{k=1}\beta_{t,k}\phi_{k,i}+\varepsilon_{t,i},\qquad 1\leq t \leq n, \quad 1\leq i \leq p,$$ where $n$ denotes the last year in the training sample and $p$ denotes the last age, $\mu_i$ represents the mean estimated by $\frac{1}{n}\sum^n_{t=1}z_{t,i}$, $\{\beta_{1,k},\dots,\beta_{n,k}\}$ represents the $k$th estimated principal component scores, $\{\phi_{k,1},\dots,\phi_{k,p}\}$ represents the $k$th estimated principal component which can be obtained from singular value decomposition applied to the training sample, $\varepsilon_{t,i}$ represents the independent and identically distributed Gaussian white noise, and $K$ represents the number of retained principal components and the value of $K$ can be determined by a ratio-based estimator [see @LYB11 for details].

Point and interval forecasts {#sec:3.1}
----------------------------

Conditional on the estimated mean $\widehat{\mu}_i$ and the estimated principal components $\big(\widehat{\phi}_{1,i},\dots,\widehat{\phi}_{K,i}\big)$, the point forecasts are given by $$\begin{aligned}
  \widehat{z}_{n+h|n,i} &= \widehat{\mu}_i+\sum^K_{k=1}\widehat{\beta}_{n+h|n,k}\widehat{\phi}_{k,i},\end{aligned}$$ where $\widehat{\beta}_{n+h|n,k}$ represents the $h$-step-ahead point forecast of the $k$th principal component scores. These forecasts can be obtained from applying a univariate time-series model, such as an autoregressive integrated moving average (ARIMA) model. We use the `uto.`rima  algorithm of @HK08 to select the optimal orders of an ARIMA model on the basis of an information criterion, such as the corrected Akaike information criterion [@HT89] considered in this paper.

Similarly, conditional on the estimated mean and estimated principal components, the total variance can be approximated by $$\begin{aligned}
 \text{Var}[\widehat{z}_{n+h|n,i}]&\approx \sum^K_{k=1}\widehat{u}_{n+h|n,k}\widehat{\phi}_{k,i}^2+\widehat{v}_{n+h,i},\end{aligned}$$ where $\widehat{u}_{n+h|n,k}$ denotes the estimated variance of the sample principal component scores; $\widehat{\phi}_{k,i}^2$ denotes the square of the fixed principal components; and $\widehat{v}_{n+h,i}$ denotes the estimated variance of the model residual [see also @SBH11]. The 80% prediction interval of the transformed data can be obtained based on the estimated total variance and a normality assumption.

Having obtained the point and interval forecasts for the transformed data, we then back-transform these forecasts to the original scale through inverse Box-Cox transformation. This can be expressed as $$\widehat{f}_{n+h|n,i} = \left\{ \begin{array}{ll}
         \left(\lambda \widehat{z}_{n+h|n,i} +1\right)^{\frac{1}{\lambda}} & \mbox{if $\lambda \neq 0$}\\
        \exp (\widehat{z}_{n+h|n,i}) & \mbox{if $\lambda = 0$}\end{array} \right.$$

Application to age-specific fertility
-------------------------------------

In Figure \[fig:decamp\], we present principal components and their associated scores for the Australian fertility data from 1921 to 1989. Based on these data, the forecasts of fertility rates from 1990 to 2006 are obtained. Although the optimal $K$ is selected by the ratio-based estimator, we display only the first two components for the ease of presentation. In the top panel, we show the age profile. In the middle panel, we display the time trend of the principal component scores. In particular, the point forecasts of the scores are shown in solid line, whereas the dark and light gray regions represent the 80% and 95% point-wise prediction intervals, respectively. In the bottom panel, the forecasts of fertility are obtained by multiplying the fixed principal components by the forecast principal component scores before adding the main effect.

![Principal component decomposition for the Australian fertility data from 1921 to 1989, from which the forecasts are obtained from 1990 to 2006.<span data-label="fig:decamp"></span>](decomposition){width="\textwidth"}

The first principal component models the fertility rates at young ages, whereas the second principal component models the fertility rates at older ages. From the forecast first principal component scores, it is clear that the fertility trend at young ages is likely to decline. Based on the forecast second principal component scores, it is evident that the fertility trend at older ages is likely to increase.

Result {#sec:4}
======

Selection of the optimal parameter {#sec:3.2}
----------------------------------

Section \[sec:3.1\] presents one method for modeling and forecasting age-specific fertility, but the main contribution is to present a method to select optimal transformation parameter based on in-sample forecast accuracy. To investigate the in-sample forecast accuracy, we implement the rolling origin approach. Using the initial training sample in the Australian age-specific fertility, we produce one- to 17-step-ahead point and interval forecasts. Then, we increase the sample size by one year, re-estimate the model and produce one- to 16-step-ahead forecasts. This process is iterated until the training sample reaches the last year of the validation sample. This would produce 17 one-step-ahead forecasts, 16 two-step-ahead forecasts, up to one 17-step-ahead forecast. We use these forecasts to evaluate the out-of-sample forecast accuracy. For a range of forecast horizons, we calculate its forecast accuracy based on an error measure, such as MAFE or interval score given in , over different ages and years in the validation sample. The optimal Box-Cox transformation parameter is the one that minimizes the median of a forecast error measure over a range of forecast horizons. Computationally, the optimization can be achieved by using the `ptimize \ functi`n in

.

In Table \[tab:bcfert\], we present the selected Box-Cox transformation parameter $\lambda$, based on the in-sample MAFE and interval score. For the purpose of comparison, we also consider the log transformation which is commonly used in modeling age-specific mortality. Based on the averaged MAFE and averaged interval score across 17 horizons, we found that with the selected Box-Cox transformation parameter, the out-of-sample point and interval forecast errors can be reduced in comparison with the log transformation for each forecast horizon.

=0.14in

  -------- ----------------------- -------------------- ---------------------- ------------------------ --------------------- --
                                                                                                                              
  $h$        MAFE$_{\lambda=0.46}$   MAFE$_{\lambda=0}$   MAFE$_{\lambda=0.4}$   score$_{\lambda=0.46}$   score$_{\lambda=0}$ 
  1                                             0.00235                0.00120                                        0.00682 
  2                                             0.00304                0.00155                                        0.00982 
  3                                             0.00388                0.00225                                        0.01332 
  4                                             0.00487                0.00289                                        0.01696 
  5                                             0.00590                0.00360                                        0.01905 
  6                                             0.00721                0.00432                                        0.02135 
  7                                             0.00853                0.00508                                        0.02568 
  8                                             0.00964                0.00591                                        0.02909 
  9                                             0.01067                0.00662                                        0.03324 
  10                                            0.01180                0.00735                                        0.03743 
  11                                            0.01291                0.00780                                        0.04313 
  12                                            0.01400                0.00844                                        0.04745 
  13                                            0.01499                0.00938                                        0.05058 
  14                                            0.01668                0.01013                                        0.06074 
  15                                            0.01782                0.01070                                        0.06641 
  16                                            0.01871                0.01111                                        0.07244 
  17                                            0.01830                0.01179                                        0.07312 
  Mean                                          0.01067                0.00648                                        0.03686 
  Median                                        0.01067                0.00662                                        0.03324 
  -------- ----------------------- -------------------- ---------------------- ------------------------ --------------------- --

  : The estimated optimal Box-Cox transformation parameters and out-of-sample point and interval forecast accuracy for different horizons. The minimum MAFE and interval score are highlighted in bold for each horizon and the summary statistics.<span data-label="tab:bcfert"></span>

Note that Table \[tab:bcfert\] is consistent with the results of @HB08 who found that the best point forecast accuracy (for one-step-ahead forecasts) had $\lambda=0.4$. In comparison to $\lambda=0.4$, we found that our selected $\lambda=0.46$ gives better accuracy for each horizon, but their differences in point forecast accuracy on the testing sample are marginal.

Application to age-specific fertility
-------------------------------------

Prior to fitting a modified Lee-Carter model, the raw data are transformed by the Box-Cox transformation. The Box-Cox transformation may introduce a small bias, but can potentially reduce variance. As a result, this may improve estimation and forecast accuracy. In terms of its effect on forecasts of fertility, Figure \[fig:decomp\_BC\] displays the functional principle component decomposition for the Box-Cox transformed data with $\lambda=0.46$. From the bottom left plot, it is evident that the forecast fertility rates have a similar shape as the ones using the raw data. However, the age patterns are very different in shape from the un-transformed ones, such as the bimodality shown in the first principal component. From the forecast first principal component scores, such bimodality is likely to continue with increasing forecast uncertainties as horizon increases. The second principal component shows the contrast between ages around 25 and 40. From the forecast second principal component scores, such contrast is likely to decrease with increasing forecast uncertainties as horizon increases.

![Principal component decomposition for the transformed Australian fertility data from 1921 to 1989, from which the forecasts are obtained from 1990 to 2006.<span data-label="fig:decomp_BC"></span>](decomposition_BC){width="\textwidth"}

Conclusion and future research {#sec:5}
==============================

We presented a method and an algorithm for selecting the optimal Box-Cox transformation parameter. The contributions of this paper are two-fold: First, we found that the log transformation may not be adequate for modeling and forecasting age-specific fertility. Second, we presented a way of selecting optimal Box-Cox transformation parameter based on in-sample forecast accuracy and showed that with the selected Box-Cox transformation parameter, the out-of-sample point and interval forecast accuracy can be improved. In addition, our optimal Box-Cox transformation parameter $\lambda=0.46$ produces slightly smaller point forecast error in comparison to $\lambda=0.4$ used in @HB08.

The proposed method and algorithm can be extended to select the optimal Box-Cox transformation parameter for modeling and forecasting age-specific migration. With the selected Box-Cox transformation parameter, the forecast uncertainties associated with age-specific components of population change are more likely to be fully captured. Finally, from a Bayesian viewpoint, it is also possible to embed the selection of the optimal Box-Cox transformation parameter into the modeling and forecasting.

Acknowledgements {#acknowledgements .unnumbered}
================

The author thanks two referees for their insightful comments and suggestions, which led to a much improved manuscript. The author thanks Professor Peter W. F. Smith and Dr Jakub Bijak for insightful comments and suggestions, and Bridget Browne for proof-reading an early version of this manuscript.

[^1]: Postal address: Research School of Finance, Actuarial Studies and Applied Statistics, Building 26C, Australian National University, Canberra 0200, Australia; Telephone: (551)684-4376; Email: lbaker@example.com

{'source': 'arXiv_out/1503'}