nlparci — Confidence intervals for nonlinear least-squares parameter estimates.
nlparci(beta,r,'Jacobian',J) or nlparci(beta,r,'Covar',CovB) returns lower and upper confidence bounds for each fitted parameter.
Syntax
ci = nlparci(beta, r, 'Jacobian', J)
ci = nlparci(beta, r, 'Covar', CovB)
ci = nlparci(beta, r, method, data, 'Alpha', alpha)Inputs
beta- Type
NumericArray- Required
- Yes
- Default
- —
- Description
- Estimated real single or double parameter vector.
r- Type
NumericArray- Required
- Yes
- Default
- —
- Description
- Residual vector with one value per observation.
method- Type
StringScalar- Required
- Yes
- Default
- —
- Description
- Jacobian or Covar.
J or CovB- Type
NumericArray- Required
- Yes
- Default
- —
- Description
- Jacobian matrix or estimated covariance matrix.
Alpha- Type
StringScalar- Required
- Yes
- Default
- —
- Description
- Alpha option name.
alpha- Type
NumericScalar- Required
- Yes
- Default
0.05- Description
- Significance level strictly between zero and one.
Returns
ci- Type
NumericArray- Description
- N-by-2 lower and upper confidence interval bounds.
Errors
RunMat:nlparci:InvalidArgument- When
- The option, class, shape, or significance level is invalid.
- Message
nlparci: invalid argument
RunMat:nlparci:NumericalFailure- When
- There are insufficient complete observations, a rank-deficient Jacobian, or the interval calculation cannot be completed.
- Message
nlparci: numerical failure
Input forms
beta and r are real single or double vectors. J has one row per residual and one column per coefficient. CovB is a square estimated parameter covariance matrix with one row and column per coefficient. Optional 'Alpha',alpha sets the significance level in the open interval (0,1); the default is 0.05.
The covariance form is appropriate when the fitting procedure supplies its own covariance estimate, including robust fits. The Jacobian form estimates covariance from the complete residual sum of squares and the inverse normal equations using a rank-revealing SVD. NaN residuals, and rows with NaN Jacobian entries in the Jacobian form, are omitted as missing observations. Inf is rejected.
Intervals and execution
The N-by-2 result contains lower bounds in column one and upper bounds in column two. Both forms use the two-sided Student-t critical value with complete-observation count minus parameter count degrees of freedom. At least one positive degree of freedom is required; the Jacobian must have full column rank. A zero residual variance gives a zero-width interval.
The computation is CPU-owned and can suspend while gathering resident real floating inputs. Resident inputs are a RunMat-only extension and are rejected by MATLAB compatibility mode before provider access. It does not have a provider-native confidence-interval kernel or fuse with preceding GPU operations. Output class follows beta: a single beta produces single bounds; a double beta produces double bounds. Native integer, logical, complex, and sparse inputs are not accepted. Finite host-allocation admission for ordinary statistics calls remains an implementation limitation.
Examples
Compute equivalent intervals from a Jacobian and covariance
beta = [1; 2]; r = [1; -1; 1; -1]; J = [1 -1; 1 -1; 1 1; 1 1]; ciJ = nlparci(beta,r,'Jacobian',J); CovB = [0.5 0; 0 0.5]; ciC = nlparci(beta,r,'Covar',CovB);Expected output:
Both forms produce the same 2-by-2 intervals for this orthogonal Jacobian.Use a narrower confidence level
beta = 1; r = [1; -1; 0]; J = [1; 1; 1]; ci95 = nlparci(beta,r,'Jacobian',J); ci90 = nlparci(beta,r,'Jacobian',J,'Alpha',0.1);Expected output:
The 90% interval is narrower than the 95% interval.Using nlparci with coding agents
Open a RunMat example with live inputs, then ask the agent to explain how nlparci changes the result.
Run a small nlparci example, explain the result, then change one input and compare the output.
FAQ
When should I use Covar rather than Jacobian?⌄
Use Covar when your fitting procedure supplies an estimated coefficient covariance matrix, particularly for robust fits. The Jacobian form estimates covariance from residuals and J.
What happens when the Jacobian is rank deficient?⌄
RunMat reports a numerical failure because finite ordinary confidence intervals are not identified by a rank-deficient Jacobian.
Related Stats functions
Ml
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
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
Source you can read
Every RunMat function's source is public. Read exactly how nlparci is executed, line by line, in Rust.
- View the source for nlparci 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.