pr_tree_control: Control parameters for PRTree

View source: R/prtree_control.R

pr_tree_controlR Documentation

Control parameters for PRTree

Description

This function creates a list of control parameters for the pr_tree function, with validation for each parameter.

Usage

pr_tree_control(sigma_grid = NULL, grid_size = 8, min_mult = 0,
  max_mult = 2, tiny_sigma = NULL, max_terminal_nodes = 15L,
  max_depth = max_terminal_nodes - 1, cp = 0.01, n_min = 5L,
  prop_x = 0.1, p_min = 0.05, prop_hold = 0.2, idx_train = NULL,
  fill_type = 2L, proxy_crit = "both", n_candidates = 3L,
  by_node = FALSE, dist = "norm", iprint = -1, verbose = TRUE, ...)

Arguments

sigma_grid

Optional. Custom grid of candidate \boldsymbol\sigma vectors. See ‘Details’ for accepted formats and behavior. Default is NULL (automatic generation).

Note: The dimensions of sigma_grid are not validated inside pr_tree_control. Dimension checking against the number of features is performed internally during the execution of pr_tree or pr_tree_cv.

grid_size

Integer. Number of candidate vectors to generate when sigma_grid = NULL. Default is 8. See ‘Details’ for how multipliers are generated. Ignored when a custom grid is provided.

min_mult

Numeric. Minimum multiplier for automatic grid generation. Default is 0. See ‘Details’ for how this defines the multiplier interval. Ignored when a custom grid is provided.

max_mult

Numeric. Maximum multiplier for automatic grid generation. Default is 2. Ignored when a custom grid is provided.

tiny_sigma

A single numeric value or NULL. If provided, it is added to the grid as an additional candidate representing a very small \sigma value (same value for all features). This approximates the limiting case \boldsymbol\sigma \to \boldsymbol{0}, where the smooth assignment function \Psi converges to the hard indicator function, recovering deterministic splits. A typical value is 1e-20. See ‘Details’ for its role in grid generation. Default is NULL. Ignored when a custom grid is provided.

max_terminal_nodes

A non-negative integer. The maximum number of terminal nodes (regions/leaves) in the output tree. The default is 15.

max_depth

A non-negative integer. The maximum depth of the decision tree. The depth is defined as the length of the longest path from the root to a leaf. The default is max_terminal_nodes - 1.

cp

A positive numeric value. The complexity parameter. Any split that does not decrease the MSE (mean square error) by a factor of at least cp will be ignored. The default is 0.01.

n_min

A positive integer. The minimum number of observations required in a terminal (final) node. While Probabilistic Regression Trees can theoretically handle empty regions, this restriction is enforced to ensure the stable and well-posed calculation of the region's cut points (thresholds) based on empirical data. The default is 5.

prop_x

A numeric value between 0 and 1. The minimum proportion of observations in a region that must have a probability greater than p_min to attempt a split. Default is 0.1. See ‘Details’ for more information.

p_min

A numeric value between 0 and 1. The threshold probability used in conjunction with prop_x to evaluate if a region contains enough probability mass to be split. Default is 0.05. See ‘Details’.

prop_hold

A numeric value between 0 (inclusive) and 1 (exclusive) that specifies the proportion of the data to be held out for model validation or testing. Default is 0.2. Ignored if idx_train is provided.

idx_train

Optional integer vector specifying which observations to use as the training sample. Default is NULL. Overrides prop_hold.

fill_type

Integer indicating the method to be used to fill the probability matrix when X has NA's. Default is 2.

  • 0: uniform (same probability for both child nodes).

  • 1: attributes all probability to the child node that is compatible with the observed values.

  • 2: computes the probability restricted to the observed entries.

proxy_crit

Character. Default is "both". Criterion used to associate an observation with missing values to a region:

  • "mean": maximizes the difference in means after a split.

  • "var": maximizes the variability between nodes.

  • "both": combines the "mean" and "var" criteria.

n_candidates

Integer. The number of competing candidates to consider when searching for the best split. To select the candidates, a proxy improvement measure is used. Then a full analysis is performed to choose the best among the n_candidates candidates. Higher values increase accuracy but significantly extend computation time due to the full analysis being performed on more splits. Default is 3.

by_node

