mat3379-2024-lab1-solutions
pdf
keyboard_arrow_up
School
University of Ottawa *
*We aren’t endorsed by this school
Course
3379
Subject
Mathematics
Date
Apr 3, 2024
Type
Pages
14
Uploaded by LieutenantOstrich3315
MAT3379 (Winter 2024)
Data Project 1
Due date: February 26
Question 1.
(a) Generate ARMA(
p, q
) sequence
X
t
.
You have to choose
p
,
q
as well as
the required parameters.
Make sure that the chosen parameters imply
existence of a stationary solution.
(b) Identify the model using ACF and PACF. Include graphs of ACF and
PACF (2 graphs).
(c) Add a linear or a polynomial trend
m
t
. The new sequence is
Y
t
=
m
t
+
X
t
.
(d) Estimate
m
t
using all three methods:
–
parametric method;
–
exponential smoothing;
–
moving average smoothing with your chosen
Q
.
(e) For each of the three methods, plot
Y
t
and the estimated trend
b
m
t
on the
same graphs (3 graphs).
(f) For each of the three methods, compute
b
X
t
=
Y
t
−
ˆ
m
t
.
Plot residuals
(that is
b
X
t
) (3 graphs).
(g) Analyse
b
X
t
using ACF and PACF. Graph ACF and PACF for all three
methods (6 graphs). Identify ARMA model. Compare with your identifi-
cation in (b).
Marking for Question 1
: Part b) - 1 point for the correct model identification
based on your graphs. Part c) - 1 point for producing a graph for tiem series with
trend. Parts d)-e) - 3 points for producing 3 graphs using each method. Part f)
- 1 point for plots of residuals. Part g) - 3 points for correct model identification
for each of the three methods. Additionally, 6 points for providing codes and
overall quality of your presentation.
Total: 15 points.
Question 2 will not be marked.
Solution to Question 1.
(a) I generated 100 observations from ARMA(1,2) with parameters
ϕ
= 0
.
3
and
θ
1
=
θ
2
= 1.
(b) Refer to Figure 1. For my example, it is hard to identify the model from
ACF and PACF. PACF suggests that there is MA part of order
q
= 1 (note
that original time series was
q
= 2). ACF suggests that if there is no AR
part, then MA part must be of order
q
= 4. Consequently, it suggest that
there is an autoregressive part in the model.
I choose ARMA(1
,
1).
1
(c) Refer to Figure 2. I added linear trend
m
t
= 0
.
1
t
:
c=length(MyTimeSeries);
Time=c(1:n);
M=0.1*Time;
NewTimeSeries=MyTimeSeries+M;
plot.ts(MyTimeSeries); plot.ts(NewTimeSeries)
(d), (e) Refer to Figure 3. I estimated linear parameters as
n=100
Time=c(1:n)
a.est=lm(NewTimeSeries~Time)$coefficients[1];
b.est=lm(NewTimeSeries~Time)$coefficients[2];
We obtain ˆ
a
=
−
0
.
48,
b
= 0
.
105.
Recall that the true parameters are
a
= 0,
b
= 0
.
1.
Then, I typed
Fitted.Lin.Trend=a.est+b.est*Time;
plot(Time,NewTimeSeries,type="l",col="black");
points(Time,Fitted.Lin.Trend,type="l",col="blue");
ResidualsLinear=NewTimeSeries-Fitted.Lin.Trend;
Then, I applied moving average smoothing as follows
MySmoothedTimeSeries=SmoothedTS(NewTimeSeries,5)
plot(Time,NewTimeSeries,type="l",col="black");
points(Time,MySmoothedTimeSeries,type="l",col="blue");
ResidualsMASmooth=NewTimeSeries-MySmoothedTimeSeries;
Then, I applied exponential smoothing as follows
AnotherSmoothedTimeSeries=ExpSmooth(NewTimeSeries,0.2)
plot(Time,NewTimeSeries,type="l",col="black");
points(Time,AnotherSmoothedTimeSeries,type="l",col="blue");
ResidualsExpSmooth=NewTimeSeries-AnotherSmoothedTimeSeries;
2
In both cases, parameters
Q
= 5 in the MA smoothing and
α
= 0
.
2 in
the exponential smoothing are chosen by trying several parameters. Idea:
you should choose parameters such that the smoothed time series does not
follow too closely the original one.
(f) Refer to Figure 4. We plot residuals in three above cases. The obtained
pictures suggest that the residuals are stationary.
plot.ts(ResidualsLinear);
plot.ts(ResidualsMASmooth);
plot.ts(ResidualsExpSmooth);
(g) Refer to Figure 5. In all three case we plot ACF and PACF. We start with
the case of linear trend. Note that for the parametric linear trend, ACF
and PACF look similar to the original time series in (b).
acf(ResidualsLinear); pacf(ResidualsLinear);
Refer to Figure 6. We follow with moving average smoothing. Note that
for the moving average smooth, ACF and PACF look different as compared
to the original time series in (b). It is hard to specify the model here. It
looks like MA(1) model with some AR part.
This is the price you pay
when you apply nonparametric smooth.
acf(ResidualsMASmooth); pacf(ResidualsMASmooth);
Refer to Figure 7. Note that for the exponential smooth, ACF and PACF
look different as compared to the original time series in (b). I would con-
clude that residuals follows MA(1) model. Thus, I would not specify the
model correctly. This is the price you pay when you apply nonparametric
smooth.
CONCLUSION: Whenever possible estimate trend in a parametric way
(linear, polynomial).
acf(ResidualsExpSmooth); pacf(ResidualsExpSmooth);
Question 2.
(a) Download a data set.
(b) Remove trend using any of the methods, if needed.
You should obtain
stationary time series. State your chosen
b
m
t
.
(c) Plot the original sequence together with the estimated trend (1 graph).
(d) Plot the stationary part, then its ACF and PACF (3 graphs). Comment
on a model.
3
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
- Access to all documents
- Unlimited textbook solutions
- 24/7 expert homework help
Solution to Question 2.
I consider
SouthernHemisphere.txt
. I typed
plot.ts(SouthernHemisphere)
and obtained Figure 11.
The graph suggests that there is some trend. Linear trend does not seem
to be appropriate. I applied exponential smoothing. Refer to Figure 12.
SmoothedTimeSeries=ExpSmooth(SouthernHemisphere,0.2);
n=length(SouthernHemisphere); Time=c(1:n);
plot(Time,SouthernHemisphere,type="l",col="black");
points(Time,SmoothedTimeSeries,type="l",col="black");
ResidualsExpSmooth=SouthernHemisphere-SmoothedTimeSeries;
I plot residuals, ACF, PACF. Refer to Figure 13.
plot.ts(ResidualsExpSmooth); acf(ResidualsExpSmooth);
pacf(ResidualsExpSmooth);
PACF excludes MA component; suggests AR(1). ACF suggests that it is
either AR model of small order or MA(1). Combining together; I choose
AR(1) model.
4
1
Figure 1
0
5
10
15
20
-0.2
0.0
0.2
0.4
0.6
0.8
1.0
Lag
ACF
Series MyTimeSeries
5
10
15
20
-0.2
0.0
0.2
0.4
0.6
Lag
Partial ACF
Series MyTimeSeries
5
2
Figure 2
Time
MyTimeSeries
0
20
40
60
80
-4
-2
0
2
4
Time
NewTimeSeries
0
20
40
60
80
0
5
10
6
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
- Access to all documents
- Unlimited textbook solutions
- 24/7 expert homework help
3
Figure 3
0
20
40
60
80
100
0
5
10
Time
NewTimeSeries
0
20
40
60
80
100
0
5
10
Time
NewTimeSeries
0
20
40
60
80
100
0
5
10
Time
NewTimeSeries
7
4
Figure 4
Time
ResidualsLinear
0
20
40
60
80
-4
-2
0
2
4
Time
ResidualsMASmooth
0
20
40
60
80
-2
-1
0
1
2
Time
ResidualsExpSmooth
0
20
40
60
80
-1.0
-0.5
0.0
0.5
1.0
1.5
2.0
8
5
Figure 5
0
5
10
15
20
-0.2
0.0
0.2
0.4
0.6
0.8
1.0
Lag
ACF
Series ResidualsLinear
5
10
15
20
-0.2
0.0
0.2
0.4
0.6
Lag
Partial ACF
Series ResidualsLinear
9
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
- Access to all documents
- Unlimited textbook solutions
- 24/7 expert homework help
6
Figure 5
0
5
10
15
20
-0.5
0.0
0.5
1.0
Lag
ACF
Series ResidualsMASmooth
5
10
15
20
-0.4
-0.2
0.0
0.2
Lag
Partial ACF
Series ResidualsMASmooth
10
7
Figure 6
0
5
10
15
20
-0.2
0.0
0.2
0.4
0.6
0.8
1.0
Lag
ACF
Series ResidualsExpSmooth
5
10
15
20
-0.4
-0.2
0.0
0.2
0.4
Lag
Partial ACF
Series ResidualsExpSmooth
11
8
Figure 11
Time
SouthernHemisphere
0
50
100
150
-0.5
0.0
0.5
12
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
- Access to all documents
- Unlimited textbook solutions
- 24/7 expert homework help
9
Figure 12
0
50
100
150
-0.5
0.0
0.5
Time
SouthernHemisphere
13
10
Figure 13
Time
ResidualsExpSmooth
0
50
100
150
-0.4
-0.2
0.0
0.2
0.4
0
5
10
15
20
-0.2
0.0
0.2
0.4
0.6
0.8
1.0
Lag
ACF
Series ResidualsExpSmoot
5
10
15
20
-0.1
0.0
0.1
0.2
Lag
Partial ACF
Series ResidualsExpSmoot
14