Econ6037讲解、辅导R、R编程语言调试、讲解Economic Forecasting

- 首页 >> 其他
Econ6037: Economic Forecasting
Spring 2019, University of Hong Kong
Project #1 – Forecasting trade balance
Due date: Thursday, February 28, 11:30p.m. (via the course website)
A note from the instructor
1. Please pay attention to my instructions. They are all here for good reasons!
2. This assignment is meant to be completed individually. Communication with, and hence learning from,
classmates is strongly encouraged. Caution, however, too much reliance on our classmates for help
diminishes the amount of our learning from the assignment. Each student is expected to collect his/her
own data, write or modify the R-scripts to suit the purpose of the assignment, conduct his/her own
analysis and write up this/her own report. Remember:
Give a man (your classmate) a fish, and you feed him for a day.
Teach a man (your classmate) to fish, and you feed him for a lifetime.
3. To enrich our understanding of the world, no students are allowed to work on the same data set.
4. To some students, it might appear easier and more convenient to use Excel or to use R interactively
for the computational part of this assignment. Here, aside from some very basic data manipulation
using Excel, students should use R to do most of the calculation as much as possible. Try to write a
short program/script of R for the task, with annotations so that readers of the R script will know your
programming logic. Points will be deducted if you do not use R to generate the graphs and statistics.
5. Always try to write the report in a self-contained way and in a style that you would be happy to show
to your current or potential employer.
6. Start early. This assignment is very demanding, especially if you are not familiar with R!
7. Make sure your report is back-and-white printer friendly. For grading, I almost always print out the
reports using a black and white printer. Keep in mind that colors will not show on a black and white
printout.
Page 1 of 4We would like to forecast the ANNUAL trade balance between the United States and its major trading partners
(top 30 trading partners). The trade data at monthly frequency can be found at https://www.census.gov/foreigntrade/balance/index.html.
Pick a country. Indicate your choice of country in “Project #1 Wiki” in our course moodle page. Once a country
is taken, other students have to choose different countries. First come, first served!
Obtain the longest series possible of the monthly data of the chosen country. Use the data series up to 2010 for
model selection and initial estimation. That is, model selection is based on in-sample information. Nevertheless,
we would like to check the consistency of in-sample model selection criteria and the out-of-sample performance.
We thus use the remaining data series (2011 onward) for model forecast comparison. While we may use the
data at monthly frequency, our focus is in forecasting the trade balance at ANNUAL frequency, i.e., trade
balance of 2011, 2012, ..., 2018. Note, we focus on one-period-ahead forecast and would like to use a recursive
scheme. That is, once a model is chosen, forecast are produced recursively with re-estimation of the model.
The following table illustrates schematically how the forecast and forecast errors are produced.
Data / Estimated One-period-ahead One-period-ahead
information set coefficients Forecast Forecast error
2010 θ(2010) y2011,2010 e2011,2010 = y2011 y2011,2010
2011 θ(2011) y2012,2011 e2012,2011 = y2012 y2012,2011
2012 θ(2012) y2013,2012 e2013,2012 = y2013 y2013,2012
2013 θ(2013) y2014,2013 e2014,2013 = y2014 y2014,2013
2014 θ(2014) y2015,2014 e2015,2014 = y2015 y2015,2014
2015 θ(2015) y2016,2015 e2016,2015 = y2016 y2016,2015
2016 θ(2016) y2017,2016 e2017,2016 = y2017 y2017,2016
2017 θ(2017) y2018,2017 e2018,2017 = y2018 y2018,2017
where t denotes the information set consisting all information up to time t,
θ(t) the estimated coefficients
based on ?t, yt the trade balance of period (year) t, y?t+1,t the corresponding one-period-ahead forecast, and
et+1,t the corresponding one-period-ahead forecast error.
To forecast annual trade balance, there are several approaches, depending on the availability of data.
1. Use the annual data of trade balance.
2. Use the monthly data of trade balance.
3. Use the annual data of import and export.
4. Use the monthly data of import and export.
We restrict ourselves to trend plus seasonality models. Obviously, when the data/information set is restricted
to annual data, there is no need to include seasonality component.
The forecast errors can be used to access the performance of the model, with plots and summary statistics. In
particular, we can compute the mean squared prediction errors as
MSP E =e2
2011,2010 + e2
2012,2011 + ... + e2
2018,2017 8
Keep in mind that our focus is in the comparison of the performance of various modeling strategies, as well
as their in-sample model selection criteria and out-of-sample performance. Write up a report discussing your
forecast and your observations from the comparison of MSPEs and the plots.
Page 2 of 4Upload a zip file containing the whole folder of your work related to this project to Assignment corresponding
to project #1. The zip file should include the report (pdf format), the R script, the data file, the Word file or
LyX file (include graphic files if LyX is used), etc.
Often, students are tempted to write a lot. Please don’t. Try to write precisely and concisely. When you are
writing up the report, you should assume a reader from the industry (say, Economist Intelligence Unit). Always
ask: “We know what we are doing but do the readers know what we are doing?” “Is the report too long such
that readers will find it boring?” In your report, try to include the following sections:
1. An introduction. (One to two pages?)
What we plan to do in the paper and why we want to do it.
2. A brief description of the data. (One to two pages?)
A brief description of the variables.
Data source: the URLs or tickers or acronyms from the database such as Bloomberg, Datastream;
the definitions, the original source of the data, etc.
Sample period, and data frequency.
Reason(s) for the choice of the country.
3. Estimation. (Three to five pages?)
A brief description of the modeling strategies.
How we arrive at the chosen model, with supporting evidence.
4. Major findings of forecast comparison (Three to five pages?)
Our observations from the tables of statistics and plots.
5. Concluding remarks (One to two page?)
Major conclusion, policy implication (if any) and potential improvement of the analysis.
6. Reference section (One page?)
The report should have less than 16 pages, with at least 12 pt fonts, at least 1.5 line spacing, and at least 2 cm
of margins on each side. Page numbering, figure numbering and table numbering should be included. Some
students feel obliged to fill up all 16 pages. Please don’t. A shorter report is always preferred. It is about how
to present the idea and analysis to the readers clearly. For the same content and same clarity, readers always
prefer shorter reports.
R: R is a free software environment for statistical computing and graphics, available at http://www.rproject.org/.
Bloomberg: Bloomberg is available from our computer lab on 10/F of KK Leung Building. Students
are welcome to explore other reliable databases. Nonetheless, Bloomberg is preferred, and familiarity with
Bloomberg is a valuable assets in the business/research field.
DataStream: DataStream is available from our University Main Library. Familiarity with DataStream is
a valuable assets in the business/research field.
US Census Bureau: https://www.census.gov/foreign-trade/balance/index.html
Page 3 of 4Objectives of this assignment:
To practice how to forecast with simple time series models.
Writing up the report: tighten up the logic of discussion (why we are doing this and that).
Widen our horizon to see what happen in other countries (students have to work on a diverse set of
countries).
To see the advantages of different approaches of modeling strategies with different sets of data.
Grading rubrics (the following items may carry different weights):
Grading is mainly based on the report. The other materials are referred only when necessary.
Cover page: title of the report, the name and student ID number, and date.
Basic formatting: page numbering, equation number, table numbering, figure numbering; table title, figure
title.
Discussion associated with plots or tables. If you include a plot, make sure you discuss it.
Whether the R script and data file are adequate to regenerate the results used in the paper
Data description / Data sources
Properly labeled tables and figures (Clear titles); whether notes to tables / figures are included
Adequate guidance to readers in understanding the paper
Writing: Grammar, organization, transition from one paragraph to the next, etc.
Proper citations and references
Motivation / Policy implications / Potential use of the analysis
Are claims properly supported with evidence and statistical logic?
Discussion of the linkage of the paper to policy implications