Parameter inference¶
This page documents 5 public symbols. Each entry includes its purpose, import path, full API docstring, and the maintained example that exercises it.
ParameterInference¶
One local coefficient surface with inference arrays.
| Property | Value |
|---|---|
| Type | class |
| Import | from pygwrx.diagnostics import ParameterInference |
| Signature | ParameterInference(values: 'np.ndarray', statistic: 'Optional[np.ndarray]', standard_error: 'Optional[np.ndarray]', label: 'str', parameter_index: 'int', distribution: 'str') -> None |
| Maintained example | examples/diagnostics/02_inference_and_collinearity.py |
ParameterInference
dataclass
¶
ParameterInference(
values: ndarray,
statistic: Optional[ndarray],
standard_error: Optional[ndarray],
label: str,
parameter_index: int,
distribution: str,
)
One local coefficient surface with inference arrays.
adjust_pvalues¶
Adjust p values using Bonferroni, BH, or BY correction.
| Property | Value |
|---|---|
| Type | function |
| Import | from pygwrx.diagnostics import adjust_pvalues |
| Signature | adjust_pvalues(p_values: 'Sequence[float]', method: 'str' = 'bh') -> 'np.ndarray' |
| Maintained example | examples/diagnostics/02_inference_and_collinearity.py |
adjust_pvalues ¶
Adjust p values using Bonferroni, BH, or BY correction.
Source code in src/pygwrx/diagnostics/inference.py
feature_names¶
Return stable predictor names for a fitted model.
| Property | Value |
|---|---|
| Type | function |
| Import | from pygwrx.diagnostics import feature_names |
| Signature | feature_names(model: 'Any') -> 'Tuple[str, ...]' |
| Maintained example | examples/diagnostics/02_inference_and_collinearity.py |
feature_names ¶
Return stable predictor names for a fitted model.
Source code in src/pygwrx/diagnostics/inference.py
parameter_inference¶
Extract a coefficient, test statistic, and standard error surface.
| Property | Value |
|---|---|
| Type | function |
| Import | from pygwrx.diagnostics import parameter_inference |
| Signature | parameter_inference(model: 'Any', feature: 'FeatureLike') -> 'ParameterInference' |
| Maintained example | examples/diagnostics/02_inference_and_collinearity.py |
parameter_inference ¶
Extract a coefficient, test statistic, and standard error surface.
The extractor understands both split attributes such as coef_t_ and
full parameter matrices such as parameter_t_values_ or t_values_.
This keeps inference consistent across GWR, GWGLM, MGTWR, ScalableGWR,
SGWR, STWR, and SGTWR.
Source code in src/pygwrx/diagnostics/inference.py
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 | |
parameter_significance¶
Return coefficient values, p values, and significance categories.
| Property | Value |
|---|---|
| Type | function |
| Import | from pygwrx.diagnostics import parameter_significance |
| Signature | parameter_significance(model: 'Any', feature: 'FeatureLike', *, alpha: 'float' = 0.05, correction: 'str' = 'adjusted') -> 'pd.DataFrame' |
| Maintained example | examples/diagnostics/02_inference_and_collinearity.py |
parameter_significance ¶
parameter_significance(
model: Any,
feature: FeatureLike,
*,
alpha: float = 0.05,
correction: str = "adjusted"
) -> pd.DataFrame
Return coefficient values, p values, and significance categories.
Source code in src/pygwrx/diagnostics/inference.py
Runnable examples used on this page¶
examples/diagnostics/02_inference_and_collinearity.py
# SPDX-FileCopyrightText: 2026 Jinghao Hu
# SPDX-License-Identifier: MIT
"""Use coefficient inference, multiple-testing correction, and collinearity tools."""
# Allow this script to run directly from any working directory.
import sys
from pathlib import Path
_PROJECT_ROOT = Path(__file__).resolve().parents[2]
_EXAMPLES_ROOT = _PROJECT_ROOT / "examples"
_SRC_ROOT = _PROJECT_ROOT / "src"
for _path in (_SRC_ROOT, _EXAMPLES_ROOT):
if str(_path) not in sys.path:
sys.path.insert(0, str(_path))
import numpy as np
from _common import collinear_regression
from pygwrx import GWR
from pygwrx.diagnostics import (
LocalCollinearityDiagnostics,
ParameterInference,
adjust_pvalues,
feature_names,
parameter_inference,
parameter_significance,
)
X, y, coords = collinear_regression(n=44)
model = GWR(bandwidth=24, adaptive=True).fit(X, y, coords)
view = parameter_inference(model, "x1")
assert isinstance(view, ParameterInference)
print("feature_names=", feature_names(model))
print("inference_label=", view.label)
print(parameter_significance(model, "x1", correction="bh").head())
print("adjusted=", adjust_pvalues(np.array([0.01, 0.04, 0.2, 0.8]), method="bh"))
collinearity = LocalCollinearityDiagnostics(model)
print(collinearity.summary_frame().head())
print("vif_shape=", collinearity.compute_vif().shape)
print("vdp_shape=", collinearity.compute_vdp().shape)
print("correlation_shape=", collinearity.compute_local_correlations().shape)
print("condition_numbers=", collinearity.compute_condition_number()[:5])
print("diagnosis_keys=", sorted(collinearity.diagnose(verbose=False)))