---
title: "Exchange Rate Regime Analysis for the Indian Rupee"
author: "Achim Zeileis, Ajay Shah, Ila Patnaik"
output:
  rmarkdown::html_vignette:
    highlight: monochrome
abstract: >
  We investigate the Indian exchange rate regime starting from 1993
  when trading in the Indian rupee began up to the end of 2007. This reproduces
  the analysis from @fxregime which
  includes a more detailed discussion.
bibliography: fxregime.bib
vignette: >
  %\VignetteIndexEntry{Exchange Rate Regime Analysis for the Indian Rupee}
  %\VignetteEngine{knitr::rmarkdown}
  %\VignetteDepends{graphics, stats, zoo, sandwich, strucchange}
  %\VignetteKeywords{INR, foreign exchange rates, structural change, dating}
  %\VignettePackage{fxregime}
---

```{r cleanup, include=FALSE}
cleanup <- TRUE
library("fxregime")
knitr::opts_chunk$set(
  engine = "R",
  collapse = TRUE,
  comment = "##",
  message = FALSE,
  warning = FALSE,
  echo = TRUE
)
```

## Analysis

Exchange rate regime analysis is based on a linear regression model
for cross-currency returns. A large data set derived from exchange
rates available online from the US Federal Reserve
at <https://www.federalreserve.gov/releases/h10/Hist/> is
provided in the `FXRatesCHF` data set in `fxregime`.

```{r preliminaries}
library("fxregime")
data("FXRatesCHF", package = "fxregime")
```

It is a `zoo` series containing `r ncol(FXRatesCHF)` daily time series from
`r start(FXRatesCHF)` to `r end(FXRatesCHF)`. The columns correspond to the prices for various
currencies (in ISO 4217 format) with respect to CHF as the unit currency.

India is an expanding economy with a currency that has been receiving increased
interest over the last years. India is in the process of evolving
away from a closed economy towards a greater integration with the
world on both the current account and the capital account. This has
brought considerable stress upon the pegged exchange rate regime.
Therefore, we try to track the evolution of the INR exchange rate regime since trading
in the INR began in about 1993 up to the end of 2007. The currency basket employed consists of
the most important floating currencies (USD, JPY, EUR, GBP).
Because EUR can only be used for the time
after its introduction as official euro-zone currency in 1999, we employ
the exchange rates of the German mark (DEM, the most important currency in the EUR zone)
adjusted to EUR rates. The combined returns are denoted DUR below in `FXRatesCHF`:


```{r inr-data}
inr <- fxreturns("INR", frequency = "weekly",
  start = as.Date("1993-04-01"), end = as.Date("2008-01-04"),
  other = c("USD", "JPY", "DUR", "GBP"), data = FXRatesCHF)
```

Weekly rather than daily returns are employed to reduce
the noise in the data and alleviate the computational burden of the dating algorithm
of order $O(n^2)$.

Using the full sample, we establish a single exchange rate regression only to show that
there is not a single stable regime and to gain some exploratory insights from the 
associated fluctuation process. 

```{r inr-fitting}
inr_lm <- fxlm(INR ~ USD + JPY + DUR + GBP, data = inr)
```

As we do not expect to be able to draw valid conclusions
from the coefficients of a single regression, we do not report the coefficients and
rather move on directly to assessing its stability using the associated empirical
fluctuation process.

```{r inr-hprocess, fig.height=9, fig.width=9, fig.cap="Historical fluctuation process for INR exchange rate regime."}
inr_efp <- gefp(inr_lm, fit = NULL)
plot(inr_efp, aggregate = FALSE, ylim = c(-1.85, 1.85))
```

This shows that there is significant instability
because two processes (intercept and variance) exceed their 5% level boundaries. More 
formally, the corresponding double maximum can be performed by

```{r inr-sctest}
sctest(inr_efp)
```

This $p$~value is not very small because there seem to be several changes in various parameters.
A more suitable test in such a situation would be the Nyblom--Hansen test

