convertSingleParam {crossvalidationCP} | R Documentation |
Provides estimators that allows list of parameters
Description
Converts estimators allowing single parameters to estimators allowing a list of parameters. The resulting function can be passed to the argument estimator
in the cross-validation functions, see See Also.
Usage
convertSingleParam(estimator)
Arguments
estimator |
the function to be converted, i.e. a function providing a local estimate. The function must have the arguments |
Value
a function that can be passed to the argument estimator
in the cross-validation functions, see the functions listed in See Also
References
Pein, F., and Shah, R. D. (2021) Cross-validation for change-point regression: pitfalls and solutions. arXiv:2112.03220.
See Also
crossvalidationCP
, VfoldCV
, COPPS
, CV1
, CVmod
Examples
# wrapper around pelt to demonstrate an estimator that allows a single parameter only
singleParamEstimator <- function(Y, param, minseglen = 1, ...) {
if (is.numeric(param)) {
ret <- changepoint::cpt.mean(data = Y, penalty = "Manual", pen.value = param, method = "PELT",
minseglen = minseglen)
} else {
ret <- changepoint::cpt.mean(data = Y, penalty = param, method = "PELT", minseglen = minseglen)
}
list(cps = ret@cpts[-length(ret@cpts)], value = as.list(ret@param.est$mean))
}
# conversion to an estimator that is suitable for crossvalidationCP() etc.
estimatorMultiParam <- convertSingleParam(singleParamEstimator)
crossvalidationCP(rnorm(100), estimator = estimatorMultiParam, param = list("SIC", "MBIC"))