prepareDataR Documentation

lcMethod estimation step: logic for preparing the training 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 prepareData() function of the lcMethod object processes the training data prior to fitting the method. Example uses:

The computed variables are stored in an environment which is passed to the preFit() function for further processing.

By default, this method does not do anything.

Usage

## S4 method for signature 'lcMethod'
prepareData(method, data, verbose)

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.

verbose

A R.utils::Verbose object indicating the level of verbosity.

Value

An environment with the prepared data variable(s) that will be passed to preFit().

Implementation

A common use case for this method is when the internal method fitting procedure expects the data in a different format. In this example, the method converts the training data data.frame to a matrix of repeated and aligned trajectory measurements.

setMethod("prepareData", "lcMethodExample", function(method, data, verbose) {
  envir = new.env()
  # transform the data to matrix
  envir$dataMat = tsmatrix(data,
    id = idColumn, time = timeColumn, response = valueColumn)
  return(envir)
})

Estimation procedure

The steps for estimating a lcMethod object are defined and executed as follows:

  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.