Fitting

From Open Ideas
Jump to navigation Jump to search

Fitting in QFF

Codebook

Construction

FitterFactory factory = FitterFactory.getInstance();

It is not possible to instantiate an IFitter object without passing some arguments to the create method. It is required to specify the name of the engine used to minimize the goodness-of-fit function, the data model containing the observations and the corresponding model values and the criterion to measure the quality of fitness.

Assume that we already have a data model, an instance of IFitModel. Then a fitter is created as follows:

IFitModel model = ...
IFitter fitter1 = factory.create("R", model, new WeightedSSE(model));

That's all. Now we have a fitter which minimizes the sum of squared errors between observed data and model data. A general-purpose optimizer of R is used to compute the minimum. It is the sum of squared errors, since the weights are all 1 by default. It is, of course, possible to change the weights on creation or at some later time.

Methods

The method getResult() returns an IFitResult object containing the relevant data of the fit process.

IFitResult result = fitter.getResult();
 
double sse = fitter.getOptimum();
double[] theta = fitter.getOptimalPoint();

See also