# Nonlinear least squares

Gretl Manual: Gnu Regression, Econometrics and Time-series Library
Prev |  | Next

# Chapter 9. Nonlinear least squares

# Introduction and examples

As of version 1.0.9, `gretl` supports nonlinear least squares (NLS) using a variant of the Levenberg–Marquandt algorithm. The user must supply a specification of the regression function; prior to giving this specification the parameters to be estimated must be "declared" and given initial values. Optionally, the user may supply analytical derivatives of the regression function with respect to each of the parameters. The tolerance (criterion for terminating the iterative estimation procedure) can be set using the `genr` command.

The syntax for specifying the function to be estimated is the same as for the `genr` command. Here are two examples, with accompanying derivatives.

Example 9-1. Consumption function from Greene

    	  nls C = alpha + beta * Y^gamma
    	  deriv alpha = 1
    	  deriv beta = Y^gamma
    	  deriv gamma = beta * Y^gamma * log(Y)
    	  end nls

Example 9-2. Nonlinear function from Russell Davidson

    	  nls y = alpha + beta * x1 + (1/beta) * x2
    	  deriv alpha = 1
    	  deriv beta = x1 - x2/(beta*beta)
    	  end nls

Note the command words `nls` (which introduces the regression function), `deriv` (which introduces the specification of a derivative), and `end nls`, which terminates the specification and calls for estimation. If the `--vcv` flag is appended to the last line the covariance matrix of the parameter estimates is printed.

Prev | Home | Next
Boxplots |  | Initializing the parameters