Home · Command reference

RainbowStats™ · Command reference

EXTRACT — Reuse a Model’s Results

Retrieve a model’s tables, charts, data series and statistics for further analysis or presentation.

EXTRACT selects one supported result from an extractable RainbowStats object. For example, a regression can provide its coefficient table, residual series, fitted series, diagnostic charts or slideshow. Other objects expose different results.

Quick start: extract a regression table

r = REGRESSION(LIST(SERIES_SINCE(UNRATE,20010101),SERIES_SINCE(U6RATE,20010101)))
EXTRACT(r,"model")

Run this example in RainbowStats

The first line estimates unemployment as a function of U-6 using their common date range from January 2001 onward. The second line displays the regression results table. The variable r retains the regression object, allowing other components to be requested from the same fitted model.

The object defines the available names. EXTRACT is a common access command; it does not give every model the same capabilities. Check the source command’s extract table before choosing a result.

Syntax and alias

EXTRACT(object,"extract_name")
EX(object,"extract_name")
result = EXTRACT(object,"extract_name")
ArgumentMeaning
objectAn extractable result object, such as a regression, threshold regression or matched comparison. Usually a variable assigned by a previous command; a nested model expression can also be used.
"extract_name"A result name supported by that object. Use quoted strings, for example "residuals", "model" or "threshold".
resultOptional variable receiving the returned object. Its type depends on the requested extract.

EX is the shorthand alias for EXTRACT. The examples use lowercase extract names. The regression, threshold-regression and matched-comparison operators shown here accept names case-insensitively.

This page describes named extraction. Some object types may provide other selectors or specialized forms; use their own command documentation for those interfaces. A numeric selector is not a universal substitute for a named extract.

Extract directly from a nested model

EXTRACT(REGRESSION(LIST(UNRATE,U6RATE)),"model")

Assigning the model to a variable is clearer when you need several extracts and avoids explicitly recreating the model expression for each request.

What EXTRACT returns

The return type determines the appropriate next operation. An extract can return a reusable data object or an already prepared display.

Return typeVerified exampleHow to use it
Data seriesEXTRACT(r,"residuals")Pass to LINE_CHART, date selection, transformations or other operations that accept series.
Data seriesEXTRACT(r,"fitted")Reuse or chart the regression’s in-sample fitted values.
Table / HTML panelEXTRACT(r,"model")Display directly or include in SLIDESHOW.
ChartEXTRACT(r,"actualvsfitted")Display directly or include in SLIDESHOW; it is already a chart.
Numeric arrayEXTRACT(r,"beta")Inspect the coefficient values; consult the regression documentation for ordering and meaning.
NumberEXTRACT(m,"effect")Display or use the matched comparison’s average difference in a numeric calculation.
NumberEXTRACT(tr,"threshold")Retrieve the threshold-regression cutoff in the split variable’s units.
SlideshowEXTRACT(r,"slideshow")Display the model’s prepared presentation.
A series and a chart are different objects. LINE_CHART(EXTRACT(r,"residuals")) creates a chart from a residual series. EXTRACT(r,"actualvsfitted") already returns a chart. Similarly, a table panel is not a numeric array.

Choose the extract for the specific model

Names can look similar while returning different kinds of results. These distinctions are especially useful when constructing scripts automatically:

ObjectExtractMeaning
Linear regression r"model"Conventional regression results table.
Linear regression r"hac"Newey–West HAC coefficient-results table. This is not a separate fitted model.
Linear regression r"actualvsfitted"Actual-versus-fitted chart. The name has no underscores.
Linear regression r"betase"Conventional coefficient standard-error array, including after a separate HAC extraction.
Matched comparison m"pairs"Matched-pair table.
Matched comparison m"matched_pairs"Number of matched pairs.
Matched comparison m"differences"Paired-difference chart; not a raw difference series.
Threshold regression tr"pooled_residuals"Residual data series from the pooled regression, not the two-regime fit.
Searched threshold regression tr"ssr_profile"Chart of combined SSR across candidate thresholds. Unavailable for a fixed threshold.

An alias is supported only where the source object implements it. For instance, summary is an alias of model for matched comparisons and threshold regressions, but it is not a supported name in the supplied linear-regression operator.

Examples: extract, reuse and present

Chart a reusable residual series

