Each iteration splits the sequences once into a training and a testing set,
fits every estimator to both halves, and compares the two networks with
compare_networks().
Arguments
- data
Sequence data in long or wide form.
- models
Character vector of TNA estimators to compare, any of
"tna","ftna","ctna","atna". The default runs all four.- iterations
Number of train/test splits, a whole number of at least 1, default
20.- training_fraction
Fraction of sequences assigned to the training half, strictly between 0 and 1, default
0.7. At least two training sequences are always used, and a split leaving fewer than two testing sequences is an error.- format, id, period, state
Arguments describing the shape and column names of
data. They are used to reshapedatabefore splitting; both halves are then fitted in wide form.- seed
Optional single seed, restored on exit.
- ...
Further arguments passed to
fit_tna().
Value
A plain base data.frame with one row per iteration and estimator
and the columns iteration, model, and the compare_networks()
agreement metrics pearson, cosine, mae, rmse, jaccard, edges_x
and edges_y. This is not a simulab_sim.
Examples
data <- simulate_sequences(n = 60, n_states = 3, chain_length = 12, seed = 1)
if (requireNamespace("tna", quietly = TRUE)) {
cross_validate_tna(data, models = c("tna", "ftna"), iterations = 2, seed = 1)
}