The error in delay_calculator() at rtestim/R/cv_estimate_rt.R:126:5 says:
! The minimum spacing in xout must be at least
delay_distn_periodicity.
ℹ delay_distn_periodicity = 1 compared to 0 for xout.
Run rlang::last_trace() to see where the error occurred.
Warning messages:
1: In min(xout) : no non-missing arguments to min; returning Inf
2: In max(xout) : no non-missing arguments to max; returning -Inf
The empty subsets of samples makes the diff(xout) = 0 in line 74. We should drop the empty subsets and throw a warning in cv_estimate_rt(). Here is the solution:
# under line 93, add the warning info if there are nonempty subsets:
if (length(unique(middle_fold)) < nfold)
cli::cli_warn("Number of randomly generated folds is less than `nfold`.")
# in the for loop, iterate through non-empty subsets:
for (f in unique(middle_fold))
# drop NAs in the summary table after computation in the for loop:
cvall <- cvall[unique(middle_fold), !index]
# correct the number of total folds in the calculation of `cv_se` in the end:
sqrt(nrow(cvall)) # divided by it
Please try the following code to reproduce the error.
The error in
delay_calculator()
at rtestim/R/cv_estimate_rt.R:126:5 says: ! The minimum spacing inxout
must be at leastdelay_distn_periodicity
. ℹdelay_distn_periodicity
= 1 compared to 0 forxout
. Runrlang::last_trace()
to see where the error occurred. Warning messages: 1: In min(xout) : no non-missing arguments to min; returning Inf 2: In max(xout) : no non-missing arguments to max; returning -InfThe empty subsets of samples makes the
diff(xout) = 0
in line 74. We should drop the empty subsets and throw a warning incv_estimate_rt()
. Here is the solution: