In file example_fitter.h:

class my_fitter : public gml_generic_fitter

The my_fitter class is an example of how to use the gml_generic_fitter class

Inheritance:

my_fitter < gml_generic_fitter


Public Fields

IML_DOUBLE BestLogLikelihood
A variable to hold an important quantity
my_data IML_PTR Data
A pointer which holds an array of my_data structures

Public Methods

IML_DOUBLE bestLL (void)
Calculate the absolute minimum best fit
virtual IML_DOUBLE data (register IML_ULINT I)
An interface function that must be defined
virtual IML_DOUBLE evaluate ( register gml_double_vec &PVector)
The only interface function that must absolutely be defined
virtual IML_DOUBLE model_error (register IML_ULINT I)
An interface function that must be defined
my_fitter (IML_USINT DCnt)
The only constructor
virtual IML_DOUBLE weight (register IML_ULINT I)
An interface function that must be defined
~my_fitter ()
The only destructor

Inherited from 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

The my_fitter class is an example of how to use the gml_generic_fitter class. We will us it to fit a Weibull function to psychometric data. The class is derived from the gml_generic_fitter class, as described in the documentation. All I need to do is tell gml_generic_fitter that I need two parameters, make sure to set the DataCount variable that I inherit from gml_generic_fitter, then initialize my own stuff.
my_fitter(IML_USINT DCnt)
The only constructor. It tells gml_generic_fitter that there are two parameters, and initializes the DataCount variable inherited from gml_generic_fitter, and allocates the my_data array.

~my_fitter()
The only destructor. Just dallocates the my_data array.

virtual IML_DOUBLE model_error(register IML_ULINT I)
An interface function that must be defined. Returns the model error for the point so that goodness-of-fit statistics can be calculated.

virtual IML_DOUBLE data(register IML_ULINT I)
An interface function that must be defined. Returns the data value of the point so that goodness-of-fit statistics can be calculated.

virtual IML_DOUBLE weight(register IML_ULINT I)
An interface function that must be defined. Returns the model confidence weight for the point so that goodness-of-fit statistics can be calculated.

virtual IML_DOUBLE evaluate( register gml_double_vec &PVector)
The only interface function that must absolutely be defined. Returns the model error upon which the fitter shall operate, and from which covariance and correlation matrices will eventually be calcualted.


This class has no child classes.

alphabetic index hierarchy of classes


generated by doc++