Professional Documents
Culture Documents
Page 1 of 16
UECM3243 Time Series Analysis / UECM3493 Introduction to Time Series and Forecasting /
UECM3773 Financial Time Series
The time series components do not always occur alone. They can occur in any combination or
all can occur together. For this reason, no single best forecasting model exits. In fact, there are
many forecasting methods that can be used to predict future events.
Forecasting Methods
Page 2 of 16
UECM3243 Time Series Analysis / UECM3493 Introduction to Time Series and Forecasting /
UECM3773 Financial Time Series
ASSET RETURNS
Let Pt be the price of an asset at time t , and assume no dividend.
Pt
Rt k 1 net return
Pt k
Dividend Payment.
Let Pt be the price of an asset at time t
Dt be the dividend payment of an asset between dates t 1 and t
The simple net return and continuously compounded return at time t become
P Dt
Rt t 1 , rt ln Pt Dt ln Pt 1 .
Pt 1
Page 3 of 16
UECM3243 Time Series Analysis / UECM3493 Introduction to Time Series and Forecasting /
UECM3773 Financial Time Series
Example 1.1.
Table below gives six daily (adjusted) closing prices of Apple stock in December 2017.
Compute the gross return, simple return and log return of holding the stock from
(a) 27/12 to 28/12,
(b) 22/12 to 29/12.
Solution:
Example 1.2.
(a) Given the monthly log return of an asset is 4.46%. Find the corresponding monthly
simple return.
(b) Given the monthly log returns of an asset within a quarter are 4.46%, -7.34% and
10.77%. Find the quarterly log return.
(c) Given the monthly simple returns of an asset are 4.46%, -7.34% and 10.77%. Find the
quarterly simple return.
Solution:
Page 4 of 16
UECM3243 Time Series Analysis / UECM3493 Introduction to Time Series and Forecasting /
UECM3773 Financial Time Series
T 1 t 1
Sample skewness
T
1
3 t
Sˆ x x ˆ x
3
T 1 ˆ x t 1
Sample kurtosis
T
1
Kˆ x x ˆ
4
T 1 ˆ x4 t 1
t x
Page 5 of 16
UECM3243 Time Series Analysis / UECM3493 Introduction to Time Series and Forecasting /
UECM3773 Financial Time Series
Example 1.3.
Consider the daily log returns of the Sony stock from 04/01/2010 to 29/12/2017. The time plot
of the data is given below.
Here, we use the command basicStats of fBasics in Rmetrics to obtain summary statistics of the
log returns and to perform some basic hypothesis testing.
From the output, we see that there are data points, the sample mean of the log
return is or , and the sample standard error is .
The sample skewness and excess kurtosis are and
respectively.
Next, let denotes the mean of the daily Sony log return.
H0 : 0
H1 : 0
0.05 , p-value =
0.05 , p-value ≈
Page 6 of 16
UECM3243 Time Series Analysis / UECM3493 Introduction to Time Series and Forecasting /
UECM3773 Financial Time Series
0.05 , p-value =
Note. The test statistics value is huge, which is large compared with a standard normal random
variable. Thus the p-value is close to zero and hence reject H 0 .
0.05 , p-value
Note. The Jarque-Bera test statistic from the output is 1870.7536, which is very large compared
with a chi-square distribution with 2 degrees of freedom.
Page 7 of 16
UECM3243 Time Series Analysis / UECM3493 Introduction to Time Series and Forecasting /
UECM3773 Financial Time Series
R demonstration
> library(fBasics)
> sony=read.table("sne1017.txt", header=T)
> head(sony)
SNE.Open SNE.High SNE.Low SNE.Close SNE.Volume SNE.Adjusted
1 29.52 30.18 29.50 30.02 988800 27.62975
2 29.72 29.93 29.50 29.88 567800 27.50090
3 29.88 29.95 29.66 29.85 468200 27.47329
4 29.74 29.87 29.59 29.80 645300 27.42727
5 30.04 30.47 29.93 30.41 574100 27.98870
6 30.72 30.75 30.39 30.60 603200 28.16357
> sony.lrtn=diff(log(sony$SNE.Adjusted)) # compute daily log returns
> head(sony.lrtn) # show the first 6 rows of data
[1] -0.004674540 -0.001004544 -0.001676450 0.020263156
[5] 0.006228548 0.031207366
> tdx=c(1:2012)/252+2010 # calender time
> plot(tdx, sony.lrtn, xlab="year", ylab="log return", type="l")
# note that type = small letter L not one
> title(main="Sony Corporation")
> basicStats(sony.lrtn) # compute descriptive statistics of log returns
sony.lrtn
nobs 2012.000000
NAs 0.000000
Minimum -0.118491
Maximum 0.162913
1. Quartile -0.011236
3. Quartile 0.010880
Mean 0.000242
Median -0.000325
Sum 0.486658
SE Mean 0.000467
LCL Mean -0.000675
UCL Mean 0.001158
Variance 0.000439
Stdev 0.020961
Skewness 0.300098
Kurtosis 4.677912
> ## simple test
> t.test(sony.lrtn) # testing the mean log return = 0
One Sample t-test
data: sony.lrtn
t = 0.51761, df = 2011, p-value = 0.6048
alternative hypothesis: true mean is not equal to 0
95 percent confidence interval:
-0.0006745549 0.0011583098
sample estimates:
mean of x
0.0002418775
> s3=skewness(sony.lrtn)
> s3
[1] 0.3000975
attr(,"method")
[1] "moment"
> T=length(sony.lrtn) # sample size
> t3=s3/sqrt(6/T) # skewness test
> t3
[1] 5.495418
attr(,"method")
[1] "moment"
> pv1=2*(1-pnorm(t3)) # compute p-value
> pv1
[1] 3.897854e-08
attr(,"method")
[1] "moment"
> s4=kurtosis(sony.lrtn) # this is excess kurtosis
> s4
[1] 4.677912
attr(,"method")
[1] "excess"
> t4=s4/sqrt(24/T) # kurtosis test
> t4
[1] 42.83122
attr(,"method")
[1] "excess"
> pv2=2*(1-pnorm(t4)) # compute p-value
> pv2
[1] 0
attr(,"method")
[1] "excess"
> normalTest(sony.lrtn, method="jb") # JB test
Title:
Jarque - Bera Normalality Test
Test Results:
STATISTIC:
X-squared: 1870.7536
P VALUE:
Asymptotic p Value: < 2.2e-16
Page 8 of 16
UECM3243 Time Series Analysis / UECM3493 Introduction to Time Series and Forecasting /
UECM3773 Financial Time Series
Figure 1.1. Histogram of daily log returns of Sony stock from January 4, 2010 to December 29, 2017.
Figure 1.2. Empirical density function of daily log returns of Sony stock from January 4, 2010 to December 29,
2017. The dashed line denotes the density function of a normal distribution with the same mean and variance.
R demonstration
> hist(sony.lrtn, nclass = 30) # histogram
> d1=density(sony.lrtn) # obtain density estimate
> names(d1) # find out the output variables of the command "density"
[1] "x" "y" "bw" "n" "call" "data.name"
[7] "has.na"
> plot(d1$x, d1$y, xlab="log return", ylab="density", type="l")
> range(sony.lrtn) # range of log return
[1] -0.1184913 0.1629131
> x=seq(-0.12, 0.17, 0.001) # create a sequence of x with increment 0.001
> y=dnorm(x, mean(sony.lrtn), sd(sony.lrtn))
> lines(x,y,lty=2, col="blue")
Page 9 of 16
UECM3243 Time Series Analysis / UECM3493 Introduction to Time Series and Forecasting /
UECM3773 Financial Time Series
Graphs are useful tools in analysing financial data. To gain a better visualization of the
distribution of asset returns, we can exam either the histogram or empirical density function of
the data. Consider, for instance, the daily log returns of Sony stock from January 4, 2010 to
December 29, 2017 for 2013 observations. The summary statistics of the data are given before.
Figure 1.1 shows a histogram of the data. This is obtained by dividing the data range into 30
bins. The plot appears to be symmetric with respect to its mean zero. However, according to
the skewness test, we have sufficient statistical evidence to conclude that the daily log returns
of Sony stock are positively skewed.
The solid line of Figure 1.2 shows the empirical density function of the Sony log returns. The
empirical density function can be regarded as a refined version of the histogram. The dashed
line of Figure 1.2 shows the density function of a normal distribution that has the same mean
and standard deviation as those of the Sony data. The plot provides a visual inspection of the
normality assumption for the daily Sony log returns. The empirical density function has a
higher peak and tends to be skewed to the right with heavy tails than the normal density. This
phenomenon is common for daily stock returns. In general, the deviation between the solid and
dashed line indicates that the daily log returns of Sony stock are not normally distributed. This
is consistent with the result of normality test shown before.
1.3. Stationarity
The foundation of statistical inference in time series analysis is the concept of weak stationarity.
A time series Yt is weakly stationary if its first two moments (mean and variance) are time
invariant. More specifically, Yt is weakly stationary if
(a) E Yt , which is a constant, and
(b) Cov Yt , Yt k k , which only depends on k .
Y Y Yt t k Y
ˆ k t k 1
n
, 0 k T 1 , 1 ˆ k 1 .
Y Y
2
t
t 1
Page 10 of 16
UECM3243 Time Series Analysis / UECM3493 Introduction to Time Series and Forecasting /
UECM3773 Financial Time Series
Example 1.4.
Consider the time series with 6 observations which was constructed using uncorrelated random
number between 0 and 100. Find the autocorrelation function (ACF) for time lags of 1, 2 and
5 respectively.
Period, t 1 2 3 4 5 6
Value, Yt 23 59 36 99 36 74
Solution:
Y Y
2
t Yt Yt 1 Yt 2 Yt 5 Yt Y t Yt 1 Y Yt 2 Y Yt 5 Y
1 23 -31.5 992.25
2 59 23 4.5 20.25 -31.5
3 36 59 23 -18.5 342.25 4.5 -31.5
4 99 36 59 44.5 1980.25 -18.5 4.5
5 36 99 36 -18.5 342.25 44.5 -18.5
6 74 36 99 23 19.5 380.25 -18.5 44.5 -31.5
∑ = 327 ∑ = 4057.50
327
Y 54.5
6
t Y Y Y
t t 1 Y Y Y Y
t t 2 Y Y Y Y
t t 5 Y
1
2 -141.75
3 -83.25 582.75
4 -823.25 200.25
5 -823.25 342.25
6 -360.75 867.75 -614.25
∑ = -2232.25 ∑ = 1993 ∑ = -614.25
2232.25
r1 0.55
4057.50
1993
r2 0.49
4057.50
614.25
r5 0.15
4057.50
Page 11 of 16
UECM3243 Time Series Analysis / UECM3493 Introduction to Time Series and Forecasting /
UECM3773 Financial Time Series
R demonstration
> Y <- c(23,59,36,99,36,74)
> plot.ts(x=Y, ylab=expression(paste(Y[t])), xlab="t (period)",
+ type="o", col="black", main="Time Series with 6 Observations")
> ACF$acf
, , 1
[,1]
[1,] 1.0000000
[2,] -0.5501540
[3,] 0.4911892
[4,] -0.4548983
[5,] 0.1652495
[6,] -0.1513863
Page 12 of 16
UECM3243 Time Series Analysis / UECM3493 Introduction to Time Series and Forecasting /
UECM3773 Financial Time Series
WHITE NOISE
A time series Yt is called a white noise if Yt is a sequence of independent and identically
distributed (iid) random variables with finite mean and variance. In particular, if Yt is normally
distributed with mean 0 and variance 2 , namely,
Yt ~ N 0, 2 ,
the series is called a Gaussian white noise.
For a white noise series, all the ACFs are 0. In practice, if all sample ACFs are close to 0, then
the series is a white noise series.
Example 1.5.
Consider a random error process,
t ~ N 0, 2 .
Then,
E t 0 , and E t2 2 .
For which the 's are uncorrelated across time,
E t u 0 for t u .
t t , namely,
Yt t .
Then,
E Yt and Var Yt 0 E Yt 2 for all t.
2
Cov Yt , Yt k k E Yt Yt k 0 for all t and k 0 .
Page 13 of 16
UECM3243 Time Series Analysis / UECM3493 Introduction to Time Series and Forecasting /
UECM3773 Financial Time Series
i 1
T
1
For simplicity, many software packages use as the asymptotic variance of ˆ k for all k 0 .
T
The t-ratio then becomes
t ˆ k T .
This simplification essentially assumes that the underlying time series is a sequence of iid
random variables.
PORTMANTEAU TESTS
Financial application often requires to test jointly that several autocorrelations of Yt are zero.
H 0 : 1 2 m 0
H1 : i 0 for some i 1, , m
Note. Simulation studies suggest that the choice of m ln T provides better power
performance.
Page 14 of 16
UECM3243 Time Series Analysis / UECM3493 Introduction to Time Series and Forecasting /
UECM3773 Financial Time Series
Example 1.6.
Reconsider Example 1.4., test the null hypothesis if the autocorrelations of Yt are zero by using
(a) Box – Pierce Q statistic,
(b) Ljung – Box Q* statistic.
Solution:
R demonstration
> Box.test(Y, lag=5) # by default is Box-Pierce
Box-Pierce test
data: Y
X-squared = 4.8066, df = 5, p-value = 0.4399
> Box.test(Y, lag=5, type="Ljung")
Box-Ljung test
data: Y
X-squared = 10.867, df = 5, p-value = 0.05408
Page 15 of 16
UECM3243 Time Series Analysis / UECM3493 Introduction to Time Series and Forecasting /
UECM3773 Financial Time Series
Example 1.7.
Test the null hypothesis if the autocorrelations of the time series are zero with the information
given below.
R demonstration
> Box.test(Y2, lag=4)
Box-Pierce test
data: Y2
X-squared = 3.1459, df = 4, p-value = 0.5337
> Box.test(Y2, lag=4, type="Ljung")
Box-Ljung test
data: Y2
X-squared = 3.3922, df = 4, p-value = 0.4945
Page 16 of 16