Archive for the ‘Economics’ Category

Computing NEER, REER and TWI

Posted by Vitalie Ciubotaru

Notation conventions

I_{it} denotes the amount of imports from country i in period t.
I_{t} denotes total imports of the home country in period t. Strictly speaking, we don’t need total imports to compute the weights, but it is good to know the combined weight of the selected countries in the total (computing the shares of all trading partners is usually infeasible).

Definitions

Nominal EER

Nominal Effective Exchange Rate shows the average value of domestic currency against a pool of foreign currencies. A value higher than 1 means nominal appreciation of domestic currency.

\displaystyle{NEER_t = \prod_{i} (\frac {E_{i0}} {E_{it}})^{w_i}}
where:
E_{it} denotes the bilateral exchange rate of country i‘s currency in period t (direct quotation — units of domestic currency per unit of foreign currency).
w_{i} denotes the weight of country i and it’s currency in the index. Weights should sum up to unity.

Comment: We could lend more elegance to our formula if we use indirect quotation.

Real EER

Real Effective Exchange Rate shows the inflation-adjusted average value of domestic currency against a pool of foreign currencies. A value higher than 1 means real appreciation (i.e. an increase in the purchasing power) of domestic currency.

REER_t = NEER_t \cdot \frac {\displaystyle{P_t}} {\displaystyle{\sum_{i} (w_i P_{it})}}
where:
P_{t} denotes the home country’s price index in period t.
P_{it} denotes the price index of country i in period t.

Trade-Weighted Index

Trade-Weighted Index shows the average value of a pool of foreign currencies in terms adjusted for foreign inflation.

TWI_t = \displaystyle{\prod_{i}} E_{it}^{w_i} \cdot \displaystyle{\sum_{i}}(w_i P_{it})

TWI can be easily computed from NEER or REER:
TWI_t = \displaystyle{ \frac { \prod_{i} E_{i0}^{w_i}} {NEER_t} } \cdot \displaystyle{\sum_{i}}(w_i P_{it})

or

TWI_t = \displaystyle{ \frac { \prod_{i} E_{i0}^{w_i}} {REER_t} } \cdot P_t

Output gap, polynomial trends and gretl

Posted by Vitalie Ciubotaru

A while ago I needed to estimate Moldova’s output gap. The only data series that covered a long enough period of time and had quarterly frequency was gross domestic product. It can be downloaded from the online database of Moldova’s National Bureau of Statistics. So I used quarterly data on Moldova’s GDP and employed Gretl. In order to model the potential level of output I chose a third-order polynomial trend.

1. Get the data and save it as CSV file. The file should contain two columns: the dates and the values.
2. Import your data to gretl (File -> Open data -> Import -> Text/CSV). If the datafile is formatted properly, no additional treatment is required. Otherwise, one might need to explicitly specify the dataset structure, frequency, and the starting and ending dates.
open /path/to/your/file.csv
setobs 4 1995:1 --time-series

3. Generate the time index and it’s powers. Since I estimated the third-order polynomial trend, I needed squares and cubes of the time index:
genr index
genr index_2 = index*index
genr index_3 = index*index*index

4. Run the regression. In my case it looked like this:
ols gdp const index index_2 index_3
5. Retrieve the coefficients for further use. For example, I wanted to compare them to what MS Excel and Libreoffice Calc compute when creating trends in their charts:
b = $coeff
6. Retrieve the absolute values of the deviation from trend (the output gap in my case):
gap = $uhat
To see the result, one can type something like:
gnuplot gap --time-series --with-lines
7. Compute the fitted values, i.e. the trend itself:
trend = gdp - gap
To see the input data and the trend line on one graph, one can type something like:
gnuplot gdp trend --with-lines --time-series

Here is my result:

GDP polynomial trend

GDP polynomial trend

Invoicing currencies?

Posted by Vitalie Ciubotaru

Still wondering why MDL is pegged to USD [only]. Are there any data on what currencies are used in Moldova’s foreign trade? The last source seems to be the Balance of Payments for 2001, which just states the share of freely convertible currencies. Not too much really…

Searching for data is always frustrating. While updating (or rather extending it back into the past) my personal database on CPI inflation I had to make my way through the jungle of different formats, time-spans, frequencies etc. that come from different statistical bodies (by the way, of all statistical agencies I checked out these days, UK’s Office for National Statistics is the weirdest! Just my humble opinion, of course).

When there was just a couple of gaps left, I turned to Inflation.eu. They got a nice web-site and, more importantly, they got data I needed. Unfortunately, there was no easy way to export these data — one has to select part of the page, paste it somewhere and clean it of rubbish like text and percentage marks. It would take ages to rip all those sparse figures … but wait, I got a perfect toolkit for this kind of job. After five minutes of “googling” and fine-tuning the tools my one-line monster script was ready. Here’s how it looks:

for i in {2006..2011}; do curl -s http://www.inflation.eu/inflation-rates/poland/historic-inflation/cpi-inflation-poland-${i}.aspx | grep "nbsp;%" | cut -d"<" -f2 | cut -d">" -f2 | cut -d"&" -f1 | awk 'NR % 2 == 0' | sed 's/$/+100/' | bc -l; done

This script crawls through all webpages that contain the data I need, searches for my figures, formats them into a human-readable form and displays them. Of course, it can be further improved, say, to add a date column, write data to a file etc., but it’s already done the job and I probably won’t need it any time soon. I just couldn’t resist bragging a bit about my script (and praising the unix-way, of course!).

