程序代写案例-ST422
时间:2021-11-28
Time Series Week 8
ST422 Assessed Coursework
Deadline: 9am, December 10, 2021.
1 Questions
The file Fuel price.csv on the project link on Moodle contains the weekly
time series of fuel prices for ultra-low sulphur unleaded petrol (USLP) and
ultra-low sulphur diesel (USLD). The project is on finding good forecasts for
both time series.
Read the weekly data into a dataframe, say fuel. Then read the fuel prices
series using
library(forecast)
library(lubridate)
ulsp = msts(fuel[,2], seasonal=365.25/7,
start = decimal_date(as.Date("2003-06-09")))
ulsd = msts(fuel[,3], seasonal=365.25/7,
start = decimal_date(as.Date("2003-06-09")))
(In your future endeavour with weekly data, you may want to remember that
frequency=52 is not exactly right, but should be exactly 365/7 for non-leap
years, and 366/7 for leap years, making it on average 365.25/7 as there is a
leap year every 4 years)
1. Present time series plots to display the data, and other proper plots
that you think is helpful to reveal the structure of the data. Describe
what you found.
2. Using the knowledge you gained from part 1, find time series models to
separately model the 2 different series. Write down the fitted models
for the 2 time series, and produce predicted values until the last week
of December 2021 using forecast. Remember to briefly justify your
final models chosen. If the no models are satisfactory, state so, and
November 19, 2021 ST422 1 c©Copyright Clifford Lam 2021
Time Series Week 8
use the one that you think is the most satisfactory among the ones you
tried.
3. Do the following for each series:
Split the data into 60% (the first 60% of data points) training data and
40% validation data. Use a rolling window with length D to predict
the next weekly measurement for the training data, each time moving
the window forward A weeks. You may use A = D/3 or A = D/2 to
reduce computational burden in practice.
Write an R function to compute the weekly squared prediction error,
and aggregate them to form a final prediction error for each window
length. Find a window length to minimise this prediction error. The
models you use within each window can start from auto.arima or just
use those fitted from the function if they are satisfactory.
Repeat the above for the validation data. Does the window length
found for the training data match the one found for the validation
data?
Determine a window length (with reasons), and predict the measure-
ments until the last week of December 2021 using forecast. Are they
close to the answers in part 2?
4. Use the function mstl to decompose each series into trend, seasonal,
and residual components, and plot them. Then use forecast to predict
and plot predicted values until the last week of December 2021. Are
they close to the answers in part 2 or 3?
(If you are interested, check out the paper on mstl here ).
2 Submission
• Submit your work anonymously under your candidate number in
LSE For You. (NOT your ID Number starting with 20XX).
Write your candidate number on a cover page as well within the
pdf file.
The name of the pdf file should be candidate number-ST422.pdf. For
instance, if you candidate number is 54321, then the filename should
be 54321-ST422.pdf.
November 19, 2021 ST422 2 c©Copyright Clifford Lam 2021
Time Series Week 8
• Plagiarism will be checked, and students who found to plagiarise will
not only be penalised, but also face potential disciplinary actions from
the school.
• Upload a single pdf file to the corresponding course-work upload link
on Moodle.
• The single pdf file should contain your presented answers including
graphs and tables. All R codes used should be added in an appendix
in the end.
• The upload link will stop working after the deadline indicated on the
link. You can still submit then by sending the file directly to me,
subject to 5-mark penalty from a possible 100 for every day late.
• Extensions to deadlines for coursework will only be given in fully doc-
umented serious extenuating circumstances.
November 19, 2021 ST422 3 c©Copyright Clifford Lam 2021


essay、essay代写