How PyMetrix works¶
PyMetrix rests on four ideas. Each is a choice about how the pieces fit together, and each is there so that work can be changed, shown and checked without being redone.
- Data, model, method and result are separate objects, so you can swap the method or the sample without rewriting anything else.
- A result is a value that remembers how it was made.
- One result, every surface: the same result shows in the desktop app, a notebook, a report, a saved project and generated Python.
- Every click is code: dialogs, notebooks, project replay and AI agents all run the same recorded commands.
Separate pieces, so you change one at a time¶
Every piece of an analysis is an object of its own, and no object mixes two jobs:
- the data: a dataset of series, with their units, sources and release dates;
- what is estimated or solved: an equation or a model, written as a formula such as
c ~ y + c[-1]; - how: the method or solver and its settings, such as ordinary least squares with robust standard errors;
- what came out: the result.
Because they are separate, a change touches one piece only. Here the same equation is estimated three ways:
from pymetrix import OLS, Dataset, Equation
data = Dataset.example("sample_macro") # the data
eq = Equation("dlog(c) ~ dlog(y) + dlog(c)[-1]") # what to estimate
fit = eq.fit(data, method=OLS()) # how: least squares
robust = eq.fit(data, method=OLS(cov="hac")) # the same, robust errors
recent = eq.fit(data, span=("2010Q1", "2024Q4"), # the same, a later sample
method=OLS())
The same holds for models: one model, solved under several scenarios; one forecast round, compared with the last. A dialog in the app fills in the same objects, so a form and a script describe a step in the same terms.
A result remembers how it was made¶
An estimate is not a page of printed output. It is a value: its numbers are named fields a script can read, and it keeps a record of how it was made, its provenance. Nothing important exists only in a summary table or a chart.
Below is a real result, drawn from the object when this site was built: the consumption function of Estimate and test an equation, fitted on the example data installed with pymetrix.
fitFittedEquationdlog(c) ~ dlog(y) + dlog(c)[-1]fit.paramsnamed numbers, not text in a summary| coef | std err | |
|---|---|---|
const | −0.0002 | 0.0005 |
dlog(y) | 1.0446 | 0.0309 |
dlog(c)[-1] | −0.0711 | 0.0280 |
fit.statsstatistics, by name| R² | 0.9274 |
| s.e. of regression | 0.0032 |
| Durbin-Watson | 2.77 |
| observations | 98 |
fit.provenancerecorded when it was estimatedsample .sample | 2000Q3 to 2024Q4 |
observations .nobs | 98 (2 dropped, for lags) |
method .method | OLS, classic standard errors |
data .vintage_request | example data sample_macro |
data vintages .data_vintages | c, y: no release dates (example data) |
data fingerprint .data_fingerprint | 7e0cd195821d0c8f |
seed .seed | none: nothing random |
pymetrix .package_version | 0.1.0a23 |
warnings .warnings | none |
views.titles(fit)defined once, in pymetrix.views- Summary
- Graph
- Equation
- Coefficients
- Covariance
- Statistics
- Residuals
- Diagnostics
- Q-Q plot
- Correlogram
- Correlogram graph
- Provenance
session.producer("fit")a recorded command, replayed when a project opensfit = Equation('dlog(c) ~ dlog(y) + dlog(c)[-1]').fit(data, method=OLS())fit from the Estimate and test an equation page, fitted on the example data installed with pymetrix. Every line is a field a script can read.The provenance is what lets a reader check the number. Two estimates on different samples or different data releases say so, even when their coefficients look alike, and the data fingerprint changes if the data do. Estimates and model solutions record it today; Concepts lists the kinds of result that do not yet.
One result, every surface¶
What a result shows is defined once, as a list of views: a summary, a graph, the diagnostics, the provenance and so on. Each place that shows the result draws those same views. The desktop window lists them down its side; a notebook prints them; a report lays them out on the page; a saved project keeps the steps and rebuilds the result when it opens; and the generated Python says how to make it again.
So a number is the same number wherever you see it, and a new kind of result shows up everywhere once its views are written.
fitFittedEquation12 views, defined once:- Summary
- Graph
- Equation
- Coefficients
- Covariance
- Statistics
- Residuals
- Diagnostics
- Q-Q plot
- Correlogram
- Correlogram graph
- Provenance
session.script()from pymetrix import *
data = Dataset.example('sample_macro')
fit = Equation('dlog(c) ~ dlog(y) + dlog(c)[-1]').fit(data, method=OLS())fitfitdlog(c) ~ dlog(y) + dlog(c)[-1]
| coef | std err | t | p>|t| | |
|---|---|---|---|---|
| const | -0.0002 | 0.0005 | -0.3409 | 0.7339 |
| dlog(y) | 1.0446 | 0.0309 | 33.7522 | 1.0712e-54 |
| dlog(c)[-1] | -0.0711 | 0.0280 | -2.5371 | 0.0128 |
Report(...).add(fit)dlog(c) ~ dlog(y) + dlog(c)[-1]
| coef | std err | t | p>|t| | |
|---|---|---|---|---|
| const | -0.0002 | 0.0005 | -0.3409 | 0.7339 |
| dlog(y) | 1.0446 | 0.0309 | 33.7522 | 1.0712e-54 |
| dlog(c)[-1] | -0.0711 | 0.0280 | -2.5371 | 0.0128 |
Appendix: where the numbers come from
Where the numbers come from
| result | method | sample | observations | data vintages (release dates) | pymetrix |
|---|---|---|---|---|---|
| FittedEquation | OLS | 2000Q3 to 2024Q4 | 98 | not recorded | 0.1.0a23 |
Every click is code¶
A session changes only through commands. A dialog builds a command; so does a line of typed code that calls pymetrix; so does an AI agent working through pymetrix's tools. Each command is recorded in the session's history with its settings, the objects it read and wrote, and the Python it stands for.
- Dialogs show the code they ran, so the app teaches the library as you use it.
- Notebooks and scripts run the same commands, and their history exports as a script like any other.
- Projects save the data and the commands, and replay them to rebuild every result when opened. Typed code in a project runs only once you trust it.
- AI agents run the same commands through pymetrix's MCP server or the assistant plugin. Their steps land in the same history and replay the same way, and the lab book plugin records whether a person or an agent took each one.
That is what makes a number traceable. Start from any figure in a report and follow it back:
Further reading¶
- Why PyMetrix: who it is for, and why it is open.
- Concepts: every object and verb, with its name in the code. This page is a plain-terms tour of it.
- Provenance: what a result records, field by field.
- The guide: the whole of pymetrix, from data to reports.
