postFit {latrend} | R Documentation |
lcMethod
estimation step: logic for post-processing the fitted lcModel
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 postFit()
function of the lcMethod
object defines how the lcModel
object returned by fit()
should be post-processed.
This can be used, for example, to:
Resolve label switching.
Clean up the internal model representation.
Correct estimation errors.
Compute additional metrics.
By default, this method does not do anything. It merely returns the original lcModel
object.
This is the last step in the lcMethod
fitting procedure. The postFit
method may be called again on fitted lcModel
objects, allowing post-processing to be updated for existing models.
Usage
postFit(method, data, model, envir, verbose, ...)
## S4 method for signature 'lcMethod'
postFit(method, data, model, envir, verbose)
Arguments
method |
An object inheriting from |
data |
A |
model |
The |
envir |
The |
verbose |
A R.utils::Verbose object indicating the level of verbosity. |
... |
Not used. |
Value
The updated lcModel
object.
Implementation
The method is intended to be able to be called on previously fitted lcModel
objects as well, allowing for potential bugfixes or additions to previously fitted models.
Therefore, when implementing this method, ensure that you do not discard information from the model which would prevent the method from being run a second time on the object.
In this example, the lcModelExample
class is assumed to be defined with a slot named "centers"
:
setMethod("postFit", "lcMethodExample", function(method, data, model, envir, verbose) { # compute and store the cluster centers model@centers <- INTENSIVE_COMPUTATION return(model) })
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 outputtedlcModel
object.
The result of the fitting procedure is an lcModel object that inherits from the lcModel
class.