likelihood_function: Evaluate a Parameter Set with Cross-Validation

View source: R/adaptive_sampling.R

likelihood_functionR Documentation

Evaluate a Parameter Set with Cross-Validation

Description

This internal function calculates the cross-validated likelihood for a given set of parameters. It splits the data into training and validation sets across multiple folds, fits the topolow model on each training set, and evaluates the error on the corresponding validation set.

Usage

likelihood_function(
  dissimilarity_matrix,
  mapping_max_iter,
  relative_epsilon,
  N,
  k0,
  cooling_rate,
  c_repulsion,
  folds = 20,
  num_cores = 1
)

Arguments

dissimilarity_matrix

The input dissimilarity matrix to fit.

mapping_max_iter

The maximum number of optimization iterations.

relative_epsilon

The convergence threshold for optimization.

N

The number of dimensions for the embedding.

k0

The initial spring constant.

cooling_rate

The spring constant decay rate.

c_repulsion

The repulsion constant.

folds

The number of cross-validation folds.

num_cores

The number of cores for parallel processing.

Details

To calculate a single Negative Log-Likelihood (NLL) value per parameter set, the function uses a "pooled errors" approach. It combines all out-of-sample errors from every fold into a single set before calculating the NLL and the overall Mean Absolute Error (MAE). This method respects the underlying error distribution and correctly accounts for the total number of validation points.

Value

A list containing the pooled Holdout_MAE and the NLL.


topolow documentation built on Aug. 31, 2025, 1:07 a.m.