RunMat
  • Pricing
RunMat
GitHub
GitHub
Sign inTry in browser
DesktopRuntimePhysicsCADAdministrationAgent

Get RunMat updates

New releases, guides and examples.

Product+
  • Runtime
  • GPU
  • Parallel
  • Compile
  • Interop and MEX
  • Simulation
  • MCAD
  • ECAD
  • Enterprise
  • AI integrations
  • Pricing
  • Download
Math+
  • Signal processing
  • Linear algebra
  • Statistics
  • Curve fitting
  • Differential equations
  • Control systems
  • Optimization
  • Finance
  • Data and tables
  • Plotting
Physics+
  • Simulation overview
  • Structural
  • Thermal
  • Electromagnetic
  • Joule heating
  • Thermal stress
  • Acoustics
  • Fluid flow
  • Conjugate heat transfer
  • Fluid–structure
  • What is FEA
Industries+
  • Aerospace
  • Automotive and transportation
  • Defense
  • Electronics and semiconductors
  • Energy
  • Industrial machinery
  • Life sciences
  • Quantitative finance
Learn+
  • Guides
  • Docs
  • Function reference
  • Language reference
  • Migration guide
  • Changelog
  • MATLAB Online
  • MATLAB AI agent
  • For students
Compare+
  • RunMat vs MATLAB
  • RunMat vs Ansys
  • RunMat vs SOLIDWORKS
  • RunMat vs Altium
  • RunMat vs Cadence
  • RunMat vs COMSOL
  • RunMat vs Python
  • RunMat vs Julia
  • RunMat vs Physics AI
  • RunMat vs Octave
  • Benchmarks
  • MATLAB alternatives
  • All comparisons
Company+
  • About
  • Blog
  • Contact
  • Source code↗
  • License
  • Privacy
  • Terms

Product

  • Runtime
  • GPU
  • Parallel
  • Compile
  • Interop and MEX
  • Simulation
  • MCAD
  • ECAD
  • Enterprise
  • AI integrations
  • Pricing
  • Download

Math

  • Signal processing
  • Linear algebra
  • Statistics
  • Curve fitting
  • Differential equations
  • Control systems
  • Optimization
  • Finance
  • Data and tables
  • Plotting

Physics

  • Simulation overview
  • Structural
  • Thermal
  • Electromagnetic
  • Joule heating
  • Thermal stress
  • Acoustics
  • Fluid flow
  • Conjugate heat transfer
  • Fluid–structure
  • What is FEA

Industries

  • Aerospace
  • Automotive and transportation
  • Defense
  • Electronics and semiconductors
  • Energy
  • Industrial machinery
  • Life sciences
  • Quantitative finance

Learn

  • Guides
  • Docs
  • Function reference
  • Language reference
  • Migration guide
  • Changelog
  • MATLAB Online
  • MATLAB AI agent
  • For students

Compare

  • RunMat vs MATLAB
  • RunMat vs Ansys
  • RunMat vs SOLIDWORKS
  • RunMat vs Altium
  • RunMat vs Cadence
  • RunMat vs COMSOL
  • RunMat vs Python
  • RunMat vs Julia
  • RunMat vs Physics AI
  • RunMat vs Octave
  • Benchmarks
  • MATLAB alternatives
  • All comparisons

Company

  • About
  • Blog
  • Contact
  • Source code↗
  • License
  • Privacy
  • Terms
GitHubXLinkedIn

© Dystr, Inc. · RunMat v0.7.1, Nov 17, 2026

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.

/
See all docs
Builtin Reference
    • bayesopt
    • classify
    • confusionmat
    • crossvalind
    • cvpartition
    • fitclinear
    • fitctree
    • fitlm
    • kmeans
    • knnsearch
    • lasso
    • lassoglm
    • linkage
    • lscov
    • mnrfit
    • nlparci
    • 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. Columns of B follow ascending Lambda values; a second output returns FitInfo.

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

X
Type
NumericArray
Required
Yes
Description
Predictor matrix with observations in rows and predictors in columns.
Y
Type
NumericArray
Required
Yes
Description
Response vector, or two-column binomial successes/trials matrix.
distr
Type
StringScalar
Required
Yes
Description
Distribution name: normal, binomial, or poisson.
options
Type
Any
Required
Variadic
Description
Name-value options such as Lambda, Alpha, Standardize, Intercept, Weights, Offset, CV, NumLambda, LambdaRatio, MaxIter, RelTol, and Options.
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

