/
README.Rmd
110 lines (66 loc) · 3.79 KB
/
README.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
---
output: github_document
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "80%"
)
```
# fcrat
<!-- badges: start -->
<!-- badges: end -->
The goal of fcrat is to provide easy access to the methods of the paper "Testing Forecast Rationality for Measures of Central Tendency" by Timo Dimitriadis, Andrew Patton, and Patrick Schmidt.
## Installation
You can install the preliminary version of fcrat from Github with:
```{r install}
#install.packages("devtools")
#devtools::install_github("Schmidtpk/fcrat")
```
## Example
This is a basic example which shows you how to replicate some of the main findings of the paper. Let's try consider one-quarter ahead forecast of real GDP growth as released in the Greenbook by the Federal Reserve Board. For more information see `?GDP`. We test if the predictions are a rational mean, median or mode forecast:
The `test_central` function, applies rationality tests for the three functionals of central tendency: Mean, median, and mode. We have to specifiy the forecast x and the actual observations y.
```{r example}
library(fcrat)
test_central(x = GDP$FC.first,
y = GDP$Obs.recent)
```
The output depicts the p-values for each functional. The GDP forecast is consistent with a rational mean forecast, but partially inconsistent with a median or mode forecast (deduced from the p-values below 0.1).
One can specify the instrument choice as a list of characters describing each component. Above, we use the constant and the forecast as instruments, as in the main specification of the paper. It is also possible to check several instruments in one command:
```{r example2}
library(fcrat)
test_central(x = GDP$FC.first,
y = GDP$Obs.recent,
instruments = list(c("1","X"),
c("1","X","lag(X-Y)")))
```
# Test all convex combinations of mean, median, and mode
The `test_convex` function tests any convex combination of mean, median, and mode. The plot function can be used to illustrate the confidence sets.
## Income expectations from the Survey of Consumer Expectations
In this example, we consider the survey of consumer expectations. For more information see `?sce`. The income expectations reported in the labour market survey are rational mode forecasts, but inconsistent with mean or median forecasts.
```{r example3, message = FALSE}
library(fcrat)
# As in the paper, we drop observations that include forecasts or realizations of annualized income below $ 1,000 or above $ 1 million, which represent less than 1% of the initial sample. We also drop observations where the ratio of the realization to the forecast, or its inverse, is between 9 and 13, to avoid our results being affected by misplaced decimal points or by the failure to report annualized income (leading to proportional errors of around 10 to 12 respectively).
sce <- sce[sce$filter1 & sce$filter3,]
res <- test_convex(x = sce$expectation,
y = sce$income)
plot(res)
```
You can also include the p-values with the `plot_numbers` function.
```{r example3_numbers, message = FALSE}
plot_numbers(res)
```
## Are exchange rates rational?
In this example, we consider exchange rates as forecasts for the next trading day. For more information see `?exchange`. Here, we show the results for the exchange rate between the Euro and the Japanese Yen.
```{r example4}
library(fcrat)
data <- exchange[exchange$to== "JPY",]
res <- test_convex(x = data$fc,
y = data$realization,
instruments = c("1","lag(X-Y)"))
plot(res)
```
While the mean is in the confidence set (as postulated by the rational market hypothesis), the median and mode are rejected.