RunMat
  • Pricing
RunMat
GitHub
GitHub
DownloadSign InTry in Browser
DesktopRuntimeServer
RunMat

Run math blazing fast

GitHubX (Twitter)LinkedIn

Company

  • About
  • Pricing
  • Contact

Explore

  • RunMat for academia
  • RunMat vs MATLAB Online
  • Benchmarks

Get product updates and release notes from the RunMat team.

© 2026 Dystr · Made withfor the scientific community.

RunMat™ is a registered trademark of Dystr, Inc. MATLAB® is a registered trademark of The MathWorks, Inc. RunMat is not affiliated with, endorsed by, or sponsored by The MathWorks, Inc.

LicensePrivacy
/
See all docs
Builtin Reference
    • bayesopt
    • classify
    • confusionmat
    • crossvalind
    • cvpartition
    • fitclinear
    • fitctree
    • fitlm
    • kmeans
    • knnsearch
    • lasso
    • lassoglm
    • linkage
    • lscov
    • mnrfit
    • optimizableVariable
    • pdist
    • pdist2
    • perfcurve
    • predict
    • regress
    • ridge
    • squareform
    • test
    • training
    • tsne

lassoglm — Fit lasso or elastic-net regularized generalized linear models.

lassoglm(X,Y,distr) fits a regularized generalized linear model for predictor matrix X, response Y, and distribution distr. Columns of B correspond to ascending Lambda values, and [B,FitInfo] = lassoglm(...) returns MATLAB-compatible fit metadata.

Syntax

B = lassoglm(X, Y, distr)
B = lassoglm(X, Y, distr, Name, Value)
[B, FitInfo] = lassoglm(X, Y, distr)
[B, FitInfo] = lassoglm(X, Y, distr, Name, Value)

Inputs

NameTypeRequiredDefaultDescription
XNumericArrayYes—Predictor matrix with observations in rows and predictors in columns.
YNumericArrayYes—Response vector, or two-column binomial successes/trials matrix.
distrStringScalarYes—Distribution name: normal, binomial, or poisson.
optionsAnyVariadic—Name-value options such as Lambda, Alpha, Standardize, Intercept, Weights, Offset, CV, NumLambda, LambdaRatio, MaxIter, RelTol, and Options.

Returns

NameTypeDescription
BNumericArrayCoefficient matrix with one column per Lambda value.
FitInfoAnyFit information structure containing Lambda, Intercept, Deviance, DF, and diagnostics.

Returned values from lassoglm depend on how many outputs the caller requests.

Errors

IdentifierWhenMessage
RunMat:lassoglm:InvalidArgumentInputs, distribution name, dimensions, option names, or option values are malformed.lassoglm: invalid argument
RunMat:lassoglm:ConvergenceThe regularized GLM solver cannot make numerical progress.lassoglm: convergence failure
RunMat:lassoglm:InternalRunMat cannot construct lassoglm outputs.lassoglm: internal error

How lassoglm works

  • X must be a finite real numeric matrix with observations in rows and predictors in columns.
  • distr supports "normal"/"gaussian", "binomial", and "poisson". Normal and poisson responses are numeric vectors. Binomial responses may be a probability/logical vector or an N-by-2 successes/trials count matrix.
  • Lambda accepts a nonnegative scalar or vector. RunMat sorts Lambda values in ascending order for output, matching MATLAB's FitInfo.Lambda convention.
  • When Lambda is omitted, RunMat computes a geometric regularization path using NumLambda and LambdaRatio from an all-zero coefficient model.
  • Alpha supports lasso and elastic-net fits for values in (0,1]. Alpha=1 is lasso; smaller positive values mix in the ridge penalty.
  • Standardize and Intercept follow MATLAB's model form. Weights accepts a nonnegative observation-weight vector with positive total weight, and Offset accepts one finite offset per observation.
  • RelTol, MaxIter, and statset-style Options control solver convergence. Options.MaxIter, Options.TolX, and Options.TolFun are honored; enabled parallel options are rejected because RunMat's solver is CPU-local.
  • CV supports "resubstitution" and positive integer K-fold cross-validation. K-fold fits add SE, LambdaMinDeviance, Lambda1SE, IndexMinDeviance, and Index1SE fields to FitInfo.
  • BinomialSize supports scalar or per-observation trial counts for binomial probability responses. Link is accepted only for canonical supported links (identity, logit, or log according to distribution), EstDisp currently accepts "off", and unsupported values are rejected instead of silently changing the model.
  • Typed-integer X, Y, numeric parameters, direct controls, and honored nested Options fields are independently classified RunMat-only extensions. Integer values remain exact until a checked double solver boundary; values not exactly representable as double reject rather than round.

