Documentation

NAVAL-SEM v0.7

Open-source structural equation modelling desktop application. PLS-SEM and CB-SEM in a self-contained GUI — no R, no SPSS licence required.

v0.7.1 FastAPI · Python semopy · NumPy · pandas CC BY-NC-ND 4.0 Windows · macOS · Linux
▸ What's new in v0.7
  • Moderation analysis — product-of-composites with bootstrap simple slopes and Δ R² / Cohen's f²
  • IPMA — Importance-Performance Map Analysis with 0–100 rescaled performance scores
  • NCA — Necessary Condition Analysis (CE-FDH + CR-FDH, permutation p-values)
  • Moderated Mediation / Conditional Process Analysis (Hayes Models 7, 14, 58/59)
  • Results Summary panel — ModelSummary digest with structural paths, construct validity, and verdict string
  • OLS manifest-variable fallback for moderation models without latent constructs
  • Auto reverse-scoring: rVAR prefix triggers automatic reverse coding at runtime
  • Reproducibility fingerprint (SHA-256) now attached to all /run responses

Quick Start

1 · Launch the server

Shell
# From the extracted release folder
uvicorn app.main:app --reload --port 8000
# Or use the bundled launcher
python launcher.py

2 · POST your first model

All analysis endpoints accept multipart/form-data with a file upload (CSV / XLSX / SAV) and a model string in lavaan syntax.

cURL — minimal PLS-SEM run
curl -X POST http://localhost:8000/run \
  -F "file=@data.csv" \
  -F "model=Y =~ y1 + y2 + y3
X =~ x1 + x2 + x3
Y ~ X" \
  -F "algorithm=pls" \
  -F "bootstrap_n=500"

3 · Stream live logs (SSE)

JavaScript
const runId = crypto.randomUUID();
const es = new EventSource(`/logs/${runId}`);

es.onmessage = (e) => {
  const d = JSON.parse(e.data);
  if (d.done) { es.close(); return; }
  console.log(d.level, d.msg);
};

// Then POST /run with run_id in the form body
formData.append("run_id", runId);

Algorithms

All analysis endpoints that accept an algorithm parameter support three estimators:

pls
Partial Least Squares SEM
  • Default for all endpoints
  • Small-to-medium samples
  • Non-normal data
  • Exploratory research
  • Composite-based fit
cb
Covariance-Based SEM
  • Theory-confirming
  • Normal distribution assumed
  • Full CFI / TLI / RMSEA
  • n ≥ 200 recommended
  • ML estimator via semopy
wls
Weighted Least Squares
  • Ordinal / Likert data
  • Robust to non-normality
  • DWLS / WLSMV variant
  • Categorical indicators

lavaan Syntax

NAVAL-SEM parses a lavaan-compatible model string. Three operator types are supported:

OperatorMeaningExample
=~Measurement (reflective loading)EXO =~ x1 + x2 + x3
~Structural regression pathENO ~ EXO + MOD
~~Residual covariance / variancey2 ~~ y4

Interaction terms

Use the * operator inside a structural path to specify moderation. The engine auto-creates the mean-centred product column.

Moderation syntax
# Standard moderation: X*M on outcome Y
Y  ~  X + M + X*M
X  =~ x1 + x2 + x3
M  =~ m1 + m2 + m3
Y  =~ y1 + y2 + y3

Auto reverse scoring

Prefix any indicator name with r (e.g. rx3) when the column x3 exists in the dataset but rx3 does not. The server applies (max + min) − value automatically before fitting.

Reverse-scored indicator
SatisfactionLV =~ sat1 + sat2 + rsat3 + sat4
# rsat3 will be auto-reverse-scored from sat3
Multi-target residual covariance shorthand (y2 ~~ y4 + y6) is automatically expanded to individual pairs by the engine. However, write them individually for clarity in production models.
Core API

POST /run

Fit a full SEM model. Returns path coefficients, loadings, fit indices, validity metrics, and optionally bootstrap CIs. Generates a SHA-256 reproducibility fingerprint.

POST /run Fit model → ModelResult

Form Parameters

FieldTypeDefaultDescription
filerequiredFileCSV, XLSX, or SAV dataset
modelrequiredstringlavaan syntax string
algorithmoptionalstringplspls | cb | wls
bootstrap_noptionalint0Bootstrap resamples (0 = no bootstrap, max 20 000)
missingoptionalstringlistwiselistwise | mean
run_idoptionalstringauto UUIDClient-supplied ID for SSE log streaming