```{r inr-sctest2}
sctest(inr_efp, functional = meanL2BB)
```

However, the multivariate fluctuation process is interesting as a visualization of the
changes in the different parameters. The process for the variance $\sigma^2$ has the most
distinctive shape revealing at least four different regimes: at first, a variance that is lower than the
overall average (and hence a decreasing process), then a much larger variance (up to the boundary
crossing), a much smaller variance again and finally a period where the variance is roughly
the full-sample average. Other interesting processes are the intercept and maybe the USD
and DUR. The latter two are not significant but have some peaks revealing a decrease and
increase, respectively, in the corresponding coefficients.

To capture this exploratory assessment in a formal way, a dating procedure is conducted
for $1, \dots, 10$ breaks and a minimal segment size of $20$ observations. 

```{r inr-dating, eval=FALSE}
inr_reg <- fxregimes(INR ~ USD + JPY + DUR + GBP,
  data = inr, h = 20, breaks = 10)
```

```{r inr-dating1, echo=FALSE}
if(file.exists("inr_reg.rda")) load("inr_reg.rda") else {
inr_reg <- fxregimes(INR ~ USD + JPY + DUR + GBP,
  data = inr, h = 20, breaks = 10)
save(inr_reg, file = "inr_reg.rda")
}
if(cleanup) file.remove("inr_reg.rda")
```

The associated segmented negative log-likelihood
(NLL) and LWZ criterion. Both can be visualized via

```{r inr-breaks, fig.height=5, fig.width=6, fig.cap="Negative log-likelihood and LWZ information criterion for INR exchange rate regimes."}
plot(inr_reg)
```

NLL is decreasing quickly up to
$`r length(breakdates(inr_reg))`$ breaks with a kink
in the slope afterwards. Similarly, LWZ takes its minimum for
$`r length(breakdates(inr_reg))`$ breaks, choosing
a `r length(breakdates(inr_reg))+1`-segment model.
The confidence intervals corresponding to the breaks can be
obtained by

```{r inr-confint}
confint(inr_reg, level = 0.9)
```

showing that the start/end of segments with low variance can
be determined more precisely than for segments with high variance.

The parameter estimates for all segments can be queried via

```{r inr-coef}
coef(inr_reg)
```

The most striking observation from the segmented coefficients is that
INR was closely pegged to USD up to 
`r tail(breakdates(inr_reg), 1)` when it shifted to a
basket peg in which USD has still the highest weight but considerably
less than before.  Furthermore, the changes in $\sigma$ are
remarkable, roughly matching the exploratory observations from the
empirical fluctuation process. A more detailed look at the full summaries
provided below shows that the first period is a clear and
tight USD peg. During that time, pressure to appreciate was blocked by
purchases of USD by the central bank. The second period, including the
time of the East Asian crisis, saw a highly increased flexibility in
the exchange rates. Although the Reserve Bank of India (RBI) made
public statements about managing volatility on the currency market,
the credibility of these statements were low in the eyes of the
market. The third period exposes much tighter pegging again with low
volatility, some appreciation and some small (but significant) weight
on DUR. In the fourth period after March 2004, India moved away from
the tight USD peg to a basket peg involving several currencies with
greater flexibility (but smaller than in the second period). In this
period, reserves in excess of 20% of GDP were held by the RBI, and a
modest pace of reserves accumulation has continued.

```{r inr-refit}
inr_rf <- refit(inr_reg)
lapply(inr_rf, summary)
```


## Summary {#sec:summary}

For the Indian rupee, a `r length(breakdates(inr_reg))+1`-segment
model is found with a close linkage of INR to USD in the first three
periods (with tight/flexible/tight pegging, respectively) before
moving to a more flexible basket peg in spring 2004.

The existing literature classifies the INR is a _de facto_
pegged exchange rate to the USD in the period after April 1993. The results
above show the fine structure of this pegged exchange
rate; it supplies dates demarcating the four phases of the exchange
rate regime; and it finds that by the fourth period, there was a
basket peg in operation.


## References
