solow_summary/lib.rs
1//! # solow-summary
2//!
3//! Labeled regression-results summary tables for Solow models -- the rendered,
4//! human-readable companion to a fitted model's numeric results.
5//!
6//! The crate is deliberately model-agnostic: a [`RegressionSummary`] is built
7//! from plain values (parameter names, estimates, standard errors, test
8//! statistics, p-values, confidence intervals, and a set of header
9//! statistics), so the results of *any* estimator can be rendered without this
10//! crate depending on that estimator's crate.
11//!
12//! ## Layout
13//!
14//! A summary renders as two stacked fixed-width text blocks:
15//!
16//! 1. a **header block** of key statistics, and
17//! 2. a **coefficient table** with columns `coef`, `std err`, the test
18//! statistic (`t` or `z`), the corresponding p-value, and the lower/upper
19//! confidence-interval bounds.
20//!
21//! Both blocks are produced by the general [`SummaryTable`] type, which lays
22//! out titled, optionally-headered, row-based tables with right-aligned
23//! (or per-column left-aligned) fixed-width columns.
24//!
25//! The *visual layout* here is Solow's own. Only the displayed *numbers* are
26//! cross-checked against a reference implementation (see the crate's
27//! `tests/reference.rs`).
28//!
29//! ## Example
30//!
31//! ```
32//! use solow_summary::{HeaderStats, RegressionSummary};
33//!
34//! let names = ["const", "x1"];
35//! let params = [1.5, -2.0];
36//! let bse = [0.07, 0.08];
37//! let tvalues = [21.4, -25.0];
38//! let pvalues = [1e-20, 1e-22];
39//! let conf_int = [(1.35, 1.65), (-2.16, -1.84)];
40//!
41//! let header = HeaderStats {
42//! model: Some("OLS".into()),
43//! nobs: Some(40.0),
44//! rsquared: Some(0.95),
45//! aic: Some(45.9),
46//! bic: Some(51.0),
47//! ..HeaderStats::new()
48//! };
49//!
50//! let summary =
51//! RegressionSummary::new(&names, ¶ms, &bse, &tvalues, &pvalues, &conf_int, header);
52//! let text = summary.to_string();
53//! assert!(text.contains("R-squared:"));
54//! assert!(text.contains("const"));
55//! ```
56
57mod format;
58mod regression;
59mod table;
60
61pub use format::{format_fixed, format_g, format_pvalue};
62pub use regression::{HeaderStats, RegressionSummary, StatKind};
63pub use table::{Align, SummaryTable};