In: Statistics and Probability
) The most recent 30 days of the price per gallon of regular unleaded gas is in the file. Using R code Please answer the following questions.
a. Compute a forecast for the next day’s prices using a 3-day Moving Average model. What is the forecast? What is the MSE for the last five observations?
b. Can you reduce the MSE for the last five observations by changing the movingaverage window? (Hint: Try 4-10 day windows)
c. Compute a forecast for the next day’s price by using exponential smoothing with α=0.25. What is the forecast? What is the MSE for the last five observations?
d. Can you improve the MSE for the last five observations by changing the smoothing constant α?
t | Observed |
1 | 2.53 |
2 | 2.35 |
3 | 1.91 |
4 | 2.20 |
5 | 1.77 |
6 | 3.26 |
7 | 1.63 |
8 | 2.73 |
9 | 2.41 |
10 | 2.72 |
11 | 2.87 |
12 | 1.49 |
13 | 2.92 |
14 | 3.53 |
15 | 2.74 |
16 | 2.46 |
17 | 2.60 |
18 | 2.10 |
19 | 2.01 |
20 | 2.14 |
21 | 2.03 |
22 | 2.68 |
23 | 2.59 |
24 | 2.99 |
25 | 2.94 |
26 | 1.77 |
27 | 2.62 |
28 | 3.19 |
29 | 3.01 |
30 | 2.10 |
a. Compute a forecast for the next day’s prices using a 3-day Moving Average model. What is the forecast? What is the MSE for the last five observations?
t | Observed | Forecast | Error² |
1 | 2.53 | ||
2 | 2.35 | ||
3 | 1.91 | ||
4 | 2.2 | 2.26 | 0.00 |
5 | 1.77 | 2.15 | 0.15 |
6 | 3.26 | 1.96 | 1.69 |
7 | 1.63 | 2.41 | 0.61 |
8 | 2.73 | 2.22 | 0.26 |
9 | 2.41 | 2.54 | 0.02 |
10 | 2.72 | 2.26 | 0.21 |
11 | 2.87 | 2.62 | 0.06 |
12 | 1.49 | 2.67 | 1.38 |
13 | 2.92 | 2.36 | 0.31 |
14 | 3.53 | 2.43 | 1.22 |
15 | 2.74 | 2.65 | 0.01 |
16 | 2.46 | 3.06 | 0.36 |
17 | 2.6 | 2.91 | 0.10 |
18 | 2.1 | 2.60 | 0.25 |
19 | 2.01 | 2.39 | 0.14 |
20 | 2.14 | 2.24 | 0.01 |
21 | 2.03 | 2.08 | 0.00 |
22 | 2.68 | 2.06 | 0.38 |
23 | 2.59 | 2.28 | 0.09 |
24 | 2.99 | 2.43 | 0.31 |
25 | 2.94 | 2.75 | 0.03 |
26 | 1.77 | 2.84 | 1.14 |
27 | 2.62 | 2.57 | 0.00 |
28 | 3.19 | 2.44 | 0.56 |
29 | 3.01 | 2.53 | 0.23 |
30 | 2.1 | 2.94 | 0.71 |
31 | 2.77 | ||
MSE | 0.53 |
b. Can you reduce the MSE for the last five observations by changing the movingaverage window? (Hint: Try 4-10 day windows)
t | Observed | Forecast | Error² |
1 | 2.53 | ||
2 | 2.35 | ||
3 | 1.91 | ||
4 | 2.2 | ||
5 | 1.77 | 2.25 | 0.23 |
6 | 3.26 | 2.06 | 1.45 |
7 | 1.63 | 2.29 | 0.43 |
8 | 2.73 | 2.22 | 0.27 |
9 | 2.41 | 2.35 | 0.00 |
10 | 2.72 | 2.51 | 0.05 |
11 | 2.87 | 2.37 | 0.25 |
12 | 1.49 | 2.68 | 1.42 |
13 | 2.92 | 2.37 | 0.30 |
14 | 3.53 | 2.50 | 1.06 |
15 | 2.74 | 2.70 | 0.00 |
16 | 2.46 | 2.67 | 0.04 |
17 | 2.6 | 2.91 | 0.10 |
18 | 2.1 | 2.83 | 0.54 |
19 | 2.01 | 2.48 | 0.22 |
20 | 2.14 | 2.29 | 0.02 |
21 | 2.03 | 2.21 | 0.03 |
22 | 2.68 | 2.07 | 0.37 |
23 | 2.59 | 2.22 | 0.14 |
24 | 2.99 | 2.36 | 0.40 |
25 | 2.94 | 2.57 | 0.14 |
26 | 1.77 | 2.80 | 1.06 |
27 | 2.62 | 2.57 | 0.00 |
28 | 3.19 | 2.58 | 0.37 |
29 | 3.01 | 2.63 | 0.14 |
30 | 2.1 | 2.65 | 0.30 |
31 | 2.73 | ||
MSE | 0.38 |
c. Compute a forecast for the next day’s price by using exponential smoothing with α=0.25. What is the forecast? What is the MSE for the last five observations?
t | Observed | Forecast | Error² |
1 | 2.53 | ||
2 | 2.35 | 2.53 | 0.03 |
3 | 1.91 | 2.49 | 0.33 |
4 | 2.2 | 2.34 | 0.02 |
5 | 1.77 | 2.31 | 0.29 |
6 | 3.26 | 2.17 | 1.18 |
7 | 1.63 | 2.44 | 0.66 |
8 | 2.73 | 2.24 | 0.24 |
9 | 2.41 | 2.36 | 0.00 |
10 | 2.72 | 2.37 | 0.12 |
11 | 2.87 | 2.46 | 0.17 |
12 | 1.49 | 2.56 | 1.15 |
13 | 2.92 | 2.29 | 0.39 |
14 | 3.53 | 2.45 | 1.16 |
15 | 2.74 | 2.72 | 0.00 |
16 | 2.46 | 2.73 | 0.07 |
17 | 2.6 | 2.66 | 0.00 |
18 | 2.1 | 2.64 | 0.30 |
19 | 2.01 | 2.51 | 0.25 |
20 | 2.14 | 2.38 | 0.06 |
21 | 2.03 | 2.32 | 0.09 |
22 | 2.68 | 2.25 | 0.19 |
23 | 2.59 | 2.36 | 0.05 |
24 | 2.99 | 2.42 | 0.33 |
25 | 2.94 | 2.56 | 0.15 |
26 | 1.77 | 2.65 | 0.78 |
27 | 2.62 | 2.43 | 0.03 |
28 | 3.19 | 2.48 | 0.50 |
29 | 3.01 | 2.66 | 0.12 |
30 | 2.1 | 2.75 | 0.42 |
31 | 2.58 | ||
MSE | 0.37 |
d. Can you improve the MSE for the last five observations by changing the smoothing constant α?
t | Observed | Forecast | Error² |
1 | 2.53 | ||
2 | 2.35 | 2.53 | 0.03 |
3 | 1.91 | 2.49 | 0.34 |
4 | 2.2 | 2.38 | 0.03 |
5 | 1.77 | 2.34 | 0.33 |
6 | 3.26 | 2.23 | 1.07 |
7 | 1.63 | 2.43 | 0.65 |
8 | 2.73 | 2.27 | 0.21 |
9 | 2.41 | 2.36 | 0.00 |
10 | 2.72 | 2.37 | 0.12 |
11 | 2.87 | 2.44 | 0.18 |
12 | 1.49 | 2.53 | 1.08 |
13 | 2.92 | 2.32 | 0.36 |
14 | 3.53 | 2.44 | 1.19 |
15 | 2.74 | 2.66 | 0.01 |
16 | 2.46 | 2.67 | 0.05 |
17 | 2.6 | 2.63 | 0.00 |
18 | 2.1 | 2.63 | 0.28 |
19 | 2.01 | 2.52 | 0.26 |
20 | 2.14 | 2.42 | 0.08 |
21 | 2.03 | 2.36 | 0.11 |
22 | 2.68 | 2.30 | 0.15 |
23 | 2.59 | 2.37 | 0.05 |
24 | 2.99 | 2.42 | 0.33 |
25 | 2.94 | 2.53 | 0.17 |
26 | 1.77 | 2.61 | 0.71 |
27 | 2.62 | 2.44 | 0.03 |
28 | 3.19 | 2.48 | 0.50 |
29 | 3.01 | 2.62 | 0.15 |
30 | 2.1 | 2.70 | 0.36 |
31 | 2.58 | ||
MSE | 0.35 |