pr_tree_control_cv: Control parameters for PRTree with optional cross-validation

View source: R/prtree_control.R

pr_tree_control_cvR Documentation

Control parameters for PRTree with optional cross-validation

Description

Creates a list of control parameters for Probabilistic Regression Trees. The base function pr_tree_control returns parameters for tree construction. The extended function pr_tree_control_cv returns both tree parameters and cross-validation settings.

Usage

pr_tree_control_cv(method = "montecarlo", n_rep = 10, only_sigma = FALSE,
  prop_test = 0.2, prop_valid = 0.2, stratify = FALSE,
  update_final = TRUE, fold_idx = NULL, ...)

Arguments

method

Character. Cross-validation method: either "kfold" or "montecarlo". Default is "montecarlo".

n_rep

Integer. Number of folds for k-fold CV or number of iterations for Monte Carlo CV. Default is 10.

only_sigma

Logical. If TRUE, performs only \boldsymbol\sigma estimation without estimating test error. Default is FALSE.

  • When sigma_grid has multiple rows (or is NULL): only_sigma = TRUE selects \boldsymbol\sigma but does not use a test set. only_sigma = FALSE performs both \boldsymbol\sigma selection and test error estimation.

  • When sigma_grid has a single row (fixed sigma): only_sigma is automatically set to FALSE, as only test error estimation is meaningful.

prop_test

Numeric between 0 and 1. Proportion of data for the test set in Monte Carlo CV. Default is 0.2.

  • For method = "montecarlo": Defines the proportion for the test set. If 0, no test set is used (useful for \boldsymbol\sigma estimation only). Ignored if only_sigma = TRUE.

  • For method = "kfold": This parameter is ignored. The test set is defined by the folds. To perform only \boldsymbol\sigma estimation with k-fold, set only_sigma = TRUE.

prop_valid

Numeric between 0 and 1. Proportion of the training set to use for validation (\boldsymbol\sigma selection). Default is 0.2.

  • If ⁠> 0⁠: the training set is split into training (1 - prop_valid) and validation (prop_valid) sets. The optimal \boldsymbol\sigma is chosen based on validation MSE.

  • If 0: No validation split is created. The algorithm still evaluates all \boldsymbol\sigma candidates in the grid, but selects the optimal one based on the in-sample (training) MSE. This can lead to overfitting.

stratify

Logical. If TRUE, performs stratified sampling based on missing values in X. Default is FALSE.

update_final

Logical. If TRUE, updates the final model with the optimal \boldsymbol\sigma after cross-validation. Default is TRUE. When TRUE (and prop_valid > 0), after selecting the optimal \boldsymbol\sigma on a validation set, the model is re-fitted using the entire training set of the current fold/iteration before evaluating on the test set. If FALSE, the model fitted on the smaller training subset (used for sigma selection) is used for evaluation, which can be faster but may yield higher test error estimates.

fold_idx

Integer. Optional. A numeric vector with fold numbers (from 1 to n_rep) for each observation, allowing for pre-defined folds. If provided, method is ignored and k-fold CV is used.

...

Control parameters for PRTree. See pr_tree_control

Details

Choosing the right configuration:

Goal Method Parameters
Estimate sigma + test error any prop_valid > 0, only_sigma = FALSE
Test error only (sigma known) any prop_valid = 0, only_sigma = FALSE
Sigma selection only montecarlo prop_test = 0, only_sigma = TRUE
Sigma selection only kfold only_sigma = TRUE

Value

A list of class prtree.control_cv containing merged with cross-validation settings

See Also

pr_tree for fitting a single tree,

pr_tree_cv for cross-validation.

Examples

# Default Monte Carlo CV
cv1 <- pr_tree_control_cv()

# Monte Carlo CV with custom parameters
cv2 <- pr_tree_control_cv(
  method = "montecarlo",
  n_rep = 20,
  prop_test = 0.3,
  prop_valid = 0.2,
  stratify = TRUE
)


PRTree documentation built on Nov. 23, 2026, 9:08 a.m.