Nonparametric Workshop in R
University of Pretoria, South Africa, August 14-18, 2023

Overview

In this workshop you will be guided through the application of basic nonparametric kernel methods using R (e.g., kernel regression), and you will also be introduced to recently released tools for conducting reproducible research (Quarto).

No background knowledge of either nonparametric analysis or the R programming language will be assumed.

The nonparametric methods used in this workshop will be based on Racine (2019).

Though the workshop will introduce you to the R programming language (What is R?) for conducting nonparametric kernel analysis (What is Kernel Regression?), we will also be using Quarto (What is Quarto?) and RStudio (What is RStudio?) which, combined, form an extremely powerful framework for streamlining a range of tasks (in fact, this website was created using Quarto and RStudio and is hosted on GitHub Pages). All of the software we use is available for free and is open source.

Pre-Workshop Tasks

Participants are encouraged, if possible, to bring a laptop with them pre-loaded with the free and open source software listed below (even though desktop computers will be available for use in the workshop). Doing so will guarantee that you will leave the workshop fully equipped to conduct your own analysis using the methods that we will cover. Installation instructions follow, and please pay particular attention to the issues highlighted below.

Important
  • Quarto was recently released, has evolved rapidly, and is now quite stable (Version 1.0 was released publicly July 28 2022 - see Quarto Announcement)

  • However, older versions of RStudio do not support Quarto (only RStudio v2022. 07.1 and later includes support for editing and preview of Quarto documents)

  • Therefore, it is strongly advised that, even if you have versions of R and RStudio already installed on your system, you install the most recent versions for this workshop

Workshop participants should come with the following applications (i.e., R, RStudio, and \(\rm\TeX\)) and R libraries (i.e., the R package np) pre-installed on your laptop computer:

  1. R and RStudio (see posit.co/download/rstudio-desktop)

    Important
    • You must install R before installing RStudio (otherwise RStudio will not function, so the order of installation is critical)

    • If you are using macOS (i.e., an Apple laptop), when you run the RStudio installer you need to manually copy/drag the RStudio app to the Applications folder

  2. \(\rm\TeX\) (Windows users see miktex.org, macOS users see www.tug.org/mactex, Linux/UNIX users see www.tug.org/texlive)

  3. The R package np (see installation instructions in Item 2. below, further details to appease your inner geek can be found on CRAN CRAN.R-project.org/package=np)

Test Your Installation

To test whether or not your install of the above is working prior to the workshop, you might try the following:

  1. Download the files workshop.qmd and workshop.bib contained in the zip file workshop.zip (see the download link below), place them in a folder, open the file workshop.qmd using the latest version of RStudio, make sure your working directory is set to the source file location (in RStudio, look for the menus at the top of the screen, then select "Session" -> "Set Working Directory" -> "To Source File Location")

  2. Install the np package (using the latest version of RStudio select the "Packages" tab, lower right pane by default, click the "install" icon, enter np in the "Packages" field, the click "Install")

  3. In the editor pane (upper left pane by default which opens when you opened the file workshop.qmd) click the "Render" icon

If the latest versions of RStudio, R, \(\rm\TeX\) and the np package are correctly installed, clicking the "Render" icon in RStudio should produce output that resembles the following PDF: workshop.pdf

Issues

If you succeed at the above, congratulations, but if this does not work for you prior to the workshop please don’t worry, as one way or another we will figure it out either before or after the workshop session (i.e., don’t stress out if this doesn’t work, just do what you can, and as a last resort you have free access to RStudio Cloud)

Note
  • Strictly speaking, you do not have to install RStudio to take advantage of Quarto, though for this workshop you will need to install R, and RStudio will be used throughout (RStudio is an integrated development environment while R is the engine for running R code, so strictly speaking you can avoid using RStudio if you wish)

  • There is a standalone command line interface (CLI) version of Quarto available for the adventurous, say, if you don’t want to use RStudio or wish to use, e.g., VS code or some other editor. The beauty of starting with RStudio is that you can get going immediately while other interfaces will require more work and tinkering on your part.

  • See quarto.org/docs/get-started if a CLI version of Quarto is something that interests you

Illustrations, Examples, etc.

The “Gallery of Code” website (jeffreyracine.github.io/gallery) is intended to provide those interested in semi- and nonparametric methods with illustrative examples that go far beyond what we could possibly cover in the time allotted for this workshop. I hope you find something of interest in the gallery.

Additional Resources, Books etc.

Additional resources (solutions manuals, code to accompany books, monographs, etc.) can be found at jeffreyracine.github.io/research.

References

Racine, Jeffrey S. 2019. An Introduction to the Advanced Theory and Practice of Nonparametric Econometrics: A Replicable Approach Using R. Cambridge University Press. https://doi.org/10.1017/9781108649841.