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

fitlm — Fit an ordinary least-squares linear regression model.

fitlm fits an ordinary least-squares linear regression model from a numeric predictor matrix or table and returns a host LinearModel object. The compatibility target documents single and double matrix data; RunMat mode separately gates typed-integer predictors, responses, weights, structural selectors, and Intercept controls.

Syntax

mdl = fitlm(tbl)
mdl = fitlm(tbl, modelspec)
mdl = fitlm(X, y)
mdl = fitlm(___, Name, Value)

Inputs

NameTypeRequiredDefaultDescription
tblOrXAnyYes—Input table or predictor matrix.
yOrSpecAnyNo—Response vector, response variable name, model formula, or model specification.
optionsAnyVariadic—Model specification and name-value options such as Intercept, ResponseVar, PredictorVars, VarNames, Exclude, and Weights.

Returns

NameTypeDescription
mdlAnyLinearModel object containing coefficients, fitted values, residuals, and summary statistics.

Errors

IdentifierWhenMessage
RunMat:fitlm:InvalidArgumentInputs, model specifications, dimensions, or name-value options are malformed or unsupported.fitlm: invalid argument
RunMat:fitlm:NumericalThe linear model cannot be fit numerically.fitlm: numerical failure
RunMat:fitlm:InternalRunMat cannot construct a LinearModel result.fitlm: internal error

How fitlm works

  • fitlm(X,y) fits a model with an intercept and one linear term per predictor column.
  • Table input uses the last variable as the response by default, or the response from a response name, formula, or ResponseVar option.
  • Additive table formulas such as Y ~ A + B are supported for numeric predictors.
  • Matrix model specifications constant, linear, interactions, purequadratic, and quadratic are supported.
  • Rows containing NaN in predictors, response, or zero weights are omitted before fitting; Inf values are rejected.
  • Exclude accepts logical masks or one-based numeric row indices. Weights accepts a numeric vector, and table input also accepts a weights variable name.
  • All eight typed-integer classes are RunMat-only inputs. Predictor, response, and weight values must be exactly representable at the binary64 fitting boundary; Exclude indices and Intercept zero/nonzero controls are parsed from authoritative integer storage.
  • The returned model exposes Coefficients, Fitted, Residuals.Raw, NumObservations, DFE, RMSE, Rsquared, Formula, PredictorNames, and ResponseName properties.
  • The Coefficients table contains Estimate, SE, tStat, and pValue variables with coefficient names in Properties.RowNames.
  • Categorical predictors, robust regression, and Wilkinson interaction formula terms are not supported yet and raise explicit errors.

Examples

Fit a matrix-input linear model

X = [0; 1; 2; 3];
y = [1; 3; 5; 7];
mdl = fitlm(X, y);
mdl.Coefficients.Estimate

Expected output:

The coefficient estimates are approximately [1; 2].

Fit and predict

mdl = fitlm(X, y);
yhat = predict(mdl, [4; 5])

Expected output:

yhat is approximately [9; 11].

Fit a named table formula

T = table(A, B, Y, 'VariableNames', {'A','B','Y'});
mdl = fitlm(T, 'Y ~ A + B')

Expected output:

mdl uses A and B as predictors and Y as the response.

Using fitlm with coding agents

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

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

FAQ

Does fitlm accept typed-integer predictors, responses, weights, or controls?⌄

MATLAB-compatible mode rejects those typed-integer roles. RunMat mode exposes separately declared extensions for predictor data, response data, Weights, Exclude/selectors, and Intercept. The fitted model remains floating and host-resident.

Does fitlm add an intercept?⌄

Yes. The default model includes an intercept. Use the Intercept option or a no-intercept formula to omit it.

How are missing rows handled?⌄

Rows with NaN in any active predictor or response are omitted before fitting, matching MATLAB's complete-observation behavior.

Related Stats functions

Ml

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

  • View the source for fitlm 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 fitlm works
  • Examples
  • Fit a matrix-input linear model
  • Fit and predict
  • Fit a named table formula
  • Using fitlm with coding agents
  • FAQ
  • Related Stats functions
  • Ml
  • Summary
  • Random
  • Hist
  • Options
  • Open-source implementation
  • About RunMat