Examples

Fit a binomial logistic model

X = [0; 1; 2; 3; 4; 5];
y = [0; 0; 0; 1; 1; 1];
[B,FitInfo] = lassoglm(X, y, "binomial", "Lambda", [0 0.1])

Expected output:

B has one row and two columns. FitInfo contains Intercept, Lambda, Deviance, DF, and Iterations.

Fit a poisson model with statset options

opts = statset("lassoglm", "MaxIter", 400);
[B,FitInfo] = lassoglm(X, counts, "poisson", "Options", opts)

Expected output:

The solver uses the supplied maximum iteration count and canonical log link.

Use K-fold cross-validation

[B,FitInfo] = lassoglm(X, y, "normal", "CV", 5);
coef = B(:,FitInfo.IndexMinDeviance)

Expected output:

FitInfo includes cross-validation deviance, SE, and Lambda selection fields.

Use grouped binomial counts

Y = [8 10; 3 10; 1 8];
B = lassoglm(X, Y, "binomial", "Weights", [1; 2; 1])

Expected output:

The first column is successes and the second column is trials.

Using lassoglm with coding agents

Open a RunMat example with live inputs, then ask the agent to explain how lassoglm changes the result.

Run a small lassoglm example, explain the result, then change one input and compare the output.

FAQ

Where is the intercept stored?⌄

The coefficient matrix B contains only predictor coefficients. Intercepts are returned in FitInfo.Intercept, one value per Lambda.

Which links are implemented?⌄

RunMat uses canonical links for supported distributions: identity for normal, logit for binomial, and log for poisson. Other Link values are rejected because returning a canonical-link fit for a noncanonical request would be misleading.

How are Lambda values ordered?⌄

RunMat returns Lambda values in ascending order in FitInfo.Lambda, and the columns of B use the same order.

Does cross-validation match MATLAB's random partitions exactly?⌄

No. RunMat currently uses deterministic round-robin K-fold partitions. The returned fields and selection semantics are MATLAB-compatible, but fold assignment is deterministic.

Related Stats functions

Ml

bayesopt · classify · confusionmat · crossvalind · cvpartition · fitclinear · fitctree · fitlm · kmeans · knnsearch · lasso · linkage · lscov · mnrfit · optimizableVariable · pdist · pdist2 · perfcurve · predict · regress · ridge · squareform · test · training · tsne

Summary

binocdf · boxplot · cdf · cdfplot · chi2cdf · corr · corrcoef · corrcov · cov · cov2corr · dummyvar · ecdf · filloutliers · fitdist · geomean · grpstats · harmmean · icdf · isoutlier · kstest · kurtosis · lsline · mad · mode · nanmax · normalize · normcdf · norminv · normpdf · onehotdecode · onehotencode · pdf · prctile · quantile · refline · rmse · skewness · tabulate · tcdf · tiedrank · tinv · tpdf · ttest2 · wblinv

Random

binornd · bootstrp · datasample · dividerand · exprnd · gamrnd · lhsdesign · mvnrnd · normrnd · random · randsample · rng · trnd · unidrnd · unifrnd · wblrnd

Hist

histc · histcounts · histcounts2

Options

statget · statset

Open-source implementation

Unlike proprietary runtimes, every RunMat function is open-source. Read exactly how lassoglm is executed, line by line, in Rust.

  • View the source for lassoglm in Rust on GitHub
  • Learn how the RunMat runtime works
  • Found a bug? Open an issue with a minimal reproduction.

About RunMat

RunMat is an open-source runtime that executes MATLAB-syntax code blazing on any GPU. It is licensed under the Apache 2.0 license.

  • RunMat automatically optimizes your math for GPU execution on Apple, Nvidia, and AMD hardware. No code changes needed. Simulations that took hours now take minutes.
  • Start running code in seconds. RunMat runs in the browser, on the desktop, or from the CLI. No license server, no IT ticket.

Getting started · Benchmarks · Pricing

Download RunMat

Download RunMat for full performance, or use RunMat in your browser for zero setup.

Download RunMatOpen Sandbox
On this page
  • Syntax
  • Inputs
  • Returns
  • Errors
  • How lassoglm works
  • Examples
  • Fit a binomial logistic model
  • Fit a poisson model with statset options
  • Use K-fold cross-validation
  • Use grouped binomial counts
  • Using lassoglm with coding agents
  • FAQ
  • Related Stats functions
  • Ml
  • Summary
  • Random
  • Hist
  • Options
  • Open-source implementation
  • About RunMat