Skip to main content

The control function approach for quantile regression models

Project description

QuantregCF

This Python package is an implementation of the control function approach for quantile regression models proposed by Sokbae Lee in "Endogeneity in Quantile Regression Models: A Control Function Approach," Journal of Econometrics, 141: 1131-1158, 2007.

Installation

This project can be installed using pip:

pip install quantregCF

Usage

from quantregCF import quantregCF

beta, se = quantregCF(option, degree, tau_first_stage, tau_second_stage, data)

quantregCF returns a list of estimated coefficients and a list of standard errors.

Parameters

The main function is

quantregCF(option, degree, tau_first_stage, tau_second_stage, data)

option = 0 if the second-stage quantile regression uses polynomial series.

option = 1 if the second-stage quantile regression uses B-spline.

degree is the degree of the polynomial/B-spline. (integer)

tau_first_stage is the value of tau for the first-stage quantile regression. (between 0 and 1)

tau_second_stage is the value of tau for the second-stage quantile regression. (between 0 and 1)

data is a list of length two that contains information on the dataset.

data = [`dataframe`, `var_lst`]

Each element in data is defined as followed:

dataframe is the dataset in the pandas DataFrame format.

var_lst is a list of length four that contains the name of variables of interest. The first two elements of var_lst are strings and the last two elements are lists of strings.

`var_lst` = [`dep_var`, `endog_var`, `exog_var_lst`, `iv_var_lst`]

Each element in var_lst is defined as followed:

dep_var and endog_var are the names of dependent variable and endogenous right-hand side variable.

exog_var_lst and iv_var_lst are the lists of names of exogenous included variables and instrumental variables.

Example

The file fishdata.py illustrates how to use quantregCF on the well-known Graddy’s Fulton fish market data. To run the code, simply download fishdata.py from the tests folder and run python fishdata.py. Below is a code snippet showing how to load the data and use quantregCF.

# load data into DataFrame `df` from https://www.kathryngraddy.org/research#pubdata
data_source = "https://uploads-ssl.webflow.com/629e460595fdd36617348189/62a0fd19b6742078eed59f47_fish.out.txt"
df = pd.read_csv(data_source, sep="\t")
var_lst = ['qty', 'price', ["day1", "day2", "day3", "day4"], ["stormy", "mixed"]]
data_lst = [df, var_lst]

# regressions using B-splines in the second-stage
beta, se = quantregCF(option=1, degree=3, tau_first_stage=0.5, tau_second_stage=0.5, data=data_lst)

# calculate the 95% confidence interval
ci_lb = beta[0] - 1.96 * se[0]
ci_ub = beta[0] + 1.96 * se[0]

Dependencies

  • NumPy
  • Pandas
  • SciPy
  • CVXPY
  • Urllib

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

quantregCF-1.0.0.tar.gz (7.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

quantregCF-1.0.0-py3-none-any.whl (13.0 kB view details)

Uploaded Python 3

File details

Details for the file quantregCF-1.0.0.tar.gz.

File metadata

  • Download URL: quantregCF-1.0.0.tar.gz
  • Upload date:
  • Size: 7.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.6

File hashes

Hashes for quantregCF-1.0.0.tar.gz
Algorithm Hash digest
SHA256 65485eb3881ff2df015f4eacf44dcbc54ee3d25464cc0b124b0d1833b53becdf
MD5 81933990c872def3fdac31ebdba4895d
BLAKE2b-256 76cc251f071500400f4837f8daccc49d0356373eb7515b9ec1c8af3edbfd8dcd

See more details on using hashes here.

File details

Details for the file quantregCF-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: quantregCF-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 13.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.6

File hashes

Hashes for quantregCF-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 86bbcd9c076739fe4a6b5319582a9422477835d55491f440597828e77ff40e00
MD5 41cb118d048cf58674a7e2e06be5845f
BLAKE2b-256 fa7cce69d03906a1771cce28c21a7745f1240724861b13197714631387326dbe

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page