CHAPTER 5 STAT 520, J.
TEBBS
5.4 Transformations
REVIEW : If we are trying to model a nonstationary time series, it may be helpful to
transform the data first before we examine any data differences (or before “detrending”
the data if we use regression methods from Chapter 3).
• For example, if there is clear evidence of nonconstant variance over time (e.g., the
variance increases over time, etc.), then a suitable transformation to the data
might remove (or lessen the impact of) the nonconstant variance pattern.
• Applying a transformation to address nonconstant variance is regarded as a “first
step.” This is done before using differencing as a means to achieve stationarity.
Example 5.4. Data file: electricity (TSA). Figure 5.7 displays monthly electricity
usage in the United States (usage from coal, natural gas, nuclear, petroleum, and wind)
between January, 1973 and December, 2005.
• From the plot, we can see that there is increasing variance over time; e.g., the series
is much more variable at later years than it is in earlier years.
• Time series that exhibit this “fanning out” shape are not stationary because the
variance changes over time.
• Before we try to model these data, we should first apply a transformation to make
the variance constant (that is, we would like to first “stabilize” the variance).
THEORY : Suppose that the variance of nonstationary process {Yt } can be written as
var(Yt ) = c0 f (µt ),
where µt = E(Yt ) and c0 is a positive constant free of µt . Therefore, the variance is not
constant because it is a function of µt , which is changing over time. Our goal is to find a
function T so that the transformed series T (Yt ) has constant variance. Such a function is
PAGE 129
CHAPTER 5 STAT 520, J. TEBBS
400000
350000
300000
Electricity usage
250000
200000
150000
1975 1980 1985 1990 1995 2000 2005
Time
Figure 5.7: Electricity data. Monthly U.S. electricity generation, measured in millions of
kilowatt hours, from 1/1973 to 12/2005.
called a variance stabilizing transformation function. Consider approximating the
function T by a first-order Taylor-series expansion about the point µt , that is,
T (Yt ) ≈ T (µt ) + T ′ (µt )(Yt − µt ),
where T ′ (µt ) is the first derivative of T (Yt ), evaluated at µt . Now, note that
var[T (Yt )] ≈ var[T (µt ) + T ′ (µt )(Yt − µt )]
= c0 [T ′ (µt )]2 f (µt ).
Therefore, we want to find the function T which satisfies
var[T (Yt )] ≈ c0 [T ′ (µt )]2 f (µt ) = c1 ,
set
where c1 is a constant free of µt . Solving this expression for T ′ (µt ), we get the differential
equation √
′ c1 c2
T (µt ) = =√ ,
c0 f (µt ) f (µt )
PAGE 130
CHAPTER 5 STAT 520, J. TEBBS
√
where c2 = c1 /c0 is free of µt . Integrating both sides, we get
∫
c
T (µt ) = √ 2 dµt + c3 ,
f (µt )
where c3 is a constant free of µt . In the calculations below, the values of c2 and c3 can
be taken to be anything, as long as they are free of µt .
• If var(Yt ) = c0 µt , so that the variance of the series is proportional to the mean,
then ∫
c2 √
T (µt ) = √ dµt = 2c2 µt + c3 ,
µt
where c3 is a constant free of µt . If we take c2 = 1/2 and c3 = 0, we see that the
√
square root of the series, T (Yt ) = Yt , will provide a constant variance.
• If var(Yt ) = c0 µ2t , so that the standard deviation of the series is proportional to the
mean, then ∫
c
T (µt ) = √2 dµt = c2 ln(µt ) + c3 ,
µ2t
where c3 is a constant free of µt . If we take c2 = 1 and c3 = 0, we see that the
logarithm of the series, T (Yt ) = ln(Yt ), will provide a constant variance.
• If var(Yt ) = c0 µ4t , so that the standard deviation of the series is proportional to the
square of the mean, then
∫ ( )
c2 1
T (µt ) = √ dµt = c2 − + c3 ,
µ4t µt
where c3 is a constant free of µt . If we take c2 = −1 and c3 = 0, we see that the
reciprocal of the series, T (Yt ) = 1/Yt , will provide a constant variance.
BOX-COX TRANSFORMATIONS : More generally, we can use a power transforma-
tion introduced by Box and Cox (1964). The transformation is defined by
Yt − 1 , λ ̸= 0
λ
T (Yt ) = λ
ln(Yt ), λ = 0,
PAGE 131
CHAPTER 5 STAT 520, J. TEBBS
Table 5.1: Box-Cox transformation parameters λ and their associated transformations.
λ T (Yt ) Description
−2.0 1/Yt2 Inverse square
−1.0 1/Yt Reciprocal
√
−0.5 1/ Yt Inverse square root
0.0 ln(Yt ) Logarithm
√
0.5 Yt Square root
1.0 Yt Identity (no transformation)
2.0 Yt2 Square
where λ is called the transformation parameter. Some common values of λ, and their
implied transformations are given in Table 5.1.
NOTE : To see why the logarithm transformation T (Yt ) = ln(Yt ) is used when λ = 0,
note that by L’Höptial’s Rule (from calculus),
Ytλ − 1 Y λ ln(Yt )
lim = lim t = ln(Yt ).
λ→0 λ λ→0 1
• A variance stabilizing transformation can only be performed on a positive series,
that is, when Yt > 0, for all t. This turns out not to be prohibitive, because if some
or all of the series Yt is negative, we can simply add (the same) positive constant c
to each observation, where c is chosen so that everything becomes positive. Adding
c will not affect the (non)stationarity properties of {Yt }.
• Remember, a variance stabilizing transformation, if needed, should be performed
before taking any data differences.
• Frequently, a transformation performed to stabilize the variance will also improve
an approximation of normality. We will discuss the normality assumption later
(Chapters 7-8) when we address issues in statistical inference.
PAGE 132
CHAPTER 5 STAT 520, J. TEBBS
1500
95%
1480
Log Likelihood
1460
1440
1420
−2 −1 0 1 2
Figure 5.8: Electricity data. Log-likelihood function versus λ. Note that λ is on the
horizontal axis. A 95 percent confidence interval for λ is also depicted.
DETERMINING λ: We can let the data “suggest” a suitable transformation in the
Box-Cox power family.
• We do this by treating λ as a parameter, writing the log-likelihood function of the
data (under the normality assumption), and finding the value of λ which maximizes
the log-likelihood function; i.e., the maximum likelihood estimate (MLE) of λ.
• There is an R function [Link] that does all of the calculations. The func-
tion also provides an approximate 95 percent confidence interval for λ, which is
constructed using the large sample properties of MLEs.
• The computations needed to produce a figure like the one in Figure 5.8 can be time
consuming if the series is long (i.e., n is large). Also, the profile log-likelihood is
not always as “smooth” as that seen in Figure 5.8.
PAGE 133
CHAPTER 5 STAT 520, J. TEBBS
12.8
12.6
(Log) electricity usage
12.4
12.2
12.0
1975 1980 1985 1990 1995 2000 2005
Time
Figure 5.9: Electricity data (transformed). Monthly U.S. electricity generation measured
on the log scale.
Example 5.4 (continued). Figure 5.8 displays the profile log-likelihood of λ for the
electricity data. The value of λ (on the horizontal axis) that maximizes the log-likelihood
function looks to be λ ≈ −0.1, suggesting the transformation
T (Yt ) = Yt−0.1 .
However, this transformation makes little practical sense. An approximate 95 percent
confidence interval for λ looks to be about (−0.4, 0.2). Because λ = 0 is in this interval,
a log transformation T (Yt ) = ln(Yt ) is not unreasonable.
• The log-transformed series {ln Yt } is displayed in Figure 5.9. We see that applying
the log transformation has notably lessened the nonconstant variance (although
there still is a mild increase in the variance over time).
• Now that we have applied the transformation, we can now return to our previous
PAGE 134
CHAPTER 5 STAT 520, J. TEBBS
0.8
ACF of the 1st differences of the logged series
0.1
0.6
First differences of log(Electricity)
0.4
0.0
0.2
0.0
−0.1
−0.2
−0.4
−0.2
1975 1980 1985 1990 1995 2000 2005 0 5 10 15 20 25 30 35
Time Lag
Figure 5.10: Electricity data. Left: Wt = log Yt − log Yt−1 , the first differences of the
log-transformed data. Right: The sample autocorrelation function of the {Wt } data.
modeling techniques. For the log-transformed series, there is still a pronounced
linear trend over time. Therefore, we consider the first difference process (on the
log scale), given by
Wt = log Yt − log Yt−1 = ∇ log Yt .
• The {Wt } series is plotted in Figure 5.10 (left) along with the sample ACF of the
{Wt } series (right). The {Wt } series appears to have a constant mean.
• However, the sample ACF suggests that there is still a large amount of structure
in the data that remains after differencing the log-transformed series.
• In particular, there looks to be significant autocorrelations that arise according to
a seasonal pattern. We will consider seasonal processes that model this type of
variability in Chapter 10.
REMARK : Taking the differences of a log-transformed series, as we have done in this
example, often arises in financial applications where Yt (e.g., stock price, portfolio return,
etc.) tends to have stable percentage changes over time. See pp 99 (CC).
PAGE 135