This is the assignments by using R-studio.

profileShelby1
ch20_hwk.pdf

R Homework for Chapter 20

Coffee Prices 2013

Coffee is the world’s second largest legal export commodity (after oil) and is the second largest source of foreign exchange for developing nations.The Unite States consumes about one-fifth of the world’s coffee. The International Coffee Organization (ICO) computes a coffee price index using Colombian, Brazilian, and a mixture of other coffee data. Data are provided for the daily ICO price index (in US dollars) from January 2013 to April 2013.

You can find the data file on Blackboard. Download it and put it in the same folder as your R program file. Then, use the following command to read the data coffee <- read.table('Coffee_prices_2013.txt', sep = '\t', header = TRUE)

1. Make a time series plot (not scatterplot) of price against time. Use “Coffee Price” and “Time” as label for y-axis and x-axis, respectively. Which time series components are evident from the plot?

2. Smooth the coffee price series using simple moving averages (SMA) of length 2 and 8. Add the two smoothed curves (one in red and one in green) to the plot made in (a) and compare them.

3. Apply single exponential smoothing (SES) to the coffee price series with weights α = 0.8 and α = 0.2, respectively. Add the two smoothed curves (one in orange and one in purple) to the plot made in (a) and compare them.

4. Find autocorrelation between the original time series and each of the first 5 lags. Then, fit an autoregressive model with the lags whose autocorrelations are greater than 0.8. Write down the fitted model and add the smoothed curve in blue to the plot made in (a). Which lag does the model depend on most? Why?

5. Suppose we know that the next value in the series was, in fact, 138.90. Compute the corresponding absolute percentage error (APE) for each of the models you have fitted before. Which model gives us the best prediction?

1

  • Coffee Prices 2013