Metadata-Version: 2.1
Name: simple_fpa
Version: 1.7
Summary: Simple nonparametric inference for sealed first-price auctions.
Author: Pasha Andreyanov, Grigory Franguridi
Author-email: pandreyanov@gmail.com
License: MIT
Platform: UNKNOWN
Classifier: License :: OSI Approved :: MIT License
Description-Content-Type: text/markdown
License-File: LICENSE

### A package for the "Nonparametric inference on counterfactuals in sealed first-price auctions" paper by Pasha Andreyanov and Grigory Franguridi.
It contains a class that fits the auction data using a symmetric first-price auction model with either additive or multiplicative heterogeneity, and predicts latent valuations and counterfactuals.

The interface of the package consists of 4 steps.

- pass a dataframe with auctionid and bid column names
- pass covariate (continuous and discrete) column names and create bid residuals and fitted values
- fit the non-parametric model
- predict latent bids, and also expected total surplus, potential bidder surplus and revenue, as functions of exclusion level

### Arxiv and Github repository
https://arxiv.org/abs/2106.13856

https://github.com/pandreyanov/pashas_simple_fpa

### Sample code

Package can be installed via pip from terminal

```python
pip install simple_fpa
```

Import typical auction data

```python
from simple_fpa import Model, load_haile
import pandas as pd
import numpy as np

import matplotlib as mpl
import matplotlib.pyplot as plt
from pylab import rcParams

rcParams.update({
    "text.usetex": True,
    "font.family": "serif",
    "font.serif": ["Arial"],
    "lines.linewidth": 1,
    "figure.dpi":200
})

data = load_haile()
```

Residualize the bids, print summary

```python
model = Model(data = data, auctionid_columns = ['auctionid'], bid_column = 'actual_bid')
cont_covs = ['adv_value', 'hhi', 'volume_total_1']
disc_covs = ['year', 'forest']
model.residualize(cont_covs, disc_covs, 'multiplicative')

# we can pick a smaller subset of auctions
model.data = model.data[model.data.auctionid.isin(list(set(model.data.auctionid.values))[:1000])].copy()

# we can pick certain numbers of bidders
model.data = model.data[model.data._bidders.isin([2,3,4,5])].copy()

model.summary()
```

Trim the residuals, fit the model and predict latent valuations

```python
model.trim_residuals(10)
model.fit(smoothing_rate = 0.34, trim_percent = 5, boundary = 'reflect')
model.predict()
```

Plot statistics

```python
model.make_ci_asy(95, hyp = 'twosided')
model.plot_stats()
```

Make confidence intervals and confidence bands

```python
model.make_cicb(95, draws = 1000, hyp = 'twosided')
```

Find optimal exclusion level

```python
model.find_optimal_u()
```

Plot counterfactuals

```python
model.plot_counterfactuals()
```

Inspect the data

```python
model.data.sample(5)
```

### Predictions

The counterfactuals are populated into the original dataset, ordered by the magnitude of bid redisuals. Some observations will not have a prediction, as they will be ignored (trimmed) in the non-parametric estimation. I use underscore in front of all variables created by the package.

- *_resid* : bid residuals
- *_fitted* : bid fitted values
- *_trimmed* : variable takes 1 if observations were omitted (trimmed) and 0 otherwise
- *_u* : u-quantile levels, takes values between 0 and 1

- *_hat_q* : estimate of quantile density of bid residuals
- *_hat_v* : estimate of quantile function of value residuals

- *_latent_resid* : same as *_hat_v*

- *_hat_ts* : total surplus as function of exclusion level u
- *_hat_bs* : (one) potential bidder surplus as function of exclusion level u
- *_hat_rev* : auctioneer revenue as function of exclusion level u

- *q_ci*, *v_ci*, *_bs_ci*, *_ts_ci*, *_rev_ci* : simulated confidence intervals
- *q_cb*, *v_cb*, *_bs_cb*, *_ts_cb*, *_rev_cb* : simulated confidence bands

- *q_cia*, *v_cia*, *_bs_cia*, *_rev_cia* : asymptotic (theoretical) confidence intervals