B
Type
NumericArray
Description
Coefficient matrix with one column per Lambda value.
FitInfo
Type
Any
Description
Fit information structure containing Lambda, Intercept, Deviance, DF, and diagnostics.
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

RunMat:lassoglm:InvalidArgument
When
Inputs, distribution name, dimensions, option names, or option values are malformed.
Message
lassoglm: invalid argument
RunMat:lassoglm:Convergence
When
The regularized GLM solver cannot make numerical progress.
Message
lassoglm: convergence failure
RunMat:lassoglm:Internal
When
RunMat cannot construct lassoglm outputs.
Message
lassoglm: internal error
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

Data and distributions

X is a nonempty finite real matrix with observations in rows. distr accepts normal (also spelled 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 matrix. BinomialSize supplies scalar or per-observation trial counts for binomial probability responses.

Alpha is in (0,1]; one gives lasso and smaller positive values mix in a ridge penalty. Lambda accepts nonnegative scalar or vector values, sorted and de-duplicated into ascending output columns. Without it, NumLambda and LambdaRatio define a geometric path from an all-zero-coefficient model. Standardize, Intercept (also Constant), nonnegative Weights with positive total weight, and finite observation Offset control the model.

Link accepts only the canonical link for the selected distribution: identity, logit, or log. EstDisp currently accepts off only. Unsupported values reject rather than silently selecting another model. RelTol, MaxIter, and statset-style Options control convergence; Options.MaxIter, Options.TolX, and Options.TolFun are honored. Enabled parallel options reject because fitting is CPU-local.

CV accepts resubstitution or a positive K-fold count. K-fold assignment currently uses deterministic round-robin partitions rather than MATLAB's random fold sequence. FitInfo then includes SE, LambdaMinDeviance, Lambda1SE, IndexMinDeviance, and Index1SE. FitInfo also contains Intercept, Lambda, Deviance, DF, and Iterations.

Classes and execution

Typed-integer X/Y, floating parameters, direct controls, and honored nested Options fields are independently gated RunMat extensions. Integer values must be exactly representable where they enter the binary64 solver; lossy values reject. Coefficients and numeric FitInfo values are double.

The regularized GLM solver runs on CPU. Admitted resident inputs are gathered through their owning provider; explicit gpuArray inputs require RunMat mode. Results are host values. No resident fitting kernel or fusion route is claimed. Callback-free fitting is portable to native and browser runtimes, subject to the same host memory and iteration limits.

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]); disp(B);

Control a Poisson fit with statset

X = [0;1;2;3;4;5]; counts = [1;1;2;3;4;5]; opts = statset('lassoglm','MaxIter',400); [B,FitInfo] = lassoglm(X,counts,'poisson','Options',opts); disp(FitInfo.Lambda);

Select a cross-validated penalty

X = [0;1;2;3;4;5]; y = [1;3;5;7;9;11]; [B,FitInfo] = lassoglm(X,y,'normal','CV',3); coef = B(:,FitInfo.IndexMinDeviance); disp(coef);

Fit grouped binomial observations

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

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?⌄

B contains predictor coefficients only; FitInfo.Intercept has one intercept per retained Lambda.

Which links are implemented?⌄

Identity for normal, logit for binomial, and log for poisson. Other Link values reject.

How are Lambda values ordered?⌄

FitInfo.Lambda is ascending and B uses the same column order.

Does K-fold assignment reproduce MATLAB's random partition?⌄

No. The current solver assigns folds deterministically in round-robin order.

Related Stats functions

Ml

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

Summary

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

Random

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

Hist

histc · histcounts · histcounts2

Options

statget · statset

Source you can read

Every RunMat function's source is public. 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 a runtime that executes MATLAB-syntax code fast on any GPU. The runtime is free for individuals, including freelancers; students and faculty at an academic institution, for teaching or research there; contributors to an open-source project, for work on that project; organizations with 250 or fewer people and US$10M or less in annual revenue; and anyone, for non-production use. See runmat.com/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
  • Data and distributions
  • Classes and execution
  • Examples
  • Fit a binomial logistic model
  • Control a Poisson fit with statset
  • Select a cross-validated penalty
  • Fit grouped binomial observations
  • Using lassoglm with coding agents
  • FAQ
  • Related Stats functions
  • Ml
  • Summary
  • Random
  • Hist
  • Options
  • Source you can read
  • About RunMat