Learn R Programming

latrend (version 1.3.0)

validate: lcMethod fit process: method argument validation logic

Description

Note: this function should not be called directly, as it is part of the lcMethod fitting process. For fitting an lcMethod object to a dataset, see latrend().

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.

Usage

# S4 method for lcMethod
validate(method, data, envir = NULL, ...)

Arguments

method

An object inheriting from lcMethod with all its arguments having been evaluated and finalized.

data

A data.frame representing the transformed training data.

envir

The environment in which the lcMethod should be evaluated

...

Not used.

Value

Either TRUE if all validation checks passed, or a character containing a description of the failed validation checks.

Implementation

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) ) })

Fitting procedure

Each lcMethod subclass defines a type of methods in terms of a series of steps for estimating the method. These steps, as part of the fitting procedure, are executed by latrend() in the following order:

  1. compose(): Evaluate and finalize the method argument values.

  2. validate(): Check the validity of the method argument values in relation to the dataset.

  3. prepareData(): Process the training data for fitting.

  4. preFit(): Prepare environment for estimation, independent of training data.

  5. fit(): Estimate the specified method on the training data, outputting an object inheriting from lcModel.

  6. postFit(): Post-process the outputted lcModel object.

The result of the fitting procedure is an '>lcModel object that inherits from the lcModel class.

See Also

assertthat::validate_that