Solving Rational Expectations models on the Raspberry Pi
I recently bought a Raspberry Pi to play around with. The purpose: I wanted a cheap testing ground for inspecting - and possibly compromising(!) - the system files. My primary laptop is quite expensive and I wanted to protect it from my tomfoolery. With the Pi, I can road test without fear of losing something of value.
After getting the Pi set up and connected to an old unused monitor and mouse & keyboard, I decided to go beyond using it for music, radio, video, and checking emails. The screenshot below shows my Desktop on the Pi.
What was next you ask? The world of R programming, of course! And more specifically, solving multivariate linear rational expectations models using R on the Pi. Could it do it?
The first thing to do was install R. That was easy - a simple one liner from the command line (sudo apt-get install r-base). With that done, the next thing to do was write the code and run the program. The screenshot below shows R running on the Pi.
I won't talk about the code in detail here, but I essentially ported Binder and Pesaran's program for solving multivariate linear rational expectations models using their fully recursive method (as opposed to earlier methods, including the quadratic determinental equation method). For a good review of the performance of the various methods (Blanchard-Kahn, Sims, Uhlig, etc.), Gary Anderson at the FRB has a nice paper here.
The program I wrote is called bpfrm-ver1.R and this is saved in a folder called REModels on my desktop. The program sets up a 7 equation RBC model and then solves the model using Binder and Pesaran's method (Section 4.2 paper 1997).
To run the program, I used the R CMD BATCH command from the terminal. This runs the R script. After the program is finished running, it creates two files; an .Rout file and a collection of charts called Rplots.pdf. All of this is summarized in the screenshot below which shows the bash commands in the terminal.
The program took about 2 minutes to run. The plots were then ready to be viewed. These are shown in the screenshots below.
So, the curiosity has been satisfied. It is, indeed, possible to solve these models using R on the Raspberry Pi. Not bad at all!
Hi, Thore. The model is expressed in terms of matrices. There's no model file or model language as such - as there is for other software like dynare or gEcon. Following Pesaran's recommendation, the model - after log-linearization and calculating the steady state values - is cast into a system. From there, it's basically a set of simple matrix computations. The method is fast, easy to implement, and doesn't require eigenvalue-eigenvector decompositions. The method also doesn't require any dependencies, that's how straightforward it is. I'm writing notes on the subject and I'll probably roll them out with examples - or write a package is the most likely thing. So I'll make the files available. Feel free to iterate via email.
Nice job. I'm curious about the solver you used. How do you formulate the model in R? Any implementation I know relies on some form of C syntax (gEcon)