# Reference

## Contents

Look here over the course of the semester for resources, links, and tips on how to succeed in the course, how to write well, and other things of interest related to econometrics, data analysis, managing your worfklow, and using R.

## Tips for Success

**Take notes. On paper. Yes.**Studies show that using pen and paper trump taking notes on a device. The main reason is because*you cannot possibly write down everything I am saying by hand*. This forces you to selectively filter my lecture to its most essential and important components – an integral part of the learning and retention process. If you are taking notes on a laptop, you become a court stenographer, thoughtlessly transcribing everything I am saying. At the other extreme, do not assume*everything*is written in my lecture slides. My lecture slides are visuals and cues to organize the content both for me and for you. I try hard to make sure that I have few words on slides, and even fewer answers to problems.- My suggestion: print out my lecture slides in advance (or follow along on your device) and take additional notes by hand.

**At least skim all of the readings.**I give out readings for a reason, and that reason is not to bore you or waste your time. The truth is, as a beginner, you can’t rely on heuristics or memory to “fill in the blanks.” You need the readings to provide context to what I am saying in class. I cannot help you if you are not going to try. Any professor also will lose patience at short notice when it’s discovered you haven’t done the reading.**Do the homeworks**(if there are any). You might be surprised that I need to say this, but I do. Students that do not do the homeworks do poorly on exams, which often are similar to homework questions. Homeworks are*the best*practice for exams, they give you a sense of the relevant content areas that might come up, the type and style of questions that I ask, and you often get answer keys to help you “get inside my head” and study from. There is no good reason why you should have a low homework grade.**Work on assignments together and study together**. Recognize that you are not in this alone, and other students are just as anxious or uncertain as you are. More surprisingly, other students probably have some answers you are looking for, and you may have answers for some of their problems! You will learn better when you collaborate with others similar to you. More importantly, you don’t truly understand something unless you can explain it to others.Yes, that means I am doing a*ton*of learning every time I teach!

As a wise woman once told me “whomever is doing the talking is doing the learning.”**Learn how to learn**. The most important skill you learn in college is*how to learn*. Taking a course on a subject will*not*make you an expert on that subject. It a) helps you recognize that you do not know everything on that subject, and this prevents you from actively saying stupid things; and b) gives you enough context and skills to figure out how to*actually*fill those gaps. This is the actual skill that’s relevant in the real world.Yes, Google is your best friend. But you do not yet know how to ask the right questions, or understand what constitutes good answers.

## List of Math and R Appendices

The following list contains links to all appendices spread across the Class Notes pages:

**R**: Installing R and R Studio (Class 1.3)**R**: R Packages (Class 1.3)**R**: Getting Help for R (Class 1.3)**R**: Other Useful Commands to Know (Class 1.3)**R**: Style Guide for Coding (Class 1.3)**Math**: The Summation Operator (Class 2.1)**R**: Creating Mathematical Functions (Class 2.2)**R**: Graphing Mathematical Functions (Class 2.2)**R**: Bultin Statistical Functions (Class 2.2)**R**: Graphing Statistical Functions (Class 2.2)**Math**: Variance (Class 2.3)**Math**: Covariance (Class 2.3)**Math**: Correlation (Class 2.3)**R**: Calculating Correlation Example (Class 2.3)**Math**: Deriving the OLS Estimators (Class 2.4)**Math**: Algebraic Properties of OLS Estimators (Class 2.4)**Math**: Bias in \(\hat{\beta_1}\) (Class 2.4)**Math**: Proof of the Unbiasedness of \(\hat{\beta_1}\) (Class 2.4)

## Installing R and R Studio

- Install R from CRANThe Comprehensive R Archive Network

by clicking “Download R” (or the CRAN link under Downloads on the left menu). This will take you to a mirrors page, where you can select a location in the U.S. and download a copy of R - Install R Studio (Desktop Version), choose the “Free” option

## R Packages

Packages come from multiple sources.

The polished, publicly released versions are found on CRAN. When installing a package available on CRAN, it is sufficient simply to tell R the following:Note the plural `s`

on `packages`

, and the quotes around the “package name”

Other packages, which may be in various developmental states (including perfectly functional!) are often hosted on GitHub before they make their way onto CRAN. Simply telling R `install.packages("packagename")`

will fail to find it (as R only looks in CRAN for packages), so you must use another package called `devtools`

Which you will need to install first if you (probably) don’t already have it!

to install packages directly from Github:Note the `::`

allows you to use the function `install_github()`

from the `devtools`

package without having to first load the devtools package with `library(devtools)`

.

For example, to install Hadley Wickham’s package `r4ds`

from its Github page https://github.com/hadley/r4ds, we would type:

## Getting Help for R

For specific functions or commands, you can simply type:

This will display a help page specific to that function in the Viewer pane. R functions and packages are extremely well-documented; help pages normally include a short description of the function, arguments and options (as well as their default values), and several examples or vignettes to demonstrate usage of the function.

Additionally, you can turn to the community.

## Built in Datasets

## R Markdown

### Math and \(\LaTeX{}\)

Math in R Markdown uses the \(\LaTeX{}\) language to typeset beautiful formulas and equations. To include mathematical symbols or expressions inlineThat means, within the text, and not in a separate line, location, or environment within the document.

, insert it `$`

between two dollar signs`$`

. Within a sentence, `$2^2+\frac{\pi}{\pi}=5$`

becomes \(2^2+\frac{\pi}{\pi}=5\).

If you prefer it to be centered in its own line, put it on its own line, `$$`

between two dollar signs`$$`

.

`\(``\)`2^2+\frac{\pi}{\pi}=5`

\(``\)`` becomes:

\[2^2+\frac{\pi}{\pi}=5\]

There is also a shortcut with the R package `equatiomatic`

.

### Producing documents

#### Producing a PDF Output

PDFs are archaic document formats with many flaws, yet the format remains the industry standard in most cases. PDFs are made with \(\LaTeX{}\), a typography language dating to the 1980s. \(\LaTeX{}\) has its own problems

One alternative is tinytex

## Resources

### Cheat Sheets

## R Packages

The following is a compendium of all R packages used, and their main uses

`tidyverse`

`DT`

`knitr`

`haven`

`readxl`

`dplyr`

`ggplot2`

`car`

`sandwich`

`lmtest`

`equatiomatic`

`gganimate`

`stargazer`

`broom`

`modelr`

`infer`

`aer`

## Finding Data

- A near-comprehensive list of all existing data sets built-in to R or R packagesNote: You should use these more for playing around with in R to boost your data wrangling skills. These should not be used for your projects in most circumstances.