In file mydocsrc/gml_gfit.h:

class gml_generic_fitter

Base class for model fitting

Inheritance:

gml_generic_fitter


Public

A: What to do in your derived (child) class.
Constructor to call.
gml_generic_fitter (IML_USINT PCount)
The base class constructor
Parameter to set.
IML_ULINT DataCount
Data count in the fitting process
Methods to over-ride for Powell's method.
virtual IML_DOUBLE evaluate (register gml_double_vec &Parameters)
Evaluate the model error given specific model parameters
Methods to over-ride for fit statistics.
virtual IML_DOUBLE model_error (register IML_ULINT I)
For data point I, the difference between data and model.
virtual IML_DOUBLE data (register IML_ULINT I)
The value of data point I (assuming scalar data).
virtual IML_DOUBLE weight (register IML_ULINT I)
The weight of data point I (should be defaulted to 1).
B: Fitting, convergence and parameter configuration.
IML_DOUBLE fitdata (void)
Run the fitter on the data.
void set_convergence (IML_DOUBLE Eps, IML_LINT MaxI)
Set the tolerance and maximum number of iterations for Powell's method.
void configure_parameter (IML_USINT I, ptr_to_const_char Name, IML_DOUBLE Min, IML_DOUBLE Max, IML_DOUBLE Value, IML_LINT OptimizeOrNot = TRUE)
Use this method to completely configure a single parameter
ptr_to_const_char& parameter_name (IML_USINT I)
Configure or access parameter name.
IML_DOUBLE& parameter_max (IML_USINT I)
Configure or access parameter maximum allowed value.
IML_DOUBLE& parameter_min (IML_USINT I)
Configure or access parameter minimum allowed value.
IML_DOUBLE& parameter_value (IML_USINT I)
Configure or access current parameter value.
IML_LINT& optimize_flag (IML_USINT I)
Configure or access whether a parameter will be optimized.
C: Calculating standard fit statistics.
void calculate_fit_statistics (void)
Once fitdata() is called, this calculales the standard goodness-of-fit statistics.
D: Unweighted fit statistics.
IML_DOUBLE PseudoOccamFactor
See McKay (bla bla bla).
IML_FLOAT AlgebraicMean
Data mean.
IML_FLOAT StandardDeviation
Data standard deviation.
IML_FLOAT CoeffOfDetermination
The coefficient of determination for the model.
IML_FLOAT RSquared
The r^2 for the model.
IML_FLOAT MSC
The Model Selection Criterion for the model.
E: Weighted fit statistics.
IML_FLOAT WeightedMean
Weighted data mean.
IML_FLOAT WStandardDeviation
Weighted data standard deviation.
IML_FLOAT WCoeffOfDetermination
Weighted coefficient of determination for the model.
IML_FLOAT WRSquared
Weighted r^2 for the model.
IML_FLOAT WMSC
Weighted Model Selection Criterion for the model.
F: Calculating standard error bounds on parameters.
void calculate_covariance_information (void)
Calculate information from the evaluate() (error) surface for use in parameter error bounds
IML_FLOAT covariance (IML_USINT I, IML_USINT J)
Access the covariance value for two parameters.
IML_FLOAT correlation (IML_USINT I, IML_USINT J)
Access the correlation value for two parameters.
IML_FLOAT hessian (IML_USINT I, IML_USINT J)
Access the entries in the Hessian.
IML_FLOAT error (IML_USINT I, IML_USINT J)
Access the estimates of (lower bound) error for the Hessian entries.
G: Calculating robust error bounds via error-surface search.
double find_parameter_CI (IML_LINT UpOrDown, IML_DOUBLE Contour, IML_LINT TargetParm, IML_DOUBLE LowBracket, IML_DOUBLE HighBracket, IML_DOUBLE Tolerance, IML_LINT & MaxSteps)
Method for finding error bounds on parameters via evaluate() surface contours.
H: Informational variables.
IML_ULINT ParmCount
This parameter is set at construction time, and is what it says.
IML_ULINT FittedParmCnt
This parameter is set when fitdata() is called.
IML_ULINT CovMatrixRank
This parameter is set when calculate_covariance_information() is called.
IML_LINT DegreesOfFreedom
This parameter is DataCount - FittedParmCount.
IML_DOUBLE Determinant
Hessian determinant for singular-matrix checking.
IML_LINT Evaluations
The total number of calls to the model evaluation function
IML_LINT LineMinimizations
Total number of sub-optimizations in all iterations of Powell's method.
IML_LINT PowellIterations
Total number of iterations of Powell's method to reach the minimum.

Documentation

Base class for model fitting. This class provides the interface and basic tools for fitting linear or nonlinear models to data. If you can write the code for the model, then you can probably use this.

The current fitter implements Powell's method as it is outlined in NRC. The error function is to be defined in a derived (child) class along with a few other things. This base class provides other tools in addition to a method for finding the optimal parameter values (Powell's method), namely, goodness of fit measures, and two methods for determining error bounds on the optimal parameter estimates.

A: What to do in your derived (child) class.

There are several actions to take when producing a specific fitter from this base class. This includes properly calling the constructor for this base class, setting the value of a specific variable and over-riding several class methods (writing the contents of specific functions) that are needed by the tools provided in this base class.

Constructor to call.

gml_generic_fitter(IML_USINT PCount)
The base class constructor. No other constructors are provided, and there is no default value for the parameter count.
Returns:
None (constructors don't return values).
Parameters:
PCount - The model parameter count.

Parameter to set.

IML_ULINT DataCount
Data count in the fitting process. This value must be set so that Degrees of Freedom can be calculated correctly.

Methods to over-ride for Powell's method.

virtual IML_DOUBLE evaluate(register gml_double_vec &Parameters)
Evaluate the model error given specific model parameters. This virtual method is called by the implementation of Powell's method ("method" used differently in these two senses) and should calculate some metric of the error between the model and the data. This could be the sum-of-squared-error for each data point, or perhaps the chi-squared value if we are doing a maximum likelihood fit.
Returns:
The return value should be the "error" of the model relative to the data.
Parameters:
Parameters - is a gml_double_vec reference filled with parameter values selecting a specific instance of the model family.
See Also:
Numerical Recipes in C for explanation of the chi-square statistic and its relationship to squared error.

Methods to over-ride for fit statistics.

B: Fitting, convergence and parameter configuration.

C: Calculating standard fit statistics.

D: Unweighted fit statistics.

E: Weighted fit statistics.

F: Calculating standard error bounds on parameters.

void calculate_covariance_information(void)
Calculate information from the evaluate() (error) surface for use in parameter error bounds. First the Hessian of the evaluate() (error) surface is calculated, together with a (lower bound) estimate on the amount of error for each entry in the matrix. Then the covariance and correlation matrices for the parameters is calculated from the Hessian.

G: Calculating robust error bounds via error-surface search.

H: Informational variables.

IML_LINT Evaluations
The total number of calls to the model evaluation function. This must be set in the evaluate() function call defined in the child class.


Direct child classes:
my_fitter

alphabetic index hierarchy of classes


generated by doc++