Solutions

Curve fitting results are returned as CurveFitSolution objects. These objects store the fitted coefficients, residuals, the problem solved and the algorithm used to solve it. It also stores a return code which holds information about the success of the solver. For more information on the ReturnCode type, see SciMLBase.jl.

CurveFit.CurveFitSolutionType
CurveFitSolution(alg, coeffs, resid, prob, retcode, original=nothing)

Represents the solution to a curve fitting problem. This is a callable struct and can be used to evaluate the solution at a point. Exact evaluation mechanism depends on the algorithm used to solve the problem.

source

StatsAPI functions

CurveFitSolution objects can be treated as statistical models and CurveFit defines various statistics methods for the CurveFitSolution type, many of which extend StatsAPI.jl functions.

StatsAPI.residualsFunction
residuals(sol::CurveFitSolution)

Return the residuals of the fitted model.

Residuals are defined as the difference between the observed data and the model predictions evaluated at the fitted coefficients.

source
StatsAPI.dofFunction
dof(sol::CurveFitSolution)

Return the number of degrees of freedom of the model.

source
StatsAPI.dof_residualFunction
dof_residual(sol::CurveFitSolution)

Return the residual degrees of freedom.

This is defined as nobs(sol) - dof(sol).

source
StatsAPI.predictFunction
predict(sol::CurveFitSolution, x = sol.prob.x)

Evaluate the fitted model with new data.

If x is not provided, predictions are returned at the original data points used during fitting.

source
StatsAPI.coefFunction
coef(sol::CurveFitSolution)

Return the fitted coefficients.

The ordering of coefficients depends on the fitting algorithm used.

source
StatsAPI.nobsFunction
nobs(sol::CurveFitSolution)

Return the number of observations used in the fit.

source
StatsAPI.fittedFunction
fitted(sol::CurveFitSolution)

Return the fitted values at the original data points.

source
StatsAPI.rssFunction
rss(sol::CurveFitSolution)

Return the residual sum of squares (RSS).

This is defined as sum(abs2, residuals(sol)).

source
CurveFit.isconvergedFunction
isconverged(sol::CurveFitSolution)

Return true if the underlying solver successfully converged.

This is determined from the solver return code.

source
StatsAPI.vcovFunction
vcov(sol::CurveFitSolution)

Return the variance–covariance matrix of the fitted coefficients.

The covariance matrix is computed using the Jacobian of the fitted model and a QR-based least squares formulation. This function is defined for solutions to both linear and nonlinear problems.

source
StatsAPI.stderrorFunction
stderror(sol::CurveFitSolution; rtol = NaN, atol = 0)

Return the standard errors of the fitted coefficients.

Standard errors are computed as the square roots of the diagonal elements of the variance–covariance matrix.

source
CurveFit.margin_errorFunction
margin_error(sol::CurveFitSolution, alpha = 0.05; rtol::Real = NaN, atol::Real = 0)

Returns the margin of error of the fitted coefficients, computed as stderror(sol) * t where t is the critical value of the t-distribution for `1

  • alpha / 2`.
source
StatsAPI.confintFunction
confint(sol::CurveFitSolution; level = 0.95, rtol = NaN, atol = 0)

Return confidence intervals for the fitted parameters.

The confidence intervals are returned as a vector of (lower, upper) tuples, computed as coef(sol) ± margin_error(sol).

source