npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@tangent.to/sem

v0.1.2

Published

Structural equation modeling for JavaScript (ESM): CFA, path analysis and full SEM with lavaan-style model syntax. semopy/lavaan-validated.

Downloads

92

Readme

tangent/sem

Structural equation modeling for JavaScript (ESM). Browser-first, runs in Node.js and Deno. The first maintained SEM implementation in the JavaScript ecosystem — part of the tangent suite, built entirely on its validated numeric leaves: lina (linear algebra), opt (L-BFGS), proba (test distributions).

  • Confirmatory factor analysis, path analysis, and full SEM (latent regressions, correlated residuals)
  • lavaan-style model syntax: =~, ~, ~~, 1*x to fix, NA*x to free
  • Maximum-likelihood estimation (RAM parameterization), expected- information standard errors, χ²/CFI/TLI/RMSEA/SRMR/AIC/BIC
  • lavaan identification defaults: first-indicator markers, automatic residual variances and exogenous-factor covariances

Install

npm install @tangent.to/sem     # npm
deno add jsr:@tangent/sem       # Deno / JSR

Usage

import { sem } from '@tangent.to/sem';

const fit = sem(`
  visual  =~ x1 + x2 + x3
  textual =~ x4 + x5 + x6
  speed   =~ x7 + x8 + x9
`, { data });          // rows as objects; or { cov, n, names }

fit.fit.chisq;         // 85.306 on Holzinger-Swineford, matching lavaan
fit.fit.cfi;           // 0.931
fit.estimates;         // [{lhs, op, rhs, est, se, z, pvalue}, ...]
console.log(fit.summary());

Full SEM with latent regressions:

const pd = sem(`
  ind60 =~ x1 + x2 + x3
  dem60 =~ y1 + y2 + y3 + y4
  dem65 =~ y5 + y6 + y7 + y8
  dem60 ~ ind60
  dem65 ~ ind60 + dem60
  y1 ~~ y5
`, { data });

Validation

tests_compare-to-semopy/ fits the two canonical benchmarks with both tangent/sem and semopy (which reproduces R's lavaan) on identical data:

  • Holzinger-Swineford CFA: χ² = 85.306 (lavaan's published value, exactly), estimates and expected-information standard errors matching semopy to ~1e-3 relative; CFI/TLI/RMSEA/SRMR/AIC/BIC match lavaan's published output.
  • Bollen political democracy full SEM: χ² = 38.125 (lavaan's published value); our optimum is marginally tighter than semopy's and matches lavaan's published parameter table more closely.
npm run test:semopy    # requires uv and Node

Scope

Covariance-structure ML for complete numeric data: CFA, path analysis, full SEM. Not yet: mean structures/intercepts, multiple groups, missing data (FIML), ordinal indicators (WLSMV), robust corrections. Those are roadmap items, prioritized by demand.

License

GPL-3.0 (application layer of the tangent suite; the numeric leaves it builds on are MIT).