Pystata
-
- Save python data to csv
-
- Use python to write stata do file following regression specifications
-
- Report regression results and re-read it into python
Stata required library (Install if you haven't done so)
- ssc install reghdfe, ftools, esout
Example (See example.ipynb for more details)
from src.pystata import summary_col
# some random combinations of fixed effects
fx_1 = {'Stock fixed effects': 'fx1', 'Year fixed effects': 'fx2'}
fx_2 = {'Stock fixed effects': 'fx1', 'Industry Fixed effects': 'fx3'}
fx_3 = {'Stock fixed effects': 'fx1', 'Year fixed effects': 'fx2', 'Industry Fixed effects': 'fx3'}
# Syntax: [data, regression specification, covariance type (enter cluster list),fixed effects]
reg_inputs = [[data, 'Y ~ 1 + x1+ x2', 'covariance type', {Fixed Effects}], # This is an example (column 1)
[data1, 'y ~ 1 + x1+ x2 ', 'robust', fx_1], # (column 2)
[data2, 'y ~ 1 + x1+ x2 + x3 + x4', 'robust', fx_2], # (column 3)
[data2, 'y ~ 1 + x1+ x2 + x3 ', 'robust', fx_2], # (column 4)
[data1, 'y ~ 1 + x1+ x2 + x4', ['fx1', 'fx2'], fx_2], # (column 5)
[data2, 'y ~ 1 + x1+ x2 + x3 + x4', ['fx1', 'fx2'], fx_3] # (column 6)
]
outputDir = '/home/user/pystata' # set the directory to save Stata output (log and results)
table = summary_col(reg_inputs) # read regression specification
table.set_dir(outputDir) # set the directory to save Stata output (log and results)
table.name = 'table_pystata' # set the name of the table
table.modelname = ["Y1", "Y1", "Var", "Variable", "Model name", "Y", ] # set the name for columns
table.order = ['x1', 'x2', 'x3', 'x4'] # Determine independent variables order
table._main_() # transit data from python to Stata and write Stata do file accordingly
table.run_do() # run Stata do file
Metadata
Release files for pystata 0.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| pystata-0.0.1.tar.gz | 21.1 kB | Without provenance | Details for pystata-0.0.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pystata-0.0.1-py3-none-any.whl | Python 3 | none | any | Details for pystata-0.0.1-py3-none-any.whl |
Total release size: 42.7 kB
Release files / pystata-0.0.1.tar.gz
| Download URL | pystata-0.0.1.tar.gz |
|---|---|
| Size | 21.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
cb1b138d84399f7260323f2b969a3137cf9d56f051073c889b8210f3ad28b81e
|
|
BLAKE2b-256 checksum How to use checksums |
a034e8f9a77775d514a51c74e6fb44143f82934a912448d0f491f1f5feb0407c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.10.4
|
Release files / pystata-0.0.1-py3-none-any.whl
| Download URL | pystata-0.0.1-py3-none-any.whl |
|---|---|
| Size | 21.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
69da499fb9a11a60fbfb657abf932b7f9981a7b01949e551172aec96f0b735d0
|
|
BLAKE2b-256 checksum How to use checksums |
d7980f53a1fea2eb07418465f534e536cc9167d79313261f3a8badcb3538059d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.10.4
|
Security for pystata 0.0.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.