| fit {latrend} | R Documentation |
lcMethod estimation step: logic for fitting the method to the processed data
Description
Note: this function should not be called directly, as it is part of the lcMethod estimation procedure.
For fitting an lcMethod object to a dataset, use the latrend() function or one of the other standard estimation functions.
The fit() function of the lcMethod object estimates the model with the evaluated method specification, processed training data, and prepared environment.
Usage
fit(method, data, envir, verbose, ...)
## S4 method for signature 'lcMethod'
fit(method, data, envir, verbose)
Arguments
method |
An object inheriting from |
data |
A |
envir |
The |
verbose |
A R.utils::Verbose object indicating the level of verbosity. |
... |
Not used. |
Value
The fitted object, inheriting from lcModel.
Implementation
This method should be implemented for all lcMethod subclasses.
setMethod("fit", "lcMethodExample", function(method, data, envir, verbose) {
# estimate the model or cluster parameters
coefs <- FIT_CODE
# create the lcModel object
new("lcModelExample",
method = method,
data = data,
model = coefs,
clusterNames = make.clusterNames(method$nClusters)
)
})
Estimation procedure
The steps for estimating a lcMethod object are defined and executed as follows:
-
compose(): Evaluate and finalize the method argument values. -
validate(): Check the validity of the method argument values in relation to the dataset. -
prepareData(): Process the training data for fitting. -
preFit(): Prepare environment for estimation, independent of training data. -
fit(): Estimate the specified method on the training data, outputting an object inheriting fromlcModel. -
postFit(): Post-process the outputtedlcModelobject.
The result of the fitting procedure is an lcModel object that inherits from the lcModel class.