r = REGRESSION(LIST(SERIES_SINCE(UNRATE,20010101),SERIES_SINCE(U6RATE,20010101)))
residuals = EXTRACT(r,"residuals")
LINE_CHART(residuals)

The variable residuals holds data, so subsequent series operations can use it. Extracting it does not replace the regression stored in r.

Display an existing chart

r = REGRESSION(LIST(SERIES_SINCE(UNRATE,20010101),SERIES_SINCE(U6RATE,20010101)))
EXTRACT(r,"actualvsfitted")

Build a diagnostic slideshow

r = REGRESSION(LIST(SERIES_SINCE(UNRATE,20010101),SERIES_SINCE(U6RATE,20010101)))
SLIDESHOW(EXTRACT(r,"model"),EXTRACT(r,"hac"),EXTRACT(r,"actualvsfitted"),LINE_CHART(EXTRACT(r,"residuals")),EXTRACT(r,"autocorrelation"))

This combines the conventional coefficient table, HAC coefficient table, actual-versus-fitted chart, residual chart and residual autocorrelation analysis. Each requested extract is supported by REGRESSION.

Read a coefficient array

r = REGRESSION(LIST(SERIES_SINCE(UNRATE,20010101),SERIES_SINCE(U6RATE,20010101)))
EXTRACT(r,"beta")

For this standard one-predictor regression, the array is ordered [constant, slope]. It contains coefficients, not a fitted time series. Use EX(r,"betase") for the corresponding conventional standard-error array.

Extract a matched-comparison statistic

m = MATCHED_COMPARISON(LIST(SERIES_SINCE(UNRATE,20010101),SERIES_SINCE(JTSJOR,20010101),SERIES_SINCE(TCU,20010101)),1,4,0.25)
EXTRACT(m,"effect")

This returns the mean unemployment difference between matched above-threshold and control observations. Because unemployment is expressed in percent, the outcome difference is in percentage points. It is a descriptive matched difference; causal interpretation requires an appropriate research design.

Extract a searched threshold

tr = THRESHOLD_REGRESSION(LIST(SERIES_SINCE(UNRATE,20010101),SERIES_SINCE(U6RATE,20010101)),1,36)
EXTRACT(tr,"threshold")

This returns the selected U-6 cutoff as a number. To display the search curve instead, request "ssr_profile". To display all prepared diagnostics, request "slideshow".

Model-specific extract references

Use each model’s command description as the authoritative list of supported names, aliases, types and restrictions:

CommandExtract reference
REGRESSIONRegression extracts — coefficients, fitted values, residuals, HAC results, diagnostics and Wald restrictions.
MATCHED_COMPARISONMatched-comparison extracts — balance, pairs, charts, average difference and uncertainty.
THRESHOLD_REGRESSION
FIXED_THRESHOLD_REGRESSION
Threshold-regression extracts — regime tables, cutoff, SSR comparisons and pooled residuals.

For other extractable objects—including time-series models, forests, distributions and multivariate analyses—consult that command’s own documentation. The examples above do not imply that the same extract names are available across those families.

Common mistakes and troubleshooting

IssueWhat to check
Unsupported nameCheck the exact model-specific spelling and aliases. Do not infer a name from a chart title or another model’s API.
A message appears instead of a resultAn unsupported extract may return an explanatory string or error object, sometimes listing alternatives. Successful script execution alone does not establish that the intended result was returned.
A name is missing from an error messageSome operator help lists are incomplete. Consult the maintained extract table and current implementation; absence from an error list is not conclusive.
A chart is passed to a series operationChoose an extract that returns a data series, or display the prepared chart directly.
A fixed threshold has no profileA fixed-threshold model does not search candidate cutoffs. Use its model and regime-table extracts instead.
A requested capability is absentExtraction only accesses implemented results. It does not add HAC inference, forecasting, a p-value or a new statistical test to an object.
No result is shownFor MCP scripts, put the result you want displayed on the final line. Assignment stores a value for reuse; end with the desired variable or display expression.

Keep the model object. Assign the original result to a stable name such as r, m or tr, and store extracted components under different names. Replacing r with its residual series leaves that variable holding a series instead of the regression.

Interpret the source result correctly. Extraction does not change whether values are in-sample, whether uncertainty is conventional or HAC-adjusted, or whether a comparison supports causal inference. Those properties belong to the underlying model and requested result.