Logical. If TRUE, the algorithm selects n_candidates for each node and then makes a full analysis to choose the best among all nodes. Otherwise the n_candidates are selected globally. Default is FALSE.

dist

Character. The distribution to be used in the model. One of "norm" (Gaussian), "lnorm" (log-normal), "t" (Student's t), or "gamma" (Gamma). Default is "norm".

iprint

Integer. Controls the verbosity of the Fortran backend. Default is -1 (silent).

  • iprint < 0: No printing.

  • iprint = 0: Prints basic information.

  • iprint > 0: As for iprint = 0 plus progress reports.

verbose

Logical. If TRUE (default), prints progress and informational messages. If FALSE, suppresses all non-error console output.

...

Extra parameters to be passed to the chosen distribution.

  • "norm": Uses the standard Gaussian distribution. No extra parameters required.

  • "lnorm": Uses the log-normal distribution with meanlog = 0. Requires sdlog.

  • "t": Uses the t distribution. Requires df.

  • "gamma": Uses the gamma distribution with scale = 1. Requires shape.

Details

Custom grid specification

When a custom grid is provided via sigma_grid, it must follow these rules:

  • A single number is expanded to a constant vector (same value for all features).

  • A numeric vector of length p (the number of features) is used directly as one candidate vector.

  • A k \times p numeric matrix provides k candidates, one per row.

In all custom grid cases, the automatic grid parameters (grid_size, min_mult, max_mult, tiny_sigma) are ignored.

Automatic grid generation

The automatic grid is generated as follows:

  • For each feature j, the base values are the empirical standard deviations \hat\sigma_j from the training data.

  • If grid_size = 1, the grid consists solely of these base values \hat{\boldsymbol\sigma}.

  • If grid_size > 1, the grid is constructed using grid_size multipliers equally spaced in the interval:

    • ⁠(min_mult, max_mult]⁠ when min_mult = 0 (excludes 0, includes max_mult).

    • ⁠[min_mult, max_mult]⁠ when min_mult > 0 (both inclusive).

    Each multiplier m generates a candidate vector m \times \hat{\boldsymbol\sigma}.

  • If tiny_sigma is provided, it is added as an extra candidate (first row) with \boldsymbol\sigma = \text{tiny\_sigma} \cdot \boldsymbol{1}_p, where \boldsymbol{1}_p is a vector of ones of length p (the number of features). This results in a final grid of size grid_size + 1.

Splitting Constraints and Numerical Stability

The parameters prop_x and p_min work together to control the splitting process. A splitting attempt is made in a given region only when at least a proportion prop_x of the training rows have a probability greater than p_min in that region's column of the probability matrix P. The split will be ignored if any of the resulting child regions do not meet this same criterion.

Warning: Setting either parameter to zero may lead to near-zero columns in P, making the matrix computationally singular or ill-conditioned for inversion.

Data Splitting Strategy The package uses a flexible data splitting strategy controlled by the prop_hold and idx_train arguments:

  • Automatic Split (idx_train = NULL): The training indices are computed automatically based on prop_hold. The split uses stratified sampling to ensure that the proportion of observations with missing values is preserved across the training and validation/test sets.

  • Manual Split (idx_train provided): The supplied indices are used directly, and prop_hold is ignored. The vector must be a valid subset of 1:nrow(X). This approach is useful for reusing specific splits from previous analyses, performing custom cross-validation, or ensuring identical training sets across different models.

Role of the Hold-out Set When prop_hold > 0 and idx_train is NULL, the exact role of the held-out data depends on the grid search parameters (sigma_grid or grid_size):

  • Multiple candidates (grid_size > 1): The hold-out data acts as a validation set to select the best \boldsymbol\sigma. If prop_hold = 0, the selection is based on the in-sample MSE of the training data.

  • Single candidate (grid_size = 1): The hold-out data acts as a test set to evaluate the final model. If prop_hold = 0, the entire dataset is used for training without an independent test evaluation.

Value

A list of class prtree.control containing the validated control parameters.

Examples

# Get default control parameters
controls <- pr_tree_control()

# Customize some parameters
ctrl1 <- pr_tree_control(max_depth = 5, n_candidates = 5)

# equivalent calls
ctrl2.v1 <- pr_tree_control(dist = "t", df = 4)
ctrl2.v2 <- pr_tree_control(dist = "t", dist_pars = list(df = 4))


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