Skip to content

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.

  1. Data, model, method and result are separate objects, so you can swap the method or the sample without rewriting anything else.
  2. A result is a value that remembers how it was made.
  3. One result, every surface: the same result shows in the desktop app, a notebook, a report, a saved project and generated Python.
  4. Every click is code: dialogs, notebooks, project replay and AI agents all run the same recorded commands.
How the pieces fit. Three separate inputs: data (a Dataset, with vintages and a sample), a specification (an Equation, Model or Scenario) and settings (OLS, IV, Bayes and other methods, solvers and filters). They go into a verb: fit, solve or forecast. Out comes a result: a value holding estimates, paths or tests, plus its provenance (data, sample, method, seed, version and a fingerprint of the data). The result's views, defined once in pymetrix.views, are shown in a desktop window, a notebook, a report, a saved project and generated Python. Every step is a recorded command: command, history, project file, replay. Replaying the steps rebuilds the result. Dialogs, notebooks, scripts and AI agents run the same commands. Data Dataset, vintages, a sample Specification Equation, Model, Scenario Settings OLS, IV, Bayes, … solvers, filters fit solve forecast Result a value: estimates, paths, tests + provenance data, sample, method, seed, version, a fingerprint of the data Views pymetrix.views defined once, shown in a desktop window, a notebook, a report, a saved project and generated Python each step recorded replay rebuilds it Every step is a recorded command Command → history → project file (.pymx) → replay dialogs, notebooks, scripts and AI agents run the same commands How the pieces fit. Three separate inputs: data (a Dataset, vintages, a sample), a specification (an Equation, Model or Scenario) and settings (OLS, IV, Bayes, solvers). They go into fit, solve or forecast. Out comes a result: a value holding estimates, paths or tests, plus its provenance (data, sample, method, seed, version and a fingerprint of the data). Its views, defined once in pymetrix.views, are shown in a window, a notebook, a report, a project and generated Python. Every step is a recorded command: command, history, project file, replay. Dialogs, notebooks, scripts and AI agents run the same commands. Data Dataset, vintages, a sample Specification Equation, Model, Scenario Settings OLS, IV, Bayes, … solvers fit · solve · forecast Result a value: estimates, paths, tests + provenance data, sample, method, seed, version, a fingerprint of the data Views pymetrix.views, defined once a window, a notebook, a report, a project and generated Python recorded, replayed Every step is a recorded command Command → history → project (.pymx) → replay dialogs, notebooks, scripts and AI agents run the same commands
Data, the specification and the settings stay separate; a verb brings them together and returns a result that knows how it was made. Every step is recorded, so the whole chain can be replayed.

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]
1What it estimatedfit.paramsnamed numbers, not text in a summary
coefstd err
const−0.00020.0005
dlog(y)1.04460.0309
dlog(c)[-1]−0.07110.0280
2How well it fitsfit.statsstatistics, by name
R²0.9274
s.e. of regression0.0032
Durbin-Watson2.77
observations98
3How it was madefit.provenancerecorded when it was estimated
sample .sample2000Q3 to 2024Q4
observations .nobs98 (2 dropped, for lags)
method .methodOLS, classic standard errors
data .vintage_requestexample data sample_macro
data vintages .data_vintagesc, y: no release dates (example data)
data fingerprint .data_fingerprint7e0cd195821d0c8f
seed .seednone: nothing random
pymetrix .package_version0.1.0a23
warnings .warningsnone
4How it shows itselfviews.titles(fit)defined once, in pymetrix.views
  • Summary
  • Graph
  • Equation
  • Coefficients
  • Covariance
  • Statistics
  • Residuals
  • Diagnostics
  • Q-Q plot
  • Correlogram
  • Correlogram graph
  • Provenance
5The step that made itsession.producer("fit")a recorded command, replayed when a project opens
fit = Equation('dlog(c) ~ dlog(y) + dlog(c)[-1]').fit(data, method=OLS())
A real result, drawn when this site was built: 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.

one resultfitFittedEquation12 views, defined once:
  • Summary
  • Graph
  • Equation
  • Coefficients
  • Covariance
  • Statistics
  • Residuals
  • Diagnostics
  • Q-Q plot
  • Correlogram
  • Correlogram graph
  • Provenance
