Test a lcMethod subclass implementation and its resulting lcModel implementation.

test.latrend(
  class = "lcMethodKML",
  instantiator = NULL,
  data = NULL,
  args = list(),
  tests = c("method", "basic", "fitted", "predict", "cluster-single", "cluster-three"),
  maxFails = 5L,
  errorOnFail = FALSE,
  clusterRecovery = c("warn", "ignore", "fail"),
  verbose = TRUE
)

Arguments

class

The name of the lcMethod subclass to test. The class should inherit from lcMethod.

instantiator

A function with signature (id, time, response, ...), returning an object inheriting from the lcMethod specified by the class argument.

data

An optional dataset comprising three highly distinct constant clusters that will be used for testing, represented by a data.frame. The data.frame must contain the columns "Id", "Time", "Value", "Cluster" of types character, numeric, numeric, and character, respectively. All trajectories should be of equal length and have observations at the same moments in time. Trajectory observations are assumed to be independent of time, i.e., all trajectories are constant. This enables tests to insert additional observations as needed by sampling from the available observations.

args

Other arguments passed to the instantiator function.

tests

A character vector indicating the type of tests to run, as defined in the *.Rraw files inside the /test/ folder.

maxFails

The maximum number of allowed test condition failures before testing is ended prematurely.

errorOnFail

Whether to throw the test errors as an error. This is always enabled while running package tests.

clusterRecovery

Whether to test for correct recovery/identification of the original clusters in the test data. By default, a warning is outputted.

verbose

Whether the output testing results. This is always disabled while running package tests.

Note

This is an experimental function that is subject to large changes in the future. The default dataset used for testing is subject to change.

Examples

test.latrend("lcMethodRandom", tests = c("method", "basic"), clusterRecovery = "skip")
#> === Testing lcMethod class "lcMethodRandom" ===
#> == Running tests from "method" ==
#> Tests succeeded.
#> == Running tests from "basic" ==
#> Tests succeeded.
#> 
#> ~~ Successfully passed all tests! ~~
#> [1] TRUE