---
output: github_document
---

<!-- README.md is generated from README.Rmd. Please edit that file -->

```{r, echo = FALSE}
knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>",
  fig.path = "README-"
)
```

# PointFore

The goal of PointFore is to estimate specification models for the state-dependent level of an optimal quantile/expectile forecast.

Wald Tests and the test of overidentifying restrictions are implemented. Plotting of the estimated specification model is possible.

Based on "Interpretation of Point Forecasts with unknown directive" by Patrick Schmidt, Matthias Katzfuss, and Tilmann Gneiting, 2018.

## Installation

You can install PointFore from github with:

```{r gh-installation, eval = FALSE}
# install.packages("devtools")
devtools::install_github("Schmidtpk/PointFore")
```

## Example

This is a basic example which shows you how to evaluate which quantile is forecasted by the Greenbook GDP forecasts:

```{r example}
library(PointFore)

res <- estimate.functional(Y=GDP$observation,
                           X=GDP$forecast,
                           instruments = c("X","lag(Y,2)"))

summary(res)

plot(res)
```

On average the forecast is over-optimistic with a forecasted quantile of `r round(res$gmm$coefficients[1],digits=2)`. The J-test rejects optimality for this model.

In the next step, we apply a more general model, where the forecasted quantile depends on the current forecast via a linear probit model.

```{r example with state-dependence}
res <- estimate.functional(Y=GDP$observation,X=GDP$forecast,
                           model=probit_linear,
                           instruments = c("X","lag(Y,2)"),
                           stateVariable = GDP$forecast)



summary(res)
plot(res)
```

We see that the forecast is overly optimistic in times of high growth. For this model we cannot reject optimality with a p-value of `r round(summary(res$gmm)$stest$test[2],digits=3)` in the J-Test of overidentifying restrictions.
