expand_sigma_grid: Create a grid of sigma vectors for Probabilistic Regression...

View source: R/prtree_grid_expansion.R

expand_sigma_gridR Documentation

Create a grid of sigma vectors for Probabilistic Regression Trees

Description

Creates a grid of candidate \boldsymbol\sigma vectors for use in pr_tree. The grid is generated from the feature standard deviations of X, or using unit scales when X = NULL

Usage

expand_sigma_grid(X = NULL, n_feat = NULL, idx_train = NULL,
  grid_size = 8, min_mult = 0, max_mult = 2, tiny_sigma = NULL,
  verbose = TRUE)

Arguments

X

A numeric vector, matrix or data frame of predictor variables. If NULL, the grid is generated using unit scales (all features = 1.0). In this case, n_feat must be provided.

n_feat

Optional integer. Number of features. Required when X = NULL. Ignored when X is provided.

idx_train

Optional integer vector. Indices of observations to use for computing feature standard deviations. If NULL (default), all observations in X are used. Ignored when X = NULL.

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.

verbose

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

Details

When X is provided, the grid is based on the empirical standard deviations of the features. If a standard deviation for a feature cannot be computed (e.g., due to all missing values or a constant feature), it defaults to 1.0 to ensure the grid generation proceeds without errors.

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.

See Also

pr_tree_control for setting control parameters.

pr_tree_control_cv for cross-validation settings.

pr_tree for fitting a single tree.

pr_tree_cv for cross-validation.

Examples


# With actual data, default range (0, 2]
X <- matrix(runif(100 * 3, 0, 10), ncol = 3)
grid1 <- expand_sigma_grid(X, grid_size = 8)

# Custom range with min_mult > 0 (includes min_mult)
grid2 <- expand_sigma_grid(X, grid_size = 8, min_mult = 0.5, max_mult = 3)

# Without data (unit scales)
grid3 <- expand_sigma_grid(n_feat = 3, grid_size = 8)

# Only tiny sigma
grid4 <- expand_sigma_grid(n_feat = 3, grid_size = 0, tiny_sigma = 1e-20)



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