# R Package

#
The `probstats4econ`

Package Version 0.2.0

The package `probstats4econ`

is a companion package for the book *Probability and Statistics for Economics and Business: An Introduction Using R* by Jason Abrevaya (MIT Press, under contract). It contains the companion datasets and helper functions used throughout the book. After loading the library, you can refer to any of the datasets in the book by their name. For example, here is a quick summary of the `exams`

dataset:

```
library(probstats4econ)
summary(exams)
```

```
## exam1 exam2
## Min. :33.00 Min. :20.0
## 1st Qu.:68.00 1st Qu.:64.0
## Median :79.00 Median :73.0
## Mean :77.31 Mean :70.9
## 3rd Qu.:89.00 3rd Qu.:81.0
## Max. :99.00 Max. :96.0
```

In addition, the helper functions introduced in Chapters 16 and 18 are available for you to use. For example, here is a test of the hypothesis that the mean exam scores are the same across the first two exams:

```
gamma_hat <- colMeans(exams)
var_gamma_hat <- var_mean_onesample(exams, c("exam1", "exam2"))
# test that `exam1` - `exam2` = 0
wald_test(gamma_hat, var_gamma_hat, c(1, -1))
```

```
## $W
## [1] 27.13471
##
## $p_value
## [1] 1.897602e-07
```

See the reference page for a complete list of datasets and functions available in the package. In addition, the datasets page contains a more detailed listing of the datasets along with alternative formats for download.

# Installation

The package is available both on CRAN and self-hosted on this website. You should prefer the CRAN version unless you understand the difference between published and development versions and have a good reason to use the development version.

### CRAN

You can install this package as you would install any other:

`install.packages("probstats4econ")`