Skip to main content

pyoneclick

This Python tool can automatically screen control variables to adjust the significance of specific variables, similar to Stata's oneclick command but with more powerful features.

Introduction

Insights

The development of this research is based on the following insights:

  1. A trade-off between time and optimal solutions needs to be made. During the process of filtering control variables, when there are too many control variables, finding the optimal solution becomes time-consuming and unacceptable. In many cases, we only need a quick result that works, that is, an approximate optimal solution rather than all possible usable results.

  2. Addressing the issue of "solve one problem only to find another cropping up." Oftentimes, when a variable becomes significant in a specific command, another variable or the same variable in another command may no longer be significant. Therefore, the command used for screening must address such issues where simultaneous significance is required.

Command Features

Compared to the oneclick command in Stata, this command incorporates several new features. It has the following characteristics:

  1. More efficient filtering. This command is based on the simulated annealing algorithm rather than enumeration, resulting in lower time complexity during the search for usable control variables.

  2. Clearer logic. The original Stata code can be directly passed into the command during execution, without needing to change coding habits, making the command more readable.

  3. Broader functionality. Supports joint estimation across multiple commands and adjusts the significance of multiple variables or multiple commands at the same time.

Usage

Requirements

Before formal use, we need to meet the following conditions:

  1. Licensed Stata software. The version must be Stata 17 or above.

  2. An appropriate Python 3 environment. Python 3.8 or higher is recommended.

Installation

  1. First, set a global system variable named STATA_PATH. The value of the variable should be the installation path of Stata including the executable name. Make sure the path matches your installed Stata version and edition. For example, for the MP version of Stata 18, the path may look like this:

Windows:

$env:STATA_PATH=C:\Program Files\Stata18\StataMP-64.exe

Linux:

export STATA_PATH=/usr/local/stata18/stata-mp
  1. Install the pyoneclick command:
pip install pyoneclick

Quick Start

  1. Specify the data. Before executing the statistical estimation command for the first time, use the -d parameter to specify the .dta data file to be used:
pyoneclick -d "examples/example.dta" 
  1. Simplest estimation. Use -c to specify the Stata command to run; the model will automatically parse the dependent and independent variables and adjust the significance of covariates by computing an optimal list of control variables:
pyoneclick -c "reghdfe y1 x1 c1 c2 c3 c4 c5 c6 c7 c8 c9 c10 c11 c12 c13 c14 c15 c16 c17 c18 c19 c20 c21 c22 c23 c24 c25 c26 c27 c28 c29 c30 c31, absorb( stkcd year )"

The full functionality of the pyoneclick command is relatively complex, and mastering it fully may take some time.

Acknowledgments

The development of this project was inspired by the StataOneClick project, and we sincerely thank the author of that project. Their excellent work provided valuable insights and became a crucial foundation for our project’s development.

Third-Party Libraries

This project uses the following open-source libraries:

Metadata

Release files for pyoneclick 0.2.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pyoneclick 0.2.1
File Size Uploaded
pyoneclick-0.2.1.tar.gz 7.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pyoneclick 0.2.1
File Interpreter ABI Platform
pyoneclick-0.2.1-py3-none-any.whl Python 3 none any Details

Total release size: 15.6 kB

Release files / pyoneclick-0.2.1.tar.gz

Download URL pyoneclick-0.2.1.tar.gz
Size 7.5 kB
Tags Source
SHA-256 checksum
How to use checksums
b606c7220900be7d5e79b6896f511d7d44a181be715e6cf3b6bdc64f86ed9836
BLAKE2b-256 checksum
How to use checksums
fb6f39468f8e9c0bcfe73983ad3bcd6bd07455ca0b19e7d327d44e1c06659151
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.13

Release files / pyoneclick-0.2.1-py3-none-any.whl

Download URL pyoneclick-0.2.1-py3-none-any.whl
Size 8.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5a0a88405e17adab5cb37bbd7749e82fca6c7c427581344df39d67b1b42eac53
BLAKE2b-256 checksum
How to use checksums
3f4f4749414cf5cde54f545220ee673d2971aee9e8af32ba2574a87052c581a7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.13

Release history Release notifications | RSS feed

This release

0.2.1 This release

2 release files

0.2.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page