model
ModelSpec
Declaration of a structural equation model.
Parameters ---------- latents Ordered mapping from latent variable name to its indicator column names. Order determines the order of rows and columns in ``Phi``. paths Mapping from each endogenous latent name to the latents that point directly into it. Latents absent from this mapping are exogenous.
Example ------- >>> spec = ModelSpec( ... latents={ ... "OperationalStress": ["ot_hours", "backlog", "staffing_gap"], ... "SystemCondition": ["equip_age", "pm_overdue", "alarm_rate"], ... "IncidentRate": ["trir", "dart", "near_miss"], ... }, ... paths={"IncidentRate": ["OperationalStress", "SystemCondition"]}, ... )
SEMResults
Everything a fitted model produced, including what went wrong.
bootstrap_paths
Nonparametric bootstrap of the structural coefficients.
Resamples rows with replacement and refits the entire model -- measurement model included -- so the resulting interval carries the uncertainty in the estimated loadings and reliabilities that the analytic standard errors ignore.
Returns a DataFrame with the point estimate, the bootstrap standard error, and percentile interval bounds. Replications that fail to fit are counted in the ``n_failed`` column rather than being silently discarded.
fit
Estimate a model.
Parameters ---------- spec Model declaration. data Wide DataFrame with one column per indicator. Rows with any missing indicator are dropped, and the number dropped is reported as a warning; this package does not implement FIML or multiple imputation, and pretending listwise deletion is harmless would be dishonest. repair_improper_phi When the disattenuated latent correlation matrix is indefinite, project it onto the positive-definite cone so that estimation can continue. The repair is always recorded in ``SEMResults.phi_repaired`` and in the warnings, because an indefinite ``Phi`` is a finding about the model, not a numerical nuisance.
Raises ------ ValueError If the model fails the necessary identification conditions.
implied_covariance
Rebuild the model-implied indicator covariance matrix.
``Sigma = Lambda Phi Lambda' + Theta`` with ``Phi = (I - B)^-1 Psi (I - B)^-T``, where ``Psi`` holds the exogenous latent covariances and the endogenous disturbance variances.
Returns ``(Sigma, Phi)``. ``Phi`` should have a unit diagonal; departures from it indicate an improper solution and are reported by :func:`fit`.