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

mnrfit — Fit nominal multinomial logistic regression coefficients.

mnrfit(X,Y) fits nominal multinomial logistic regression coefficients. Rows of X are observations, columns are predictors, and columns of B correspond to all response classes except the final sorted reference class.

Syntax

B = mnrfit(X, Y)
B = mnrfit(X, Y, Name, Value)
[B, dev] = mnrfit(X, Y)
[B, dev] = mnrfit(X, Y, Name, Value)
[B, dev, stats] = mnrfit(X, Y)
[B, dev, stats] = mnrfit(X, Y, Name, Value)

Inputs

X
Type
NumericArray
Required
Yes
Description
Predictor matrix with observations in rows.
Y
Type
Any
Required
Yes
Description
Response class vector or grouped counts matrix with one column per class.
NameValue
Type
Any
Required
Variadic
Description
Name-value options such as Model, Link, Constant, Weights, IterationLimit, Tolerance, and Options.
NameTypeRequiredDefaultDescription
XNumericArrayYes—Predictor matrix with observations in rows.
YAnyYes—Response class vector or grouped counts matrix with one column per class.
NameValueAnyVariadic—Name-value options such as Model, Link, Constant, Weights, IterationLimit, Tolerance, and Options.

Returns

B
Type
NumericArray
Description
Coefficient matrix with one column per non-reference response category.
dev
Type
NumericScalar
Description
Model deviance.
stats
Type
Any
Description
Fit statistics structure; its fields and shapes are described in the reference documentation.
NameTypeDescription
BNumericArrayCoefficient matrix with one column per non-reference response category.
devNumericScalarModel deviance.
statsAnyFit statistics structure; its fields and shapes are described in the reference documentation.

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

Errors

RunMat:mnrfit:InvalidArgument
When
Inputs, response values, dimensions, or options are malformed.
Message
mnrfit: invalid argument
RunMat:mnrfit:Convergence
When
The multinomial logistic solver cannot make numerical progress.
Message
mnrfit: convergence failure
RunMat:mnrfit:Internal
When
RunMat cannot allocate or construct mnrfit outputs.
Message
mnrfit: internal error
IdentifierWhenMessage
RunMat:mnrfit:InvalidArgumentInputs, response values, dimensions, or options are malformed.mnrfit: invalid argument
RunMat:mnrfit:ConvergenceThe multinomial logistic solver cannot make numerical progress.mnrfit: convergence failure
RunMat:mnrfit:InternalRunMat cannot allocate or construct mnrfit outputs.mnrfit: internal error

Inputs and response classes

X is a real numeric predictor matrix. Current MATLAB documents single or double X; typed-integer X, typed-integer Y, and logical X are independently gated RunMat extensions. Logical Y remains admitted. Integer predictors, grouped counts, weights, and tolerance values must be exactly representable at the binary64 host-solver boundary.

Y may be a numeric, logical, string, character, cell-string, or categorical class vector with one response per row of X. Numeric classes retain distinct finite values exactly; classes are sorted and the last class is the reference. Alternatively, an N-by-K numeric Y supplies grouped response counts; columns are categories and row totals contribute observation weights. Rows with nonfinite X values or NaN response values are omitted. Infinite numeric class values are rejected; grouped count rows marked missing by NaN are omitted, while inspected non-NaN counts and their totals must be finite and nonnegative.

Solver controls and outputs

The default model includes a constant term. Model supports nominal, Link supports logit, and Interactions accepts off. Weights is a nonnegative finite observation-weight vector with positive finite total after response weights are applied; unrepresentable products or totals return an error. IterationLimit and Tolerance control convergence. EstDisp accepts only off; overdispersion estimation is not implemented.

Constant, MaxIter, TolX, Options, and Display remain gated RunMat option extensions rather than MATLAB-compatible spellings. Display is accepted but does not change the solver result.

B has one row per model term and one column per non-reference class. [B,dev,stats] also returns deviance and a stats struct with beta, se, t, p, covb, coeffcorr, dfe, s, estdisp, and classNames. The solver runs on CPU; automatically resident inputs are gathered, while explicit gpuArray input is a mode-gated RunMat host-fallback extension. No resident solver kernel or fusion route is claimed.

Long fits support execution cancellation. In the browser, preparation and solver work periodically yield to the event loop so cancellation requests can be processed.

Examples

Fit a binary nominal logistic model

X = [0; 1; 2; 3; 4]; y = [1; 2; 1; 2; 2]; [B,dev,stats] = mnrfit(X,y); disp(B); disp(dev);

Fit a three-class nominal model

X = [0; 1; 0; 1; 2; 3]; y = [1; 1; 2; 2; 3; 3]; B = mnrfit(X,y,'Model','nominal'); disp(B);

Fit grouped response counts

X = [0; 1; 2; 3]; Y = [8 1 1; 5 3 2; 2 5 3; 1 6 4]; B = mnrfit(X,Y,'IterationLimit',200); disp(B);

Check a grouped fit with known odds

X = [0; 1; 2; 3]; Y = repmat([2 6],4,1); [B,dev] = mnrfit(X,Y,'Tolerance',1e-9); disp(B); disp(dev);

Fit text response labels

X = [0; 1; 2; 3; 4]; y = ["low"; "high"; "low"; "high"; "high"]; [B,dev,stats] = mnrfit(X,y,'Tolerance',1e-7); disp(stats.classNames);

Using mnrfit with coding agents

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

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

FAQ

Which response class is the reference class?⌄

RunMat sorts numeric, logical, and text response classes and uses the final sorted class as the reference for nominal coding. Grouped-count columns retain their supplied order, with the final column as the reference.

Does RunMat implement ordinal models?⌄

No. The current implementation fits nominal multinomial logistic regression; other Model values return an error.

Does RunMat estimate overdispersion?⌄

No. EstDisp accepts only off, and stats.s is 1.

Related Stats functions

Ml

bayesopt · classify · confusionmat · crossvalind · cvpartition · fitclinear · fitctree · fitlm · kmeans · knnsearch · lasso · lassoglm · linkage · lscov · 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 mnrfit is executed, line by line, in Rust.

  • View the source for mnrfit 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
  • Inputs and response classes
  • Solver controls and outputs
  • Examples
  • Fit a binary nominal logistic model
  • Fit a three-class nominal model
  • Fit grouped response counts
  • Check a grouped fit with known odds
  • Fit text response labels
  • Using mnrfit with coding agents
  • FAQ
  • Related Stats functions
  • Ml
  • Summary
  • Random
  • Hist
  • Options
  • Source you can read
  • About RunMat