estrec 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- estrec-0.1.0/LICENSE +25 -0
- estrec-0.1.0/PKG-INFO +157 -0
- estrec-0.1.0/README.md +120 -0
- estrec-0.1.0/pyproject.toml +70 -0
- estrec-0.1.0/schema/LICENSE +138 -0
- estrec-0.1.0/schema/catalog.json +268 -0
- estrec-0.1.0/schema/estrec-0.1.json +976 -0
- estrec-0.1.0/schema/estrec-collection-0.1.json +135 -0
- estrec-0.1.0/schema/estrec-table-0.1.json +170 -0
- estrec-0.1.0/schema/examples/bayesian.estrec.json +162 -0
- estrec-0.1.0/schema/examples/causal-ml.estrec.json +98 -0
- estrec-0.1.0/schema/examples/choice-mixed-logit.estrec.json +151 -0
- estrec-0.1.0/schema/examples/choice-mnl.estrec.json +137 -0
- estrec-0.1.0/schema/examples/conditional-logit.estrec.json +103 -0
- estrec-0.1.0/schema/examples/csdid.estrec.json +339 -0
- estrec-0.1.0/schema/examples/dcas.estrec.json +198 -0
- estrec-0.1.0/schema/examples/dfeols-linear-fe.estrec.json +96 -0
- estrec-0.1.0/schema/examples/did2s.estrec.json +269 -0
- estrec-0.1.0/schema/examples/event-study.estrec-table.json +24 -0
- estrec-0.1.0/schema/examples/gam.estrec.json +83 -0
- estrec-0.1.0/schema/examples/glm-logit.estrec.json +118 -0
- estrec-0.1.0/schema/examples/iv.estrec.json +64 -0
- estrec-0.1.0/schema/examples/lm-minimal.estrec.json +94 -0
- estrec-0.1.0/schema/examples/med2s.estrec.json +181 -0
- estrec-0.1.0/schema/examples/mediation.estrec.json +102 -0
- estrec-0.1.0/schema/examples/meta-analysis.estrec.json +105 -0
- estrec-0.1.0/schema/examples/mi.estrec.json +121 -0
- estrec-0.1.0/schema/examples/mixed.estrec.json +143 -0
- estrec-0.1.0/schema/examples/multiple-testing.estrec.json +81 -0
- estrec-0.1.0/schema/examples/paper.estrec-collection.json +1070 -0
- estrec-0.1.0/schema/examples/paper.estrec-table.json +30 -0
- estrec-0.1.0/schema/examples/ppmlhdfe.estrec.json +92 -0
- estrec-0.1.0/schema/examples/predictive.estrec.json +293 -0
- estrec-0.1.0/schema/examples/process-spss.estrec.json +363 -0
- estrec-0.1.0/schema/examples/replication.estrec-collection.json +123 -0
- estrec-0.1.0/schema/examples/replication.members.jsonl +2 -0
- estrec-0.1.0/schema/examples/resampling.estrec.json +91 -0
- estrec-0.1.0/schema/examples/sem.estrec.json +312 -0
- estrec-0.1.0/schema/examples/session.estrec-collection.json +857 -0
- estrec-0.1.0/schema/examples/survey.estrec.json +115 -0
- estrec-0.1.0/schema/examples/survival-cox-breslow.estrec.json +125 -0
- estrec-0.1.0/schema/examples/survival-cox-efron.estrec.json +249 -0
- estrec-0.1.0/schema/profiles/bayesian-0.1.json +117 -0
- estrec-0.1.0/schema/profiles/causal-ml-0.1.json +137 -0
- estrec-0.1.0/schema/profiles/choice-0.1.json +173 -0
- estrec-0.1.0/schema/profiles/conditional-logit-0.1.json +149 -0
- estrec-0.1.0/schema/profiles/csdid-0.1.json +85 -0
- estrec-0.1.0/schema/profiles/dcas-0.1.json +83 -0
- estrec-0.1.0/schema/profiles/dfeols-0.1.json +109 -0
- estrec-0.1.0/schema/profiles/did-0.1.json +221 -0
- estrec-0.1.0/schema/profiles/did2s-0.1.json +82 -0
- estrec-0.1.0/schema/profiles/gam-0.1.json +111 -0
- estrec-0.1.0/schema/profiles/glm-0.1.json +146 -0
- estrec-0.1.0/schema/profiles/inference-0.1.json +77 -0
- estrec-0.1.0/schema/profiles/iv-0.1.json +133 -0
- estrec-0.1.0/schema/profiles/linear-fe-0.1.json +137 -0
- estrec-0.1.0/schema/profiles/med2s-0.1.json +154 -0
- estrec-0.1.0/schema/profiles/mediation-0.1.json +99 -0
- estrec-0.1.0/schema/profiles/meta-analysis-0.1.json +145 -0
- estrec-0.1.0/schema/profiles/mi-0.1.json +102 -0
- estrec-0.1.0/schema/profiles/mixed-0.1.json +181 -0
- estrec-0.1.0/schema/profiles/multiple-testing-0.1.json +55 -0
- estrec-0.1.0/schema/profiles/ppmlhdfe-0.1.json +78 -0
- estrec-0.1.0/schema/profiles/predictive-0.1.json +125 -0
- estrec-0.1.0/schema/profiles/resampling-0.1.json +70 -0
- estrec-0.1.0/schema/profiles/sem-0.1.json +157 -0
- estrec-0.1.0/schema/profiles/survey-0.1.json +115 -0
- estrec-0.1.0/schema/profiles/survival-0.1.json +170 -0
- estrec-0.1.0/setup.cfg +4 -0
- estrec-0.1.0/src/estrec/__init__.py +141 -0
- estrec-0.1.0/src/estrec/__main__.py +5 -0
- estrec-0.1.0/src/estrec/collection.py +942 -0
- estrec-0.1.0/src/estrec/records.py +2140 -0
- estrec-0.1.0/src/estrec/show.py +297 -0
- estrec-0.1.0/src/estrec/table.py +1702 -0
- estrec-0.1.0/src/estrec/views.py +370 -0
- estrec-0.1.0/src/estrec.egg-info/PKG-INFO +157 -0
- estrec-0.1.0/src/estrec.egg-info/SOURCES.txt +95 -0
- estrec-0.1.0/src/estrec.egg-info/dependency_links.txt +1 -0
- estrec-0.1.0/src/estrec.egg-info/entry_points.txt +2 -0
- estrec-0.1.0/src/estrec.egg-info/requires.txt +12 -0
- estrec-0.1.0/src/estrec.egg-info/top_level.txt +1 -0
- estrec-0.1.0/tests/test_catalog.py +132 -0
- estrec-0.1.0/tests/test_collection.py +472 -0
- estrec-0.1.0/tests/test_converters.py +380 -0
- estrec-0.1.0/tests/test_disclosure.py +412 -0
- estrec-0.1.0/tests/test_estimation.py +838 -0
- estrec-0.1.0/tests/test_julia.py +100 -0
- estrec-0.1.0/tests/test_process.py +447 -0
- estrec-0.1.0/tests/test_sas.py +153 -0
- estrec-0.1.0/tests/test_schema.py +365 -0
- estrec-0.1.0/tests/test_show.py +133 -0
- estrec-0.1.0/tests/test_spss.py +181 -0
- estrec-0.1.0/tests/test_stata.py +652 -0
- estrec-0.1.0/tests/test_table.py +732 -0
- estrec-0.1.0/tests/test_viewer.py +404 -0
- estrec-0.1.0/tests/test_views.py +207 -0
estrec-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Ted Matherly and the estrec contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
22
|
+
|
|
23
|
+
The files in schema/ (the estrec format's schemas, catalog and example
|
|
24
|
+
records) are not under this license: they are dedicated to the public domain
|
|
25
|
+
under CC0 1.0 Universal (schema/LICENSE).
|
estrec-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: estrec
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Reference validator, writer and redactor for estrec, the estimation record format: one JSON record per statistical estimation run
|
|
5
|
+
Author: Ted Matherly
|
|
6
|
+
License-Expression: MIT AND CC0-1.0
|
|
7
|
+
Project-URL: Homepage, https://github.com/estrec/estrec
|
|
8
|
+
Project-URL: Specification, https://github.com/estrec/estrec/blob/main/spec/estrec.md
|
|
9
|
+
Project-URL: Schemas, https://estrec.org/schema/
|
|
10
|
+
Project-URL: Issues, https://github.com/estrec/estrec/issues
|
|
11
|
+
Keywords: econometrics,statistics,reproducibility,provenance,json schema,regression,fixed effects,replication
|
|
12
|
+
Classifier: Development Status :: 3 - Alpha
|
|
13
|
+
Classifier: Intended Audience :: Science/Research
|
|
14
|
+
Classifier: Programming Language :: Python :: 3
|
|
15
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
21
|
+
Classifier: Topic :: Scientific/Engineering :: Mathematics
|
|
22
|
+
Classifier: Topic :: Scientific/Engineering :: Information Analysis
|
|
23
|
+
Requires-Python: >=3.10
|
|
24
|
+
Description-Content-Type: text/markdown
|
|
25
|
+
License-File: LICENSE
|
|
26
|
+
License-File: schema/LICENSE
|
|
27
|
+
Provides-Extra: jsonschema
|
|
28
|
+
Requires-Dist: jsonschema>=4.18; extra == "jsonschema"
|
|
29
|
+
Provides-Extra: parquet
|
|
30
|
+
Requires-Dist: pyarrow>=12; extra == "parquet"
|
|
31
|
+
Provides-Extra: test
|
|
32
|
+
Requires-Dist: pytest>=7; extra == "test"
|
|
33
|
+
Requires-Dist: jsonschema>=4.18; extra == "test"
|
|
34
|
+
Requires-Dist: pyarrow>=12; extra == "test"
|
|
35
|
+
Requires-Dist: numpy>=1.25; extra == "test"
|
|
36
|
+
Dynamic: license-file
|
|
37
|
+
|
|
38
|
+
# estrec
|
|
39
|
+
|
|
40
|
+
**estrec** ("estimation record") is **a file format for one statistical estimation run**:
|
|
41
|
+
what was estimated, what came out, and how and where it ran, as a small JSON record that any
|
|
42
|
+
software can write and read.
|
|
43
|
+
|
|
44
|
+
> **Status: 0.1 draft for comment.** The format may still change. Please open an issue with
|
|
45
|
+
> anything that would stop your tool from writing or reading these records.
|
|
46
|
+
|
|
47
|
+
Why: results from two tools, or two runs, often differ, and finding out why usually means
|
|
48
|
+
rerunning both. An estrec record keeps what you need to explain the difference: the
|
|
49
|
+
resolved options, the sample and singleton counts, the small-sample correction behind the
|
|
50
|
+
standard errors, convergence, the software and environment, and the data's checksum.
|
|
51
|
+
|
|
52
|
+
- **Any software, any model**: a small core every tool can fill (`meta`, `parameters`,
|
|
53
|
+
`metrics`, `specification`, `provenance`), with **profiles** for the rules of a kind of
|
|
54
|
+
model (`inference`, `linear-fe`, `iv`, `did`, `glm`, `conditional-logit`, `mixed`, `choice`, `sem`, `mediation`, `survival`, `meta-analysis`, `predictive`, `causal-ml`, `gam`, `bayesian`; cross-cutting `mi`, `survey`, `multiple-testing`, `resampling`) or one tool.
|
|
55
|
+
- **Small**: results and metadata only; residuals, fitted values and fixed-effect
|
|
56
|
+
coefficients go in linked attachments.
|
|
57
|
+
- **Traceable**: records can cite the paper and table they appear in, carry an integrity
|
|
58
|
+
digest, and be redacted of user and host details before sharing.
|
|
59
|
+
|
|
60
|
+
## Contents
|
|
61
|
+
|
|
62
|
+
| Path | What | License |
|
|
63
|
+
|---|---|---|
|
|
64
|
+
| [`spec/estrec.md`](spec/estrec.md) | the specification | CC0 1.0 |
|
|
65
|
+
| [`spec/profiles/`](spec/profiles/) | the profiles, with field mappings across Stata, R, Python and Julia tools | CC0 1.0 |
|
|
66
|
+
| [`schema/`](schema/) | JSON Schemas (2020-12) for the core, the profiles and collections; the catalog; example records and collections | CC0 1.0 |
|
|
67
|
+
| [`src/estrec/`](src/estrec/) | `estrec`, the reference validator, writer and redactor (Python) | MIT |
|
|
68
|
+
| [`r/`](r/) | `estrec`, an R package that writes records from fitted models (fixest `feols` so far) | MIT |
|
|
69
|
+
| [`viewer/`](viewer/), [`server/`](server/) | the record viewer, and estrec.org: the site and the Publish service (one Cloudflare Worker) | MIT |
|
|
70
|
+
|
|
71
|
+
Schemas are served at `https://estrec.org/schema/`.
|
|
72
|
+
|
|
73
|
+
## A minimal record
|
|
74
|
+
|
|
75
|
+
```json
|
|
76
|
+
{"schema": "estrec/0.1",
|
|
77
|
+
"meta": {"id": "6f1c0000-0000-4000-8000-000000000001", "created": "2026-10-24T15:02:11Z",
|
|
78
|
+
"status": "ok", "estimator": {"family": "linear", "method": "ols"},
|
|
79
|
+
"responses": ["mpg"], "profiles": ["inference/0.1"]},
|
|
80
|
+
"metrics": {"nobs": 32, "df_residual": 30, "r2": 0.7528},
|
|
81
|
+
"parameters": [
|
|
82
|
+
{"term": "(Intercept)", "estimate": 37.285, "std_error": 1.8776, "p_value": 8.24e-19},
|
|
83
|
+
{"term": "wt", "estimate": -5.3445, "std_error": 0.5591, "p_value": 1.29e-10}],
|
|
84
|
+
"structures": {"vcov": [{"kind": "matrix", "labels": ["(Intercept)", "wt"],
|
|
85
|
+
"data": [[3.525, -1.0], [-1.0, 0.3126]], "type": "iid",
|
|
86
|
+
"ssc": {"convention": "R lm"}, "default": true}]}}
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
## The validator
|
|
90
|
+
|
|
91
|
+
```bash
|
|
92
|
+
pip install 'estrec[jsonschema]' # not yet on PyPI; for now: pip install .
|
|
93
|
+
estrec validate model.estrec.json
|
|
94
|
+
estrec redact model.estrec.json -o shareable.estrec.json
|
|
95
|
+
estrec digest model.estrec.json
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
```python
|
|
99
|
+
import estrec as ef
|
|
100
|
+
|
|
101
|
+
rec = ef.new_record(
|
|
102
|
+
rows,
|
|
103
|
+
estimator={"family": "linear", "method": "ols"},
|
|
104
|
+
profiles=["inference/0.1"],
|
|
105
|
+
metrics={"nobs": 32, "df_residual": 30},
|
|
106
|
+
)
|
|
107
|
+
ef.write(rec, "model.estrec.json") # spills large structures, adds the digest
|
|
108
|
+
for issue in ef.validate(ef.read("model.estrec.json")):
|
|
109
|
+
print(issue)
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
It needs only the standard library; `jsonschema` adds full schema validation and `pyarrow`
|
|
113
|
+
writes large structures as Parquet attachments.
|
|
114
|
+
|
|
115
|
+
A **collection** (`estrec-collection/0.1`, spec section 11) holds a set of records: a
|
|
116
|
+
paper's results with where each appears, or a session's or replication's timeline. The same
|
|
117
|
+
commands validate, redact and digest collections.
|
|
118
|
+
|
|
119
|
+
```python
|
|
120
|
+
coll = ef.new_collection({"baseline": rec1, "full": rec2}, kind="paper",
|
|
121
|
+
locators=["Table 2, col. (1)", {"table": "2", "column": "2"}],
|
|
122
|
+
publication={"citation": {"type": "report", "title": "..."}})
|
|
123
|
+
ef.write_collection(coll, "table2.estrec-collection.json") # records embedded
|
|
124
|
+
issues = ef.validate_collection(ef.read_collection("table2.estrec-collection.json"), base_dir=".")
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
## Tables
|
|
128
|
+
|
|
129
|
+
The readers give the parameters as rows for any table tool: `estrec::read_collection()` with
|
|
130
|
+
modelsummary in R, and in Python
|
|
131
|
+
|
|
132
|
+
```python
|
|
133
|
+
rows = ef.parameters_table(ef.read_collection("table2.estrec-collection.json"),
|
|
134
|
+
base_dir=".") # member, locator, term, estimate, std_error, ...
|
|
135
|
+
ef.tidy(rec, vcov="iid") # another vcov in the record, recomputed
|
|
136
|
+
ef.glance(rec) # metrics, vcov_type, fixed_effects
|
|
137
|
+
polars.DataFrame(rows) # then great_tables, to_latex, ...
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
A quick look in the terminal: one record gives a detail view, several records, a folder or
|
|
141
|
+
a collection a side-by-side table (estimates over SEs, N, R2s, SE type, FE rows):
|
|
142
|
+
|
|
143
|
+
```bash
|
|
144
|
+
estrec show table2.estrec-collection.json
|
|
145
|
+
estrec show fit.estrec.json --vcov iid
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
**In the browser:** the [record viewer](https://estrec.org/viewer/)
|
|
149
|
+
opens records, folders and collections without uploading them, and builds tables you can copy
|
|
150
|
+
as LaTeX, Markdown, HTML or CSV, or save as a table spec (`spec/table.md`) to render again with
|
|
151
|
+
`estrec table table2.estrec-table.json -f latex`.
|
|
152
|
+
|
|
153
|
+
## Contributing
|
|
154
|
+
|
|
155
|
+
Profiles for new model types or tools come by pull request; see
|
|
156
|
+
[CONTRIBUTING.md](CONTRIBUTING.md). Writers for your own tool don't need anyone's permission:
|
|
157
|
+
the schemas are public domain.
|
estrec-0.1.0/README.md
ADDED
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
# estrec
|
|
2
|
+
|
|
3
|
+
**estrec** ("estimation record") is **a file format for one statistical estimation run**:
|
|
4
|
+
what was estimated, what came out, and how and where it ran, as a small JSON record that any
|
|
5
|
+
software can write and read.
|
|
6
|
+
|
|
7
|
+
> **Status: 0.1 draft for comment.** The format may still change. Please open an issue with
|
|
8
|
+
> anything that would stop your tool from writing or reading these records.
|
|
9
|
+
|
|
10
|
+
Why: results from two tools, or two runs, often differ, and finding out why usually means
|
|
11
|
+
rerunning both. An estrec record keeps what you need to explain the difference: the
|
|
12
|
+
resolved options, the sample and singleton counts, the small-sample correction behind the
|
|
13
|
+
standard errors, convergence, the software and environment, and the data's checksum.
|
|
14
|
+
|
|
15
|
+
- **Any software, any model**: a small core every tool can fill (`meta`, `parameters`,
|
|
16
|
+
`metrics`, `specification`, `provenance`), with **profiles** for the rules of a kind of
|
|
17
|
+
model (`inference`, `linear-fe`, `iv`, `did`, `glm`, `conditional-logit`, `mixed`, `choice`, `sem`, `mediation`, `survival`, `meta-analysis`, `predictive`, `causal-ml`, `gam`, `bayesian`; cross-cutting `mi`, `survey`, `multiple-testing`, `resampling`) or one tool.
|
|
18
|
+
- **Small**: results and metadata only; residuals, fitted values and fixed-effect
|
|
19
|
+
coefficients go in linked attachments.
|
|
20
|
+
- **Traceable**: records can cite the paper and table they appear in, carry an integrity
|
|
21
|
+
digest, and be redacted of user and host details before sharing.
|
|
22
|
+
|
|
23
|
+
## Contents
|
|
24
|
+
|
|
25
|
+
| Path | What | License |
|
|
26
|
+
|---|---|---|
|
|
27
|
+
| [`spec/estrec.md`](spec/estrec.md) | the specification | CC0 1.0 |
|
|
28
|
+
| [`spec/profiles/`](spec/profiles/) | the profiles, with field mappings across Stata, R, Python and Julia tools | CC0 1.0 |
|
|
29
|
+
| [`schema/`](schema/) | JSON Schemas (2020-12) for the core, the profiles and collections; the catalog; example records and collections | CC0 1.0 |
|
|
30
|
+
| [`src/estrec/`](src/estrec/) | `estrec`, the reference validator, writer and redactor (Python) | MIT |
|
|
31
|
+
| [`r/`](r/) | `estrec`, an R package that writes records from fitted models (fixest `feols` so far) | MIT |
|
|
32
|
+
| [`viewer/`](viewer/), [`server/`](server/) | the record viewer, and estrec.org: the site and the Publish service (one Cloudflare Worker) | MIT |
|
|
33
|
+
|
|
34
|
+
Schemas are served at `https://estrec.org/schema/`.
|
|
35
|
+
|
|
36
|
+
## A minimal record
|
|
37
|
+
|
|
38
|
+
```json
|
|
39
|
+
{"schema": "estrec/0.1",
|
|
40
|
+
"meta": {"id": "6f1c0000-0000-4000-8000-000000000001", "created": "2026-10-24T15:02:11Z",
|
|
41
|
+
"status": "ok", "estimator": {"family": "linear", "method": "ols"},
|
|
42
|
+
"responses": ["mpg"], "profiles": ["inference/0.1"]},
|
|
43
|
+
"metrics": {"nobs": 32, "df_residual": 30, "r2": 0.7528},
|
|
44
|
+
"parameters": [
|
|
45
|
+
{"term": "(Intercept)", "estimate": 37.285, "std_error": 1.8776, "p_value": 8.24e-19},
|
|
46
|
+
{"term": "wt", "estimate": -5.3445, "std_error": 0.5591, "p_value": 1.29e-10}],
|
|
47
|
+
"structures": {"vcov": [{"kind": "matrix", "labels": ["(Intercept)", "wt"],
|
|
48
|
+
"data": [[3.525, -1.0], [-1.0, 0.3126]], "type": "iid",
|
|
49
|
+
"ssc": {"convention": "R lm"}, "default": true}]}}
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
## The validator
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
pip install 'estrec[jsonschema]' # not yet on PyPI; for now: pip install .
|
|
56
|
+
estrec validate model.estrec.json
|
|
57
|
+
estrec redact model.estrec.json -o shareable.estrec.json
|
|
58
|
+
estrec digest model.estrec.json
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
```python
|
|
62
|
+
import estrec as ef
|
|
63
|
+
|
|
64
|
+
rec = ef.new_record(
|
|
65
|
+
rows,
|
|
66
|
+
estimator={"family": "linear", "method": "ols"},
|
|
67
|
+
profiles=["inference/0.1"],
|
|
68
|
+
metrics={"nobs": 32, "df_residual": 30},
|
|
69
|
+
)
|
|
70
|
+
ef.write(rec, "model.estrec.json") # spills large structures, adds the digest
|
|
71
|
+
for issue in ef.validate(ef.read("model.estrec.json")):
|
|
72
|
+
print(issue)
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
It needs only the standard library; `jsonschema` adds full schema validation and `pyarrow`
|
|
76
|
+
writes large structures as Parquet attachments.
|
|
77
|
+
|
|
78
|
+
A **collection** (`estrec-collection/0.1`, spec section 11) holds a set of records: a
|
|
79
|
+
paper's results with where each appears, or a session's or replication's timeline. The same
|
|
80
|
+
commands validate, redact and digest collections.
|
|
81
|
+
|
|
82
|
+
```python
|
|
83
|
+
coll = ef.new_collection({"baseline": rec1, "full": rec2}, kind="paper",
|
|
84
|
+
locators=["Table 2, col. (1)", {"table": "2", "column": "2"}],
|
|
85
|
+
publication={"citation": {"type": "report", "title": "..."}})
|
|
86
|
+
ef.write_collection(coll, "table2.estrec-collection.json") # records embedded
|
|
87
|
+
issues = ef.validate_collection(ef.read_collection("table2.estrec-collection.json"), base_dir=".")
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
## Tables
|
|
91
|
+
|
|
92
|
+
The readers give the parameters as rows for any table tool: `estrec::read_collection()` with
|
|
93
|
+
modelsummary in R, and in Python
|
|
94
|
+
|
|
95
|
+
```python
|
|
96
|
+
rows = ef.parameters_table(ef.read_collection("table2.estrec-collection.json"),
|
|
97
|
+
base_dir=".") # member, locator, term, estimate, std_error, ...
|
|
98
|
+
ef.tidy(rec, vcov="iid") # another vcov in the record, recomputed
|
|
99
|
+
ef.glance(rec) # metrics, vcov_type, fixed_effects
|
|
100
|
+
polars.DataFrame(rows) # then great_tables, to_latex, ...
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
A quick look in the terminal: one record gives a detail view, several records, a folder or
|
|
104
|
+
a collection a side-by-side table (estimates over SEs, N, R2s, SE type, FE rows):
|
|
105
|
+
|
|
106
|
+
```bash
|
|
107
|
+
estrec show table2.estrec-collection.json
|
|
108
|
+
estrec show fit.estrec.json --vcov iid
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
**In the browser:** the [record viewer](https://estrec.org/viewer/)
|
|
112
|
+
opens records, folders and collections without uploading them, and builds tables you can copy
|
|
113
|
+
as LaTeX, Markdown, HTML or CSV, or save as a table spec (`spec/table.md`) to render again with
|
|
114
|
+
`estrec table table2.estrec-table.json -f latex`.
|
|
115
|
+
|
|
116
|
+
## Contributing
|
|
117
|
+
|
|
118
|
+
Profiles for new model types or tools come by pull request; see
|
|
119
|
+
[CONTRIBUTING.md](CONTRIBUTING.md). Writers for your own tool don't need anyone's permission:
|
|
120
|
+
the schemas are public domain.
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=77", "wheel"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "estrec"
|
|
7
|
+
dynamic = ["version"]
|
|
8
|
+
description = "Reference validator, writer and redactor for estrec, the estimation record format: one JSON record per statistical estimation run"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
license = "MIT AND CC0-1.0" # CC0: the schemas, catalog and example records in schema/
|
|
11
|
+
license-files = ["LICENSE", "schema/LICENSE"]
|
|
12
|
+
authors = [{ name = "Ted Matherly" }]
|
|
13
|
+
requires-python = ">=3.10"
|
|
14
|
+
keywords = [
|
|
15
|
+
"econometrics", "statistics", "reproducibility", "provenance", "json schema",
|
|
16
|
+
"regression", "fixed effects", "replication",
|
|
17
|
+
]
|
|
18
|
+
classifiers = [
|
|
19
|
+
"Development Status :: 3 - Alpha",
|
|
20
|
+
"Intended Audience :: Science/Research",
|
|
21
|
+
"Programming Language :: Python :: 3",
|
|
22
|
+
"Programming Language :: Python :: 3 :: Only",
|
|
23
|
+
"Programming Language :: Python :: 3.10",
|
|
24
|
+
"Programming Language :: Python :: 3.11",
|
|
25
|
+
"Programming Language :: Python :: 3.12",
|
|
26
|
+
"Programming Language :: Python :: 3.13",
|
|
27
|
+
"Programming Language :: Python :: 3.14",
|
|
28
|
+
"Topic :: Scientific/Engineering :: Mathematics",
|
|
29
|
+
"Topic :: Scientific/Engineering :: Information Analysis",
|
|
30
|
+
]
|
|
31
|
+
# No required dependencies: the core checks, digest and redactor use only the standard library
|
|
32
|
+
dependencies = []
|
|
33
|
+
|
|
34
|
+
[project.optional-dependencies]
|
|
35
|
+
# JSON Schema validation against the core and the profiles; without it, built-in checks
|
|
36
|
+
jsonschema = ["jsonschema>=4.18"]
|
|
37
|
+
# spilled matrices and tables as Parquet attachments; without it, they go to JSON
|
|
38
|
+
parquet = ["pyarrow>=12"]
|
|
39
|
+
test = ["pytest>=7", "jsonschema>=4.18", "pyarrow>=12", "numpy>=1.25"]
|
|
40
|
+
|
|
41
|
+
[project.scripts]
|
|
42
|
+
estrec = "estrec.records:main"
|
|
43
|
+
|
|
44
|
+
[project.urls]
|
|
45
|
+
Homepage = "https://github.com/estrec/estrec"
|
|
46
|
+
Specification = "https://github.com/estrec/estrec/blob/main/spec/estrec.md"
|
|
47
|
+
Schemas = "https://estrec.org/schema/"
|
|
48
|
+
Issues = "https://github.com/estrec/estrec/issues"
|
|
49
|
+
|
|
50
|
+
[tool.setuptools]
|
|
51
|
+
# schema/ at the top of the repository is the one copy; the wheel carries it as
|
|
52
|
+
# estrec/schema, where records.PACKAGED_SCHEMAS finds it
|
|
53
|
+
packages = ["estrec", "estrec.schema"]
|
|
54
|
+
|
|
55
|
+
[tool.setuptools.package-dir]
|
|
56
|
+
"" = "src"
|
|
57
|
+
"estrec.schema" = "schema"
|
|
58
|
+
|
|
59
|
+
[tool.setuptools.package-data]
|
|
60
|
+
"estrec.schema" = ["*.json", "LICENSE", "profiles/*.json", "examples/*.json", "examples/*.jsonl"]
|
|
61
|
+
|
|
62
|
+
[tool.setuptools.dynamic]
|
|
63
|
+
version = { attr = "estrec.__version__" }
|
|
64
|
+
|
|
65
|
+
[tool.pytest.ini_options]
|
|
66
|
+
testpaths = ["tests"]
|
|
67
|
+
|
|
68
|
+
[tool.ruff]
|
|
69
|
+
line-length = 110
|
|
70
|
+
target-version = "py310"
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
The estrec format's schemas, catalog and example records (this folder and
|
|
2
|
+
its subfolders) are dedicated to the public domain under CC0 1.0 Universal.
|
|
3
|
+
|
|
4
|
+
To the extent possible under law, Ted Matherly and the contributors have
|
|
5
|
+
waived all copyright and related or neighboring rights to the files in this
|
|
6
|
+
folder. You can copy, modify, distribute and embed them, including in other
|
|
7
|
+
software and under any license, without asking permission or giving credit.
|
|
8
|
+
|
|
9
|
+
SPDX-License-Identifier: CC0-1.0
|
|
10
|
+
Source: https://creativecommons.org/publicdomain/zero/1.0/
|
|
11
|
+
|
|
12
|
+
The rest of dfeols is licensed under GPL-3.0-or-later (../../../LICENSE).
|
|
13
|
+
|
|
14
|
+
The CC0 1.0 legal code follows.
|
|
15
|
+
|
|
16
|
+
-------------------------------------------------------------------------------
|
|
17
|
+
|
|
18
|
+
Creative Commons Legal Code
|
|
19
|
+
|
|
20
|
+
CC0 1.0 Universal
|
|
21
|
+
|
|
22
|
+
CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE
|
|
23
|
+
LEGAL SERVICES. DISTRIBUTION OF THIS DOCUMENT DOES NOT CREATE AN
|
|
24
|
+
ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS
|
|
25
|
+
INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES
|
|
26
|
+
REGARDING THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS
|
|
27
|
+
PROVIDED HEREUNDER, AND DISCLAIMS LIABILITY FOR DAMAGES RESULTING FROM
|
|
28
|
+
THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS PROVIDED
|
|
29
|
+
HEREUNDER.
|
|
30
|
+
|
|
31
|
+
Statement of Purpose
|
|
32
|
+
|
|
33
|
+
The laws of most jurisdictions throughout the world automatically confer
|
|
34
|
+
exclusive Copyright and Related Rights (defined below) upon the creator
|
|
35
|
+
and subsequent owner(s) (each and all, an "owner") of an original work of
|
|
36
|
+
authorship and/or a database (each, a "Work").
|
|
37
|
+
|
|
38
|
+
Certain owners wish to permanently relinquish those rights to a Work for
|
|
39
|
+
the purpose of contributing to a commons of creative, cultural and
|
|
40
|
+
scientific works ("Commons") that the public can reliably and without fear
|
|
41
|
+
of later claims of infringement build upon, modify, incorporate in other
|
|
42
|
+
works, reuse and redistribute as freely as possible in any form whatsoever
|
|
43
|
+
and for any purposes, including without limitation commercial purposes.
|
|
44
|
+
These owners may contribute to the Commons to promote the ideal of a free
|
|
45
|
+
culture and the further production of creative, cultural and scientific
|
|
46
|
+
works, or to gain reputation or greater distribution for their Work in
|
|
47
|
+
part through the use and efforts of others.
|
|
48
|
+
|
|
49
|
+
For these and/or other purposes and motivations, and without any
|
|
50
|
+
expectation of additional consideration or compensation, the person
|
|
51
|
+
associating CC0 with a Work (the "Affirmer"), to the extent that he or she
|
|
52
|
+
is an owner of Copyright and Related Rights in the Work, voluntarily
|
|
53
|
+
elects to apply CC0 to the Work and publicly distribute the Work under its
|
|
54
|
+
terms, with knowledge of his or her Copyright and Related Rights in the
|
|
55
|
+
Work and the meaning and intended legal effect of CC0 on those rights.
|
|
56
|
+
|
|
57
|
+
1. Copyright and Related Rights. A Work made available under CC0 may be
|
|
58
|
+
protected by copyright and related or neighboring rights ("Copyright and
|
|
59
|
+
Related Rights"). Copyright and Related Rights include, but are not
|
|
60
|
+
limited to, the following:
|
|
61
|
+
|
|
62
|
+
i. the right to reproduce, adapt, distribute, perform, display,
|
|
63
|
+
communicate, and translate a Work;
|
|
64
|
+
ii. moral rights retained by the original author(s) and/or performer(s);
|
|
65
|
+
iii. publicity and privacy rights pertaining to a person's image or
|
|
66
|
+
likeness depicted in a Work;
|
|
67
|
+
iv. rights protecting against unfair competition in regards to a Work,
|
|
68
|
+
subject to the limitations in paragraph 4(a), below;
|
|
69
|
+
v. rights protecting the extraction, dissemination, use and reuse of data
|
|
70
|
+
in a Work;
|
|
71
|
+
vi. database rights (such as those arising under Directive 96/9/EC of the
|
|
72
|
+
European Parliament and of the Council of 11 March 1996 on the legal
|
|
73
|
+
protection of databases, and under any national implementation
|
|
74
|
+
thereof, including any amended or successor version of such
|
|
75
|
+
directive); and
|
|
76
|
+
vii. other similar, equivalent or corresponding rights throughout the
|
|
77
|
+
world based on applicable law or treaty, and any national
|
|
78
|
+
implementations thereof.
|
|
79
|
+
|
|
80
|
+
2. Waiver. To the greatest extent permitted by, but not in contravention
|
|
81
|
+
of, applicable law, Affirmer hereby overtly, fully, permanently,
|
|
82
|
+
irrevocably and unconditionally waives, abandons, and surrenders all of
|
|
83
|
+
Affirmer's Copyright and Related Rights and associated claims and causes
|
|
84
|
+
of action, whether now known or unknown (including existing as well as
|
|
85
|
+
future claims and causes of action), in the Work (i) in all territories
|
|
86
|
+
worldwide, (ii) for the maximum duration provided by applicable law or
|
|
87
|
+
treaty (including future time extensions), (iii) in any current or future
|
|
88
|
+
medium and for any number of copies, and (iv) for any purpose whatsoever,
|
|
89
|
+
including without limitation commercial, advertising or promotional
|
|
90
|
+
purposes (the "Waiver"). Affirmer makes the Waiver for the benefit of each
|
|
91
|
+
member of the public at large and to the detriment of Affirmer's heirs and
|
|
92
|
+
successors, fully intending that such Waiver shall not be subject to
|
|
93
|
+
revocation, rescission, cancellation, termination, or any other legal or
|
|
94
|
+
equitable action to disrupt the quiet enjoyment of the Work by the public
|
|
95
|
+
as contemplated by Affirmer's express Statement of Purpose.
|
|
96
|
+
|
|
97
|
+
3. Public License Fallback. Should any part of the Waiver for any reason
|
|
98
|
+
be judged legally invalid or ineffective under applicable law, then the
|
|
99
|
+
Waiver shall be preserved to the maximum extent permitted taking into
|
|
100
|
+
account Affirmer's express Statement of Purpose. In addition, to the
|
|
101
|
+
extent the Waiver is so judged Affirmer hereby grants to each affected
|
|
102
|
+
person a royalty-free, non transferable, non sublicensable, non exclusive,
|
|
103
|
+
irrevocable and unconditional license to exercise Affirmer's Copyright and
|
|
104
|
+
Related Rights in the Work (i) in all territories worldwide, (ii) for the
|
|
105
|
+
maximum duration provided by applicable law or treaty (including future
|
|
106
|
+
time extensions), (iii) in any current or future medium and for any number
|
|
107
|
+
of copies, and (iv) for any purpose whatsoever, including without
|
|
108
|
+
limitation commercial, advertising or promotional purposes (the
|
|
109
|
+
"License"). The License shall be deemed effective as of the date CC0 was
|
|
110
|
+
applied by Affirmer to the Work. Should any part of the License for any
|
|
111
|
+
reason be judged legally invalid or ineffective under applicable law, such
|
|
112
|
+
partial invalidity or ineffectiveness shall not invalidate the remainder
|
|
113
|
+
of the License, and in such case Affirmer hereby affirms that he or she
|
|
114
|
+
will not (i) exercise any of his or her remaining Copyright and Related
|
|
115
|
+
Rights in the Work or (ii) assert any associated claims and causes of
|
|
116
|
+
action with respect to the Work, in either case contrary to Affirmer's
|
|
117
|
+
express Statement of Purpose.
|
|
118
|
+
|
|
119
|
+
4. Limitations and Disclaimers.
|
|
120
|
+
|
|
121
|
+
a. No trademark or patent rights held by Affirmer are waived, abandoned,
|
|
122
|
+
surrendered, licensed or otherwise affected by this document.
|
|
123
|
+
b. Affirmer offers the Work as-is and makes no representations or
|
|
124
|
+
warranties of any kind concerning the Work, express, implied,
|
|
125
|
+
statutory or otherwise, including without limitation warranties of
|
|
126
|
+
title, merchantability, fitness for a particular purpose, non
|
|
127
|
+
infringement, or the absence of latent or other defects, accuracy, or
|
|
128
|
+
the present or absence of errors, whether or not discoverable, all to
|
|
129
|
+
the greatest extent permissible under applicable law.
|
|
130
|
+
c. Affirmer disclaims responsibility for clearing rights of other persons
|
|
131
|
+
that may apply to the Work or any use thereof, including without
|
|
132
|
+
limitation any person's Copyright and Related Rights in the Work.
|
|
133
|
+
Further, Affirmer disclaims responsibility for obtaining any necessary
|
|
134
|
+
consents, permissions or other rights required for any use of the
|
|
135
|
+
Work.
|
|
136
|
+
d. Affirmer understands and acknowledges that Creative Commons is not a
|
|
137
|
+
party to this document and has no duty or obligation with respect to
|
|
138
|
+
this CC0 or use of the Work.
|