# Linear and Nonlinear Regression

Regression is a method of estimating the relationship between a response (output) variable and one or more predictor (input) variables. You can use linear and nonlinear regression to predict, forecast, and estimate values between observed data points. Curve Fitting Toolbox™ functions allow you to perform regression by fitting a curve or surface to data using the library of linear and nonlinear models, or custom equations.

Use the Curve Fitter app to fit curves
and surfaces to data interactively. For more information, see Curve Fitting. You can also use the `fit`

function to fit a
curve or surface to a set of data at the command line. For a simple example,
see Polynomial Curve Fitting.

## Apps

Curve Fitter | Fit curves and surfaces to data |

## Functions

## Topics

### Tutorials

**Parametric Fitting**

Find all library model types for the Curve Fitter app and the`fit`

function, set fit options, and optimize starting points.**Introduction to Least-Squares Fitting**

Perform least-squares fitting by using error distributions and linear, weighted, robust, and nonlinear least squares.**Polynomial Models**

Fit polynomials in the Curve Fitter app or with the`fit`

function.**Exponential Models**

Fit exponential models in the Curve Fitter app or with the`fit`

function.**Fit Logarithmic Models**

A logarithmic model has a steep initial period of growth before continuing to grow at a slower rate.**Fit Fourier Models**

Fit Fourier series models in the Curve Fitter app or with the`fit`

function.**Gaussian Models**

Fit Gaussian models in the Curve Fitter app or with the`fit`

function.**Power Series**

Fit power series models in the Curve Fitter app or with the`fit`

function.**Rational Models**

Fit rational polynomial models in the Curve Fitter app or with the`fit`

function.**Sum of Sines Models**

Fit sum of sines models in the Curve Fitter app or with the`fit`

function.**Weibull Distributions**

Fit Weibull distribution models in the Curve Fitter app or with the`fit`

function.**Fit Sigmoidal Models**

*Sigmoidal models*are S-shaped curves that are commonly used to model dose-response curves and population dynamics.**Custom Models**

If the Curve Fitting Toolbox library does not contain a desired parametric equation, you can create your own custom equation.**Custom Linear Fitting**

In the Curve Fitter app, you can use the**Custom Equation**fit to define your own linear or nonlinear equations.

### Tools Workflow

**Interactive Curve and Surface Fitting**

Select data and model types to fit curves and surfaces by using the Curve Fitter app and then save your session.**Data Selection**

Select data to fit curves and surfaces in Curve Fitter app, identify compatible size data and troubleshoot data problems.**Compare Fits in Curve Fitter App**

Find the best fit by comparing visual and numeric results, including fitted coefficients and goodness-of-fit statistics.**Surface Fitting to Franke Data**

Create and compare surface fits in Curve Fitter app using example data.**Surface Fitting to Biopharmaceutical Data**

Curve Fitting Toolbox software provides some example data for an anesthesia drug interaction study.**Custom Nonlinear ENSO Data Analysis**

This example fits the ENSO data using several custom nonlinear equations.**Gaussian Fitting with an Exponential Background**

This example fits two poorly resolved Gaussian peaks on a decaying exponential background using a general (nonlinear) custom model.

### Programmatic Workflow

**Curve and Surface Fitting**

Workflow for programmatic curve and surface fitting in Curve Fitting Toolbox.**List of Library Models for Curve and Surface Fitting**

Find all Curve Fitting Toolbox library model names for programmatic data fitting with the`fit`

function.**Curve and Surface Fitting Objects and Object Functions**

Learn how to create, access, and modify curve and surface fit objects.**Polynomial Curve Fitting**

This example shows how to fit polynomials up to sixth degree to some census data using Curve Fitting Toolbox.**Fit Polynomial Model to Data**

This example shows how to fit a polynomial model to data using the linear least-squares method.**Compare Robust Fitting Methods**

This example shows how to fit a polynomial model to data using the bisquare weights, least absolute residuals (LAR), and linear least-squares methods.**Custom Nonlinear Census Fitting**

This example shows how to fit a custom equation to census data, specifying bounds, coefficients, and a problem-dependent parameter.**Fit Exponential Model to Data**

This example shows how to fit an exponential model to data using the trust-region and Levenberg-Marquardt nonlinear least-squares algorithms.**Improve Model Fit with Weights**

This example shows how to fit a polynomial model to data using both the linear least-squares method and the weighted least-squares method for comparison.**Surface Fitting with Custom Equations to Biopharmaceutical Data**

This example shows how to use Curve Fitting Toolbox™ to fit response surfaces to some anesthesia data to analyze drug interaction effects.