Compare growth curve models on the valid weight records of each pig, in two ways:
blocked k-fold cross-validation: the days of each pig are cut into
blocks of block_days consecutive days, and the blocks are split into
k folds at random; each fold in turn is left out, the curve is fitted
on the others and predicts the valid weights of the left-out days;
truncation: the first (late entry) or last (early exit) trim_days
days are hidden, ADG is computed again and compared with the ADG from
all records of the same model.
In both, all weight records of the hidden days are removed before
cleaning: the remaining records are cleaned again with the settings of
qc (clean_weight()), so the hidden days do not decide which of the
other records are kept (before 1.5.0 the records were cleaned on all
days, and folds were single random days, whose neighbours stayed in the
training data).
Result of clean_weight().
Curve models to compare (values of curve_model).
Extrapolations to compare (values of curve_extrap):
"start", "curve", "tangent" or several. Default: the one of
qc. Other than "curve", a model is labelled e.g. "poly2+tangent". Mainly the truncation results differ;
in cross-validation, only the folds with the first or last block of
days are extrapolated.
Number of folds. Default 5.
Length of the blocks of days for the folds. Default 7; 1 gives single random days (more optimistic: a left-out day is close to its neighbours).
Cross-validation error (kg) above which a pig counts as
badly predicted, in cv_share_over. Default 10.
Days hidden at the start or the end of the test.
Default c(10, 20).
QC settings: the weight cleaning rules and stage_range,
max_extrap_days.
Use a random sample of at most this many pigs. Default
NULL: all.
Random seed for the folds.
0 (silent), 1 (summary and progress, default).
Number of CPU cores. Default 1.
A list of class ppt_validation with
summary: one row per model (and extrapolation): cv_rmse and
cv_mae, the median over pigs of each pig's prediction error (kg,
weight of the left-out records; a few pigs with an absurd
extrapolation, e.g. poly3 over a left-out block, would dominate a
mean), cv_share_over the share of pigs with an error above
cv_limit kg, and for each truncation (late10, early10, ...)
the ADG bias, rmse (g/d) and Spearman rank correlation spearman
with the full-data ADG, and how many pigs still get an ADG (n);
cv: cross-validation error of every pig and model;
truncation: ADG of every pig, model and truncation;
settings.