Returns → ModelResult

Key fields in the response JSON:

FieldTypeNotes
algorithmstringEstimator used
n_obsintRows used after missing-data handling
convergedboolOptimisation converged
parametersPathParameter[]All =~, ~, ~~ rows with estimates, SE, z, p, CI
fitFitIndicesCFI, TLI, RMSEA, SRMR, χ², AIC, BIC, AVE, CR, α
vifVIFEntry[] | nullCollinearity — VIF < 5 acceptable, < 3.3 strict
f2F2Entry[] | nullCohen's f² for each predictor
indirectIndirectResult | nullPopulated when bootstrap_n > 0
outer_weightsOuterWeightEntry[] | nullBootstrap outer weights
fingerprintstring | nullSHA-256 reproducibility hash
summaryModelSummary | nullHigh-level digest for UI panels (v0.7)
warningsstring[]Non-fatal notices

POST /bootstrap

Run standalone bootstrap without re-fitting the full model. Useful for extending an existing /run result with CIs post-hoc.

POST /bootstrap Bootstrap → BootstrapResult

Form Parameters

FieldTypeDefaultDescription
filerequiredFileCSV, XLSX, or SAV
modelrequiredstringlavaan syntax
bootstrap_noptionalint500Resamples (max 20 000)
algorithmoptionalstringplsEstimator
missingoptionalstringlistwiseMissing-data strategy

POST /indirect

Decompose indirect (mediation) effects for all variable pairs connected via paths of length ≥ 2. Returns bootstrap 95 % CIs and a total-effects matrix.

POST /indirect Indirect effects → IndirectResult

Form Parameters

FieldTypeDefaultDescription
filerequiredFileDataset
modelrequiredstringlavaan syntax
bootstrap_noptionalint500Bootstrap resamples for CIs
missingoptionalstringlistwise

Returns → IndirectResult

FieldTypeNotes
effectsIndirectEffect[]One row per from→through→to chain with bootstrapped SE, CI, significance
total_effectsDict[str, Dict[str, float]]Matrix: total_effects[from_var][to_var]

POST /predict

Predictive relevance suite: Stone-Geisser Q² (blindfolding), PLSpredict k-fold vs linear baseline, and CVPAT.

POST /predict Q² · PLSpredict · CVPAT → PredictResult

Form Parameters

FieldTypeDefaultDescription
filerequiredFileDataset
modelrequiredstringlavaan syntax
omission_distanceoptionalint7Blindfolding omission distance D
k_foldsoptionalint10Cross-validation folds for PLSpredict
missingoptionalstringlistwise

POST /cmb

Common Method Bias marker variable analysis (Lindell & Whitney 2001). Requires a marker variable theoretically unrelated to your constructs.

POST /cmb Common Method Bias → CMBMarkerResult

Form Parameters

FieldTypeDefaultDescription
filerequiredFileDataset
modelrequiredstringlavaan syntax
marker_variablerequiredstringColumn name of the marker variable
missingoptionalstringlistwise

POST /mga

Multi-Group Analysis: per-group model fit, pairwise bootstrap path-difference CIs, and (for 2-group analyses) MICOM measurement invariance.

POST /mga Multi-Group Analysis → MGAResult

Form Parameters

FieldTypeDefaultDescription
filerequiredFileDataset (must contain grouping column)
modelrequiredstringlavaan syntax
grouping_variablerequiredstringColumn name for group splits
algorithmoptionalstringpls
bootstrap_noptionalint500Resamples for path-difference CIs
missingoptionalstringlistwise
run_idoptionalstringauto UUIDSSE tracking ID
v0.7 — New

POST /moderation

