R for Economic Research

Essential tools for modern economic analysis

J. Renato Leripio


Oct, 2023


Economic Research has increasingly benefited from programming in order to automate processes and improve analyzes. However, the teaching of economics has lagged significantly behind in this aspect. This results in a large number of professionals who neither know how to implement their routines efficiently nor how to do so on an adequate scale to meet day-to-day demands, particularly in the financial market.

R for Economic Research is my contribution to those who have a basic knowledge of R programming but still lack the necessary tools to carry out professional economic analysis. This is an intermediate-level book where the reader will find shortcuts to start working on a variety of tasks and also valuable references to delve into the details of more complex topics.

The reasoning behind the book can be described as follows.

Modern economic research requires a solid knowledge of a programming language. In fact, with a growing set of data now available through APIs it is possible to produce automated analyzes almost instantly using efficient techniques. In addition, unstructured data only becomes true information if correctly handled. I chose R because I strongly believe that Tidyverse is unrivaled as a data science workflow.

It does require more than just programming. Indeed, I have interviewed several applicants who were quite proficient in programming but lacked knowledge of basic topics on applied time series. For example, they didn’t know how to perform seasonal adjustment nor how to deflating nominal to real values. Filling in these gaps is crucial.

Knowledge about forecasting is vital. I’m definitely not talking about state-of-the-art machine learning models. In fact, most problems can be addressed with traditional statistical methods. Setting up the workflow to generate reliable forecasts is the relevant skill here.

I can’t help but talk about economic modelling. Estimating the relationship between economic variables and making projections is the core business of those who work with economic research. Despite being a topic that requires theoretical and applied training beyond the scope of this book, I believe that showing how to set up the framework for these models is a valuable contribution for those who want to start in the field.

Taking it to the next level. Some tools allow us to considerably expand our possibilities. Learning how to build and estimate state-space models is undoubtedly a big step forward in becoming a senior analyst.

I really hope that you enjoy reading this book and that it can benefit you in your career.

Also, I would be very happy to receive suggestions and feedback via e-mail (leripiorenato@gmail.com).


First and foremost, I’d like to thank all those who generously contribute to the R community – whether it’s developing packages, free content, or answering questions on Stack Overflow. Most of my learning I owe to you, and this book is, to a large extent, a way of giving back.

I would also like to thank my therapist Fátima for all the emotional support on this journey. Writing this book was an act of making myself vulnerable in several ways: showing my skills publicly, writing in a language I am not a native speaker and much more. I certainly feel more confident today than when I started writing this book.

For the most part, I handled the technical aspects of this book myself. However, at certain times I was able to count on the help of very kind people. Fernanda Boldrini played such an important role in helping me with the cover image of this book. I certainly wouldn’t feel so comfortable with the outcome if it weren’t for her care.

Finally, I dedicate this book to my family. My mom Célia and my dad João Bosco who did everything they could to provide me with the education that made it possible to get here. My sister Nathália and her newborn boy João Gabriel, to whom I wish to set good examples.


All the data sets used in the examples will be soon released as an R package. In the meantime, the relevant data are stored in the folder named data in the book official repository on Github (https://github.com/leripio/R4ER).


J. Renato Leripio has almost 10 years of professional experience as a quantitative economist. He has worked in both the public and private sector and is currently a Lead Data Scientist at a large hedge fund in Brazil, in charge of developing tools to improve the accuracy of economic forecasts. He regularly participates in academic and corporate events, showing his work and debating the challenges in the field. For more information about him and his work, visit http://www.rleripio.com.


R for Economic Research: Essential tools for modern economic analysis by J. Renato Leripio is licensed under Attribution-NonCommercial-ShareAlike 4.0 International