Main Page   Alphabetical List   Compound List   File List   Compound Members   File Members  

paramest.h File Reference

Linear and nonlinear regression. More...

#include "matrect.h"
#include "mattri.h"
#include "vect.h"

Include dependency graph for paramest.h:

Include dependency graph

Go to the source code of this file.

Typedefs

typedef int (* Nonlinregfunct_ )(const double *, const double *, double *)
 Nonlinregfunct_ : the type of the function which describes the (X, P)->Y relationship for the nonlinear regression routine as (X, P, Y). More...


Functions

int lin_reg (const Matrect_ *X, const Vect_ *Y, const Vect_ *Wgt, double *Sres, Vect_ *Par, Vect_ *Sd, Mattri_ *Corr, double *Dstat)
 lin_reg(X,Y,Wgt,Sres,Par,Sd,Corr,Dstat): Multiple weighed least-square linear regression. More...

double lms_fit (const double *x, const double *y, unsigned int N, double *b, double *a, double *Sigb, double *Siga, double *Sigab)
 lms_fit(x,y,N,b,a,sigb,siga,sigab): no-frills linear regression algorithm to fit y=a+bx without weighing and the other extras. More...

int nonlin_reg (Nonlinregfunct_ Funct, unsigned int ItMax, double StepLim, const Matrect_ *X, const Matrect_ *Y, const Matrect_ *Wgt, unsigned int *ItNo, double *Sres, Vect_ *Par, Vect_ *Sd, Mattri_ *Corr)
 nonlin_reg(Funct, Itmax, Steplim, X, Y, Wgt, ItNo, Sres, Par, Sd, Corr): fits the function Y=F(X,P) where X and Y are vectors, P is the parameter vector using the Gauss-Newton-Marquardt method. More...

double tcrit_95 (unsigned int Nf)
 tcrit_95(Nf): returns the value of the Nf degrees-of-freedom t-distribution at 95% significance level. More...


Detailed Description

Linear and nonlinear regression.

The algorithms come originally from Valko+Vajda.

Definition in file paramest.h.


Typedef Documentation

typedef int(* Nonlinregfunct_)(const double *, const double *, double *)
 

Nonlinregfunct_ : the type of the function which describes the (X, P)->Y relationship for the nonlinear regression routine as (X, P, Y).

X is the vector of independent variables, P is the vector of parameters and Y is the vector of the dependent variables. This general form enables the parameter estimation for vector-vector functions. NOTE that this function is not required to do any dim checks as it takes naked C arrays as arguments for speed's sake. You have been warned. Return value: this implements a rudimentary error check. Shall return 0 if OK, a non-0 (usually negative) value if something went wrong.

Definition at line 35 of file paramest.h.


Function Documentation

int lin_reg ( const Matrect_ * X,
const Vect_ * Y,
const Vect_ * Wgt,
double * Sres,
Vect_ * Par,
Vect_ * Sd,
Mattri_ * Corr,
double * Dstat )
 

lin_reg(X,Y,Wgt,Sres,Par,Sd,Corr,Dstat): Multiple weighed least-square linear regression.

Contains an optional ridge parameter Rid for the regularization of the matrix X'WX if the problem is ill-conditioned. The parameters are:- X: ptr to matrix of independent vars (Nm x Nx) Y: ptr to vector of dependent variable (Nm) Wgt: ptr to weight vector (Nm), if NULL then uniform weighting is used Sres: residual deviation Par: vector of estimated parameters (Nx, size set automatically) Sd: standard deviation of params (Nx, size set automatically) Corr: correlation matrix, lower tridiag (Nx*Nx, size set automatically) Dstat: D-statistics (not calculated if Dstat==NULL), good if 1.7<Dstat<2.3 Return value: the degrees of freedom or a negative value on errors.

Referenced by Nonlinregfunct_().

double lms_fit ( const double * x,
const double * y,
unsigned int N,
double * b,
double * a,
double * Sigb,
double * Siga,
double * Sigab )
 

lms_fit(x,y,N,b,a,sigb,siga,sigab): no-frills linear regression algorithm to fit y=a+bx without weighing and the other extras.

Use this routine for quick-and-dirty fits. So dirty, in fact, that there are no sanity checks on the parameters... The parameters:- x,y - independent and dependent variables (both N long) b - slope a - intercept siga,sigb - S.D. of intercept & slope, respectively sigab - cross-correlation Return value: the error of fit.

Referenced by Nonlinregfunct_().

int nonlin_reg ( Nonlinregfunct_ Funct,
unsigned int ItMax,
double StepLim,
const Matrect_ * X,
const Matrect_ * Y,
const Matrect_ * Wgt,
unsigned int * ItNo,
double * Sres,
Vect_ * Par,
Vect_ * Sd,
Mattri_ * Corr )
 

nonlin_reg(Funct, Itmax, Steplim, X, Y, Wgt, ItNo, Sres, Par, Sd, Corr): fits the function Y=F(X,P) where X and Y are vectors, P is the parameter vector using the Gauss-Newton-Marquardt method.

F should be supplied by the user: see comments at the declaration of the type NonlinregFunct. The algorithm requires an initial guess of the parameter values supplied in Par. Par must also be correctly dimensioned. Due to the parameter normalization used, the estimated parameters keep the sign of the corresponding initial guess. In case of extremely high Q values and bad convergence it is advisable to try sign changes.

Note on vector and matrix dimensions:- In the explanation below, Nm is the number of measurements, Nx is the dimension of the independent variables, Ny is the dimension of the dependent variables, Np is the number of parameters. These are supplied to the routine indirectly as the row and column sizes of the X, Y matrices and the dimension of Par.

The parameters:- Funct: the nonlinear function (X, P)-> Y this operates on traditional C vectors for speed and does no dim checks. It is your responsibility to make sure that Funct knows about Nx, Np and Ny being the lengths of its args X, P and Y, respectively. ItMax: max. no. of iterations StepLim: smallest stepsize allowed X: matrix of X values (indep. vars, Nm x Nx) Y: matrix of Y values (dep. variable, Nm x Ny) W: weight matrix (Nm x Ny), if NULL then uniform weighting is used ItNo: actual no. of iterations done Sres: residual deviation Par: vector (Np-long) containing the initial parameter guess on input and the final parameter estimate on output Sd: vector of estimated parameters and S.D. (Np, size adjusted within) Corr: correlation matrix (Np x Np, size adjusted within) Return value: the degrees of freedom or a negative number on error.

Referenced by Nonlinregfunct_().

double tcrit_95 ( unsigned int Nf )
 

tcrit_95(Nf): returns the value of the Nf degrees-of-freedom t-distribution at 95% significance level.

Use for confidence interval calculations.

Referenced by Nonlinregfunct_().


Generated at Wed Aug 21 09:33:30 2002 for The Razorback C Library: Statistics by doxygen1.2.6 written by Dimitri van Heesch, © 1997-2001