Moderation analysis via the product-of-composites approach. Detects X*M interaction terms in the lavaan structural syntax and tests each one by comparing R² with vs. without the interaction term (Δ R², Cohen's f²) and computing bootstrap simple slopes at moderator = −1 SD, mean (0), +1 SD.

Manifest-variable fallback: when the model contains no =~ measurement lines, NAVAL-SEM automatically switches to an OLS path for observed-variable moderation (no latent composites needed).
POST /moderation Moderation → ModerationResult

Form Parameters

FieldTypeDefaultDescription
filerequiredFileDataset (CSV, XLSX, SAV)
modelrequiredstringlavaan syntax; must include at least one X*M term
algorithmoptionalstringplspls | cb | wls
bootstrap_noptionalint500Bootstrap resamples for β_interaction CIs and simple slopes
missingoptionalstringlistwise
run_idoptionalstringauto UUIDSSE tracking ID

Returns → ModerationResult

FieldTypeNotes
moderation_termsModerationTerm[]One entry per detected X×M interaction
parametersPathParameter[]Full model parameters including interaction term
fitFitIndicesFit of the full (interaction-included) model
n_obsintEffective sample size
bootstrap_nintActual resamples used
warningsstring[]

ModerationTerm fields

FieldTypeNotes
iv / moderator / outcomestringVariable names
interaction_colstringAuto-created product column name (e.g. X_x_M)
beta_iv / beta_moderator / beta_interactionfloatStandardised path coefficients
ci_lower_95 / ci_upper_95float | nullBootstrap percentile CI for β_interaction
significantboolTrue when CI excludes 0
r2_with / r2_without / delta_r2floatR² comparison
f2_interactionfloatCohen's f² = Δ R² / (1 − R²_with)
simple_slopesSimpleSlope[]At W = −1 SD, 0, +1 SD
Example syntax
# Test whether trust (TR) moderates innovation (IN) → satisfaction (SA)
SA ~  IN + TR + IN*TR
IN =~ in1 + in2 + in3
TR =~ tr1 + tr2 + tr3
SA =~ sa1 + sa2 + sa3

POST /ipma

Importance-Performance Map Analysis (Ringle & Sarstedt 2016; Hair et al. 2022 Ch. 7). Computes for each predictor of a target latent variable: Importance = total effect (direct + all indirect paths) and Performance = mean composite score rescaled to 0–100.

POST /ipma IPMA → IPMAResult

Form Parameters

FieldTypeDefaultDescription
filerequiredFileDataset
modelrequiredstringlavaan syntax
target_lvrequiredstringName of the outcome LV for which importance is computed
algorithmoptionalstringpls
scale_minoptionalfloatobserved minTheoretical scale minimum (e.g. 1 for Likert 1–5)
scale_maxoptionalfloatobserved maxTheoretical scale maximum (e.g. 5 for Likert 1–5)
missingoptionalstringlistwise
run_idoptionalstringauto UUID

Returns → IPMAResult

FieldTypeNotes
target_lvstringThe outcome LV specified
entriesIPMAEntry[]Sorted by importance descending
scale_min / scale_maxfloatScale range actually used for 0–100 rescaling
algorithmstring
warningsstring[]Emitted when scale range is inferred from data

IPMAEntry fields

FieldTypeNotes
lvstringPredictor construct name
importancefloatTotal effect on target_lv
performancefloat0–100 rescaled composite mean (clamped)
Pass scale_min and scale_max matching your survey instrument (e.g. 1 and 5 for a five-point Likert scale) for correct 0–100 performance rescaling. When omitted, NAVAL-SEM uses the observed data range and appends a warning.

POST /nca

Necessary Condition Analysis (Dul 2016, 2020). Tests whether each predictor is a necessary (not merely sufficient) condition for an outcome. Computes CE-FDH (staircase ceiling) and CR-FDH (regression ceiling) effect sizes plus permutation-based significance.

POST /nca NCA → NCAResult

Form Parameters

FieldTypeDefaultDescription
filerequiredFileDataset
modelrequiredstringlavaan syntax; all structural IV→DV pairs are tested
n_permutationsoptionalint1000Permutation samples for p-value (max 20 000)
missingoptionalstringlistwise
run_idoptionalstringauto UUID

Returns → NCAResult

FieldTypeNotes
entriesNCAEntry[]One per unique IV→DV pair
n_permutationsint
warningsstring[]Pairs skipped due to insufficient n

NCAEntry fields

FieldTypeNotes
iv / dv / n_obsstring / int
ce_fdh_d / ce_fdh_label / ce_fdh_pfloat / string / floatStaircase ceiling effect size and permutation p
cr_fdh_d / cr_fdh_labelfloat / stringRegression ceiling effect size
cr_fdh_slope / cr_fdh_intercept / cr_fdh_pfloatRegression ceiling line parameters
significantboolTrue when max(ce_p, cr_p) < 0.05
scatter_x / scatter_yfloat[]Sampled scatter plot coordinates (≤ 200 pts)
ceiling_x / ceiling_yfloat[]CE-FDH staircase coordinates (≤ 100 pts)

NCA Effect Size Benchmarks (Dul 2016)

dLabel
< 0.10negligible
0.10 – 0.29small
0.30 – 0.49medium
≥ 0.50large

POST /mod-mediation

Moderated Mediation / Conditional Process Analysis (Edwards & Lambert 2007; Hayes 2018 Chapters 11–14). Detects interaction terms in the structural syntax and computes the Index of Moderated Mediation (IMM) with bootstrap 95 % CI plus conditional indirect effects at W = −1 SD, 0, +1 SD.

POST /mod-mediation Moderated Mediation → ModMediationResult

Supported Hayes PROCESS patterns

PatternModelSyntax
a-path moderationModel 7M ~ X + W + X*W / Y ~ X + M
b-path moderationModel 14M ~ X / Y ~ X + M + W + M*W
Both pathsModel 58/59Combine both interaction terms above

Form Parameters

FieldTypeDefaultDescription
filerequiredFileDataset
modelrequiredstringlavaan syntax with at least one X*W term
algorithmoptionalstringpls
bootstrap_noptionalint500Bootstrap resamples for IMM CI and conditional IEs (max 20 000)
missingoptionalstringlistwise
run_idoptionalstringauto UUID

Returns → ModMediationResult

FieldTypeNotes
pathsModMediationPath[]One per detected X→M→Y chain
parametersPathParameter[]Full model parameter table
fitFitIndices
n_obs / bootstrap_nint
warningsstring[]

ModMediationPath fields

FieldTypeNotes
x / m / y / wstringVariable names
moderated_pathstring"a" or "b"
a_path / b_path / c_primefloatX→M, M→Y, direct X→Y
a3_interaction / b3_interactionfloat | nullInteraction β on a- or b-path
immfloatIndex of Moderated Mediation (a₃·b or a·b₃)
imm_ci_lower_95 / imm_ci_upper_95float | nullBootstrap percentile CI
imm_significantboolTrue when IMM CI excludes 0
conditional_effectsConditionalIndirectEffect[]IE at W = −1 SD, 0, +1 SD
a-path moderation example (Model 7)
# H1: W moderates the X → M relationship
M ~  X + W + X*W
Y ~  X + M
X =~ x1 + x2 + x3
M =~ m1 + m2 + m3
W =~ w1 + w2 + w3
Y =~ y1 + y2 + y3
Utilities

GET /logs/{run_id}

Server-Sent Events stream for a running analysis. Open immediately after submitting any endpoint that returns a run_id. The stream emits JSON objects and terminates with a done packet.

GET /logs/{run_id} SSE log stream

Stream events

Event typeFieldsNotes
log entryt, level, msglevel = step | info | ok | warn | error
donedone: true, fingerprint, auditStream closes after this

Stream auto-closes after 4 hours; results continue in background.

GET /fingerprint/{run_id}

Retrieve the full SHA-256 audit record for a completed run. The fingerprint covers model syntax hash, data hash (SHA-256 of sorted column hashes), algorithm, environment versions, and key fit metrics.

GET /fingerprint/{run_id} Reproducibility audit record

Returns 404 if run_id is unknown; 425 if the run is still in progress.

POST /upload/preview

Parse an uploaded file and return column names, row count, first 5 rows, and dtype map — without running any analysis. Useful for validating uploads before model submission.

POST /upload/preview Dataset preview
ReturnsTypeNotes
columnsstring[]All column names
n_rowsintTotal row count
previewobject[]First 5 rows as records
dtypesDict[str, str]pandas dtype per column

GET /health

GET /health Liveness check
{ "status": "ok", "version": "0.7.1" }
Reference

Schemas

All response models are Pydantic v2 classes. Key schemas:

PathParameter

One row per model parameter (measurement loading, structural path, or covariance). std_error, z_value, and p_value are null for ~~ rows.

PathParameter
lhs str
op str =~ | ~ | ~~
rhs str
estimate float
std_estimate float?
std_error float?
z_value float?
p_value float?
ci_lower / ci_upper float?
significant bool
FitIndices
cfi / tli float?
rmsea float?
rmsea_ci_lower/upper float?
srmr float?
chi_square / df / p_value float?
aic / bic float?
r_squared Dict?
ave / composite_reliability Dict?
cronbach_alpha Dict?
fornell_larcker Dict?
cfi_good / rmsea_good / srmr_good bool?
IndirectEffect
from_var / to_var str
through str[] mediator chain
indirect_effect float
bs_se float?
ci_lower_95 / ci_upper_95 float?
significant bool?
F2Entry
lhs / rhs str
r2_full / r2_reduced float
f2 float ΔR²/(1−R²_full)
effect str negligible–large
Q2Entry (v0.5)
lv str endogenous LV
q2 float 1 − SSE/SSO
sse / sso float
omission_distance int
predictive_relevance str
HTMTEntry
construct_a / b str
htmt float
acceptable bool HTMT < 0.90

Fit Thresholds

Verdict flags set automatically by the engine:

IndexAcceptableGoodField
CFI≥ 0.90≥ 0.95cfi_acceptable / cfi_good
TLI (NNFI)≥ 0.90≥ 0.95tli_acceptable / tli_good
RMSEA≤ 0.08≤ 0.06rmsea_acceptable / rmsea_good
SRMR≤ 0.08srmr_good
AVE≥ 0.50per-LV in fit.ave
Composite Reliability≥ 0.70≥ 0.80fit.composite_reliability
Cronbach's α≥ 0.70fit.cronbach_alpha
VIF< 5.0< 3.3 (PLS strict)vif[].acceptable
HTMT< 0.90< 0.85htmt[].acceptable

Effect Sizes

Cohen's f² (structural paths)

Label
< 0.02negligible
0.02 – 0.14small
0.15 – 0.34medium
≥ 0.35large

Stone-Geisser Q² (predictive relevance)

Label
≤ 0none
0 – 0.25small
0.25 – 0.50medium
≥ 0.50large

NCA Effect Size d (Dul 2016)

dLabel
< 0.10negligible
0.10 – 0.29small
0.30 – 0.49medium
≥ 0.50large

Changelog

v0.7
  • Moderation: product-of-composites, OLS fallback for manifest models, bootstrap simple slopes at −1 SD / 0 / +1 SD, Δ R², Cohen's f²
  • IPMA: total-effect importance, 0–100 rescaled performance, configurable theoretical scale range
  • NCA: CE-FDH staircase ceiling, CR-FDH regression ceiling, permutation p-values, scatter / ceiling coordinates for frontend rendering
  • Moderated Mediation (Hayes Models 7, 14, 58/59): IMM with bootstrap CI, conditional indirect effects at 3 moderator levels
  • ModelSummary digest in /run response: structural path table, construct validity table, verdicts
  • Auto reverse-scoring via r-prefix convention (auto_reverse_score)
  • Residual covariance expansion fix (TC-52): multi-target ~~ shorthand correctly split into individual pairs
  • Reproducibility fingerprint (SHA-256) in all /run responses and accessible via GET /fingerprint/{run_id}
v0.6
  • Higher-Order Constructs: repeated-indicator and two-stage approaches
  • GitHub Actions CI/CD: version injected from git tags
  • Full-width results drawer with live SSE logging
  • MGA and MICOM tabs wired in UI
  • SourceForge distribution connector via native GitHub integration
v0.5
  • Predictive relevance suite: Q², PLSpredict, CVPAT (POST /predict)
  • Common Method Bias marker variable analysis (POST /cmb)
  • Outer weights bootstrap with t-statistics
v0.4
  • Multi-Group Analysis with MICOM (POST /mga)
  • Indirect effects decomposition (POST /indirect)
  • VIF collinearity table, Cohen's f² for all structural paths
v0.3
  • HTMT discriminant validity (POST /htmt)
  • AVE, composite reliability, Cronbach's α in FitIndices
  • Fornell-Larcker criterion matrix
≤ v0.2
  • Initial public release: PLS-SEM / CB-SEM / WLS via semopy backend
  • Bootstrap standalone (POST /bootstrap)
  • CSV / XLSX / SAV parser, SSE log stream, /health endpoint
  • PyInstaller distributable for Windows, macOS, Linux