lcMethod
estimation step: method argument validation logicR/generics.R
, R/method.R
validate.Rd
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 validate()
function of the lcMethod
object validates the method with respect to the training data.
This enables a method to verify, for example:
whether the formula covariates are present.
whether the argument combination settings are valid.
whether the data is suitable for training.
By default, the validate()
function checks whether the id, time, and response variables are present as columns in the training data.
validate(method, data, envir, ...)
# S4 method for class 'lcMethod'
validate(method, data, envir = NULL, ...)
Either TRUE
if all validation checks passed,
or a scalar character
containing a description of the failed validation checks.
An example implementation checking for the existence of specific arguments and type:
library(assertthat)
setMethod("validate", "lcMethodExample", function(method, data, envir = NULL, ...) {
validate_that(
hasName(method, "myArgument"),
hasName(method, "anotherArgument"),
is.numeric(method$myArgument)
)
})
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 from lcModel
.
postFit()
: Post-process the outputted lcModel
object.
The result of the fitting procedure is an lcModel object that inherits from the lcModel
class.