ehs-risk-sem
Back to ehs-risk-sem

diagnostics

AssumptionReport

AssumptionReport(checks: 'Dict[str, dict]' = <factory>, tables: 'Dict[str, pd.DataFrame]' = <factory>, flags: 'List[str]' = <factory>) -> None

Collected assumption checks with a plain-language status for each.

bartlett_sphericity

bartlett_sphericity(data: 'np.ndarray') -> 'dict'

Bartlett's test that the correlation matrix is an identity matrix.

A necessary precondition for factor analysis to be sensible: if the indicators are mutually uncorrelated there is no common factor to extract. Rejecting the null is a very low bar and passing it proves nothing.

formative_indicator_check

formative_indicator_check(data: 'np.ndarray', blocks: 'Dict[str, Sequence[int]]', threshold: 'float' = 0.3) -> 'pd.DataFrame'

Flag blocks whose indicators are too weakly intercorrelated to be reflective.

A reflective measurement model says the latent variable causes its indicators, so the indicators must correlate. A formative construct is defined by its indicators -- equipment age, overdue preventive maintenance and alarm rate jointly constitute "system condition" and need not correlate at all. Modelling the second as though it were the first is a specification error with substantial bias in the structural parameters.

This function reports the mean absolute within-block correlation. Below ``threshold`` it flags the block. That flag is a prompt to think about the direction of measurement, not a verdict: the question is causal and cannot be answered from a correlation matrix.

harman_single_factor

harman_single_factor(data: 'np.ndarray') -> 'dict'

Share of variance explained by the first unrotated factor.

Reported with its own refutation attached. This is not a valid test for common method bias: it has low power, no defensible threshold, and passing it does not rule out method variance. If method effects are a concern, the design must address them; a post-hoc statistic cannot.

kmo

kmo(data: 'np.ndarray') -> 'dict'

Kaiser-Meyer-Olkin measure of sampling adequacy.

The ratio of squared correlations to squared correlations plus squared partial correlations, overall and per variable. Low values mean the correlations between variables are largely explained by other variables, so a common-factor model is a poor description.

linearity_check

linearity_check(x: 'np.ndarray', y: 'np.ndarray') -> 'dict'

Incremental variance explained by a quadratic term over a linear fit.

The structural model is linear in the latent variables. If a squared term adds materially to the fit, the linear coefficient is a summary of a nonlinear relation and should not be read as a constant effect.

mardia

mardia(data: 'np.ndarray') -> 'dict'

Mardia's multivariate skewness and kurtosis tests.

The chi-square reference distribution used by every fit index in this package assumes multivariate normal indicators. Departures inflate the chi-square and deflate the standard errors, so a rejected normality test means the reported fit statistics are optimistic about the model and the standard errors are optimistic about precision.

run_all_checks

run_all_checks(data: 'pd.DataFrame', blocks: 'Dict[str, Sequence[str]]') -> 'AssumptionReport'

Run every assumption check for a model specification.

Parameters ---------- data Wide DataFrame of indicators. blocks Mapping from latent name to indicator column names.

vif

vif(data: 'np.ndarray', names: 'Sequence[str]') -> 'pd.DataFrame'

Variance inflation factor for each column against all the others.