# Data sources

## Electricity stated-choice data

- **What:** the `Electricity` data set: stated choices among four electricity supplier contracts that differ in fixed
  price, contract length, local supplier, well-known supplier, time-of-day rates and seasonal rates.
- **Where:** shipped inside the R package mlogit, version 2.0-0, on CRAN.
  - Package page: https://cran.r-project.org/package=mlogit
  - Source tarball: https://cran.r-project.org/src/contrib/mlogit_2.0-0.tar.gz (once a newer version is released,
    https://cran.r-project.org/src/contrib/Archive/mlogit/mlogit_2.0-0.tar.gz)
  - sha256 of the tarball: `0ae2768408f557fa6a4b09c56ca4d03fe1f580fb256ab9eecd9ee04b858a9475` (736,963 bytes)
  - File read: `mlogit/data/Electricity.rda`
- **Licence:** the package is distributed under GPL (>= 2), which the CRAN page expands to GPL version 2 or
  version 3.
- **Provenance and citation:** the package's reference page for the data ("Electricity", `man/Electricity.Rd`) gives
  Kenneth Train's home page (https://eml.berkeley.edu/~train/) as the source and cites:
  - Joel Huber and Kenneth Train, "On the Similarity of Classical and Bayesian Estimates of Individual Mean
    Partworths", Marketing Letters, volume 12, pages 259 to 269.
  - David Revelt and Kenneth Train, "Customer-Specific Taste Parameters and Mixed Logit: Households' Choice of
    Electricity Supplier", Econometrics working paper 0012001, University Library of Munich, Germany,
    https://ideas.repec.org/p/wpa/wuwpem/0012001.html
  - The package itself: Yves Croissant, mlogit: Multinomial Logit Models, https://cran.r-project.org/package=mlogit

## Size, checked against the file

The reference page describes the columns, which match the file. Its one-line description gives a household count
("A sample of 2308 households in the United States") that does not match the file. The file holds 4,308 choice
situations from 361 respondent ids, four contracts each; 348 respondents answered 12 situations and 13 answered between
8 and 11. This study uses the file's counts. `tests/test_data.py` checks the sizes, the documented price design and the
choice shares printed in the package's own Exercise 3.

## Why the data is not redistributed here

This study ships the fitting code, a download script (`wtp/data.py`, which fetches the tarball from CRAN, checks the
sha256 above and extracts only the data file) and the results, but not the data. The package's GPL licence would
allow redistribution with its terms, but the data comes from a third-party survey whose original authors' terms are not
stated in the package, and the GPL is a software licence. Downloading from CRAN keeps the source of record and its
terms in one place, at no cost to reproduction.

## Known answer

The package's Exercise 3 (`mlogit/inst/doc/e3.mxlogit.html`, model `Elec.mxl2`) prints the estimates this study
reproduces before trusting its own; the numbers are in `wtp/known_answer.py` and `tests/test_known_answer.py` checks
them against that file inside the tarball.