Desktop windowView → Diagnostics
The desktop app's window for fit on its Diagnostics view: Breusch-Godfrey, Breusch-Pagan, Jarque-Bera and RESET tests with their statistics and p-values.
Pythonsession.script()
from pymetrix import *
data = Dataset.example('sample_macro')
fit = Equation('dlog(c) ~ dlog(y) + dlog(c)[-1]').fit(data, method=OLS())
Notebookfit
In [3]:fit

dlog(c) ~ dlog(y) + dlog(c)[-1]

coefstd errtp>|t|
const-0.00020.0005-0.34090.7339
dlog(y)1.04460.030933.75221.0712e-54
dlog(c)[-1]-0.07110.0280-2.53710.0128
ReportReport(...).add(fit)

dlog(c) ~ dlog(y) + dlog(c)[-1]

coefstd errtp>|t|
const-0.00020.0005-0.34090.7339
dlog(y)1.04460.030933.75221.0712e-54
dlog(c)[-1]-0.07110.0280-2.53710.0128

Appendix: where the numbers come from

Where the numbers come from

resultmethodsampleobservationsdata vintages (release dates)pymetrix
FittedEquationOLS2000Q3 to 2024Q498not recorded0.1.0a23
Drawn from the same object when this site was built. The window, the notebook's output and the report are all made from its views (the notebook's shown up to its coefficients); the script is the history of the steps that made it.

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:

Tracing a number back. The coefficient 1.0446 in a report comes from the result fit, a FittedEquation estimated by OLS on 2000Q3 to 2024Q4, 98 observations. The result was made by a recorded step, fit = Equation('dlog(c) ~ dlog(y) + dlog(c)[-1]').fit(data, method=OLS()), which is replayed when the project opens. The step read the data: sample_macro, data fingerprint 7e0cd195821d0c8f, with release dates where the source gives them. An analyst, through a dialog, script or notebook, and an AI agent, through the MCP tools or the assistant plugin, both run that same recorded command: same history, same script, same replay, and the lab book plugin notes who acted. 1234 In the report 1.0446 the coefficient on dlog(y) The result fit FittedEquation 2000Q3 to 2024Q4 98 observations, OLS The step replayed on opening The data sample_macro fingerprint 7e0cd195821d0c8f vintages: release dates, where given fit = Equation(   'dlog(c) ~ …')   .fit(data,   method=OLS()) comesfrom madeby read Ask of any number: where did it come from? Each link is a field a script can read. An analyst dialog, script or notebook An AI agent MCP tools or the assistant plugin runs runs The same recorded command, whoever runs it same history, same script, same replay; the lab book plugin notes who acted Tracing a number back. The coefficient 1.0446 in a report comes from the result fit, a FittedEquation estimated by OLS on 2000Q3 to 2024Q4, 98 observations. The result was made by a recorded step, fit = Equation('dlog(c) ~ dlog(y) + dlog(c)[-1]').fit(data, method=OLS()), run by an analyst (dialog, script or notebook) or an AI agent (MCP tools or the assistant plugin). The step read the data: sample_macro, data fingerprint 7e0cd195821d0c8f, with release dates where the source gives them. Whoever runs it, it is the same recorded command: same history, same script, same replay, and the lab book plugin notes who acted. comes from made by read 1 · In the report 1.0446 the coefficient on dlog(y) 2 · The result fitFittedEquation sample 2000Q3 to 2024Q4, 98 observations OLS; its provenance kept with it 3 · The step replayed on opening; run by An analyst dialog, script, notebook An AI agent MCP tools, assistant 4 · The data sample_macro fingerprint 7e0cd195821d0c8f vintages: release dates, where given fit = Equation('dlog(c) ~ dlog(y)     + dlog(c)[-1]').fit(data,     method=OLS()) The same recorded command, whoever runs it same history, same script, same replay; the lab book plugin notes who acted
Trace a number back: from the report to the result, the step that made it, and the data it read. A person and an AI agent leave the same trail.

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.