Understanding gnuplot

Posted by Vitalie Ciubotaru

When it comes to graphs, gretl has a very good interface. This is why sometimes I open gretl not for another regression, but simply to create another graph. On the other hand, the default settings for graphs in gretl are a sort of “one-size-fits-all”, so I often have to fine-tune the graphs before saving them as image. The need to to repeat many steps for every single graph can be annoying — e.g. I save the graph, close gretl and then discover that the title is mis-spelt.

In order to avoid these unnecessary repetitions I looked at gnuplot. gnuplot is a plotting software that can produce very expressive graphs. Actually, it’s gnuplot that produces graphs for gretl, but calling gnuplot directly, without relying at gretl, gives us much more control over the final result.

For the sake of exersice, I used data on Moldovan consumer prices, which I use in my research, to test-drive gnuplot. A bref look at the data:

$ cat cpi_monthly.csv
1994M01,0.173112617709,0.239803992207,0.094400675421,0.358373500574
1994M02,0.195550183875,0.221537226460,0.167194062267,0.239803442394
1994M03,0.095322755336,0.094381285981,0.072302758560,0.193910185446
1994M04,0.048778187476,-0.008989342544,0.065817779879,0.151001315845
1994M05,0.026649336222,0.021757413856,0.022738045009,0.053564944099
1994M06,0.026639092138,0.035333466639,0.012894161453,0.010939501922
1994M07,0.021790046158,-0.015093378960,0.042128161494,0.073228745712
...

and so on up to December 2011.

OK, let’s plot the last eleven years.
$ gnuplot
set datafile separator ","
set xdata time
set timefmt "%YM%m"
set xrange ["2000M01":"2011M12"]
set format x "%Y"
set yr [-.05:.05]
set xzeroaxis lt 0 lw 1 linecolor rgb "black"
set style line 1 lt 1 lw 1 pt 3 linecolor rgb "blue"
set title 'CPI inflation (log monthly changes), 2000-2011'
plot "cpi_monthly.csv" using 1:2 notitle w line ls 1

Yes, if one creates graphs from time to time, then it will look like too much code. However, if one needs to produce many graphs with the same look-and-feel, one can reuse this code for multiple times, with only minor changes. Below is the result (click to enlarge).

CPI inflation (log monthly change), 2000-2011

CPI inflation (log monthly change), 2000-2011

It’s been quite some time since I started studying Moldovan monetary phenomena. Before diving into the long list of unanswered questions, let me summarize my humble findings. So, the things I know:

  1. National Bank of Moldova is targeting inflation (just as it declared).
  2. Although officially MDL is a [dirty] floating currency, National Bank of Moldova implicitly maintains a soft peg to the US dollar. Theoretically, doing so makes it more difficult for the NBM to [efficiently] target inflation.
  3. Moldova’s capital account is far from being liberalized. From the point of view of the “impossible trinity”, imperfect cross-border mobility of capital allows monetary authorities to enjoy exchange rate stability and monetary independence at the same time.

The things I do not know are more numerous.

  1. The parameters of the peg — the rate of depreciation, exchange rate variability etc. — changed over time, but regime changes could not be associated with any known events. What caused these regime switches?
  2. Contrary to expectations, the euro has no significant weight in the peg. Why a dollar peg?
  3. NBM neither announces, nor reports about it’s foreign exchange interventions. Only monthly data on interventions are available. What is the objective of these transactions — “maintain the trend”, “return to the trend”, “reverse the trend”, “increase the official reserves”, or? Why are the interventions performed in a secret manner? What is the objective of pegging, in general — to protect official reserves, to protect forex-denominated investments, to secure forex-denominated liabilites, to stimulate foreign trade, or?
  4. What is the relationship between exchange rates and domestic prices? A conventional wisdom suggests that the pass-through of exchange rates to import prices, and further to inflation, must be very high.
  5. Is monetary policy really independent? Is there an explicit policy function? Does it include exchange rates?

Dynamic inconsistency

Posted by Vitalie Ciubotaru

Every working day I leave my lab at about 5pm and head for kinderkarten to pick up my kid. Each time, I leave with a strong intension to return later and stay until late. However, after I reach home, my plans often change — I feel tired, or it rains outside, or there’s something to do at home etc. — and I do not return to the lab. A typical example of dyniamic inconsistency.

When I leave the lab, I know that I might not be willing to return until next day, so I try to “commit” myself somehow. For example, I leave my computer turned on and waiting for me to return. Mind you, it’s not idling — it’s usually left to do distributed computing for the folding@Home project. Thus, every time I have a incentive to be back soon.

Teoretically, voluntarily constraining oneself’s choices is not an optimal solution, but what is?

Research progress: SDR

Posted by Vitalie Ciubotaru

Used CHF as numeraire, moved SDR into the list of potential anchors and added GBP “just-in-case”. Nothing new :-( (more…)

Research progress: GBP

Posted by Vitalie Ciubotaru

Intro

I am currently writing an article on the exchange rates in Moldova. A draft version of the article, entitled “Identifying the exchange rate regime in the Republic of Moldova”, was presented at the “2nd Osaka Workshop on International Economics” on February 11 this year and received a lot of feedback. It can be downloaded from SSRN (link here). (more…)