optim_doc: LinearRegression

Next: wsolve, Previous: polyconf, Up: Residual optimization [Index]

### 2.13 Function LinearRegression

Function File: LinearRegression (F, y)
Function File: LinearRegression (F, y, w)
Function File: [p, e_var, r, p_var, fit_var] = LinearRegression (…)

  general linear regression

  determine the parameters p_j (j=1,2,...,m) such that the function f(x) = sum_(j=1,...,m) p_j*f_j(x) is the best fit to the given values y_i by f(x_i) for i=1,...,n, i.e. minimize sum_(i=1,...,n)(y_i-sum_(j=1,...,m) p_j*f_j(x_i))^2 with respect to p_j

  parameters:

  - F is an n*m matrix with the values of the basis functions at the support points. In column j give the values of f_j at the points x_i (i=1,2,...,n)
  - y is a column vector of length n with the given values
  - w is a column vector of length n with the weights of the data points. 1/w_i is expected to be proportional to the estimated uncertainty in the y values. Then the weighted expression sum_(i=1,...,n)(w_i^2*(y_i-f(x_i))^2) is minimized.

  return values:

  - p is the vector of length m with the estimated values of the parameters
  - e_var is the vector of estimated variances of the provided y values. If weights are provided, then the product e_var_i * w^2_i is assumed to be constant.
  - r is the weighted norm of the residual
  - p_var is the vector of estimated variances of the parameters p_j
  - fit_var is the vector of the estimated variances of the fitted function values f(x_i)

  To estimate the variance of the difference between future y values and fitted y values use the sum of e_var and fit_var

  Caution: do NOT request fit_var for large data sets, as a n by n matrix is generated

See also (octave)ols, (octave)gls, (octave)regress, leasqr, nonlin_curvefit, (octave)polyfit, wpolyfit, expfit.

Next: wsolve, Previous: polyconf, Up: Residual optimization [Index]