关键词 > PSTAT174/274

PSTAT 174/274: Homework # 3

发布时间:2023-02-13

Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: daixieit

PSTAT 174/274: Homework # 3 (week 4 & 5).

1.  (both 174 & 274 attempt)

A random walk is expressed as X1  = Z1, Xt  = Xt 1 + Zt, t = 2, 3, . . . , where Zt  ∼ WN (µZ , σZ(2)), that is, E (Zt) = µZ , Var(Zt) = σZ(2), and Cov (Zt, Zs) = 0 for t  s.  Determine which statements are true with respect to a random walk model; show calculations and provide complete explanations.

i  If µZ   0, then the random walk is nonstationary in the mean.

(Hint:  Nonstationary in the mean means that the mean changes with time .)

ii  If σZ(2)  = 0, then the random walk is nonstationary in the variance.

(Hint: Nonstationary in the variance means that the variance changes with time.) iii If σZ(2)  > 0, then the random walk is nonstationary in the variance.

2.  (both 174 & 274 attempt) Calculation of sample acf.

You are given the following quarterly rainfall totals over a two-year span:

Quarter

Rainfall

2016 q1

2016 q2

2016 q3

2016 q4

2017 q1

2017 q2

2017 q3

2017 q4

25

19

10

32

26

38

22

20

Question: Calculate the sample lag 1,2,3 and 4 autocorrelations denoted by 1 , 2 , 3 , 4 .

3.  (both 174 & 274 attempt) Gaussian  White Noise and its square .

Let {Zt} be a Gaussian white noise, that is, a sequence of i.i.d.  normal r.v.s each with mean zero and variance 1. Let Yt = Zt(2) . Questions:

i Using R generate 350 observations of the Gaussian white noise Z . Plot the series and its acf. ii Using R, plot 350 observations of the series Y = Zt(2) . Plot its acf.

iii Analyze graphs from (i) and ii).

  Can you see a difference between the plots of graphs of time series Z and Y? From the graphs, would you conclude that both series are stationary (or not)?

 Is there a noticeable difference in the plots of acf functions ρZ  and ρY ? Would you describe Y as a non-Gaussian white noise sequence based on your plots?

Provide full analysis of your conclusions.

iv  Calculate the second-order moments of Y: µY (t) = E (Yt), σY(2)(t) = Var (Yt), and

ρY (t, t + h) = Cor (Yt, Yt+h). Do your calculations support your observations in (iii)?

4.  (both 174 & 274 attempt)

This question explores time series decomposition in R. You will learn about X11 and SEATS: For over three decades X11 has been the standard approach used to seasonally adjust time series at the Bureau of the Labor Statistics (BLS). There is a nice guide briefly you can review from the Australian Beauro of Statistics (ABS) that gives a simple overview (see Time Series AnalysisS easonalAdjustmentMethods.pdf )

• NOTE: we will discuss this further in Module Part IV so for now we just look at the R implementa- tions.

Familiarise yourself with the decomposition tool:

http://www.seasonal.website/

https://rdrr.io/cran/seasonal/src/R/seasonal-package.R

 http://www.seasonal.website/seasonal.html

There is an R example to assist you that I have provided as a markdown

  R Example Data Input Output Prep Week 1 and 2.Rmd

Use this as a guide to help you do the following:

 Explain the difference between an additive and a product time series decomposition method.

• First create an R script (function) that will read in the file ECONOMICS USIRYY, 1M.csv and then convert the first column to a valid time format given by yyy-mm-dd and keep only the open values

- output the new tibble into a csv file titled YSIRYoYformatted.csv.

• upload data set which is the USA inflation rate Year-over-Year (YoY) monthly from 1914 to present that you created called YSIRYoYformatted.csv to the seasonal website.

•  decompose the time series contained using the X11 command and discuss the outputs obtained - it will help to review the section https://otexts.com/fpp2/x11.html and to use the R commands provided below

•  Decompose the time series using the SEATS package, again example commands below. Discuss your findings.

YourDataFrame    %>%  seas(x11="")  ->  fit

autoplot(fit)

YourDataFrame    %>%  seas()  %>%

autoplot()

5.  (both 174 & 274 attempt)

You are provided data since 1914 for US 10Y Treasury prices - Open High Low and Close as well as traded volume on a monthly sampling time. Write an R function that will do the following steps:

•  Read in the csv file provided TVC US10Y,1M.csv to a tibble format

•  Convert the first column of times in ISO format to a relevant mm/yyyy format

  Create a ts() object based on the ISO time with monthly frequency

• Explore the time series structure with relevant time series plots  (see file PlotsExamples.Rmd for examples)

• Explore the difference and twice differenced time series - plot three subplots: first with Yt vs t, second subplot with ∇Yt  vs t and third subplot with ∇2 Yt  vs t, where Yt  is the monthly open price

•  Perform two different time series decomposition’s on the monthly open price time series:  an ad- ditive Seasonal - Trend - Residual decomposition and a multiplicative Seasonal - Trend - Residual decomposition. Plot the results of these decompositions and comment on what you find.

•  Construct a quarter year forecast - based on examples provided in (Simple-Forecast-Functions-in- R.Rmd) and plot this result.