Statistics

Statistics

The namespace for all UF/Statistics utility functions, typically for static methods.

Source:

Methods

(static) _computeXT_X(arg0_X) → {Array.<Array.<number>>}

Computes the X^T * X matrix manually to save memory.

Source:
Parameters:
Name Type Description
arg0_X Array.<Array.<number>>
Returns:
Type:
Array.<Array.<number>>

(static) argmaxMultinomialClass(arg0_probabilities, arg1_classes) → {any}

Returns the class label with the highest probability.

Source:
Parameters:
Name Type Description
arg0_probabilities Object

Map of class labels to probabilities.

arg1_classes Array
Returns:
Type:
any

(static) computeMultinomialLogits(arg0_row_X, arg1_beta) → {Array.<number>}

Computes logits for a single sample against a CxK coefficient matrix. Row 0 of beta is assumed to be the zeroed reference class.

Source:
Parameters:
Name Type Description
arg0_row_X Array.<number>
arg1_beta Array.<Array.<number>>
Returns:
Type:
Array.<number>

(static) computeMultinomialStandardErrors(arg0_X, arg1_Y, arg2_result, arg3_lambdaopt) → {Object}

Computes approximate per-class standard errors from the Hessian at convergence. Uses the standard class-vs-rest approximation H_c = Σ p_ic(1-p_ic) x_i x_i^T + λI.

Source:
Parameters:
Name Type Attributes Default Description
arg0_X Array.<Array.<number>>
arg1_Y Array.<Array.<number>>
arg2_result Object

Result object from Statistics.multinomialLogitRegression.

arg3_lambda number <optional>
1e-3
Returns:
Type:
Object
  • Map of class labels to arrays of standard errors.

(static) computeVIF(arg0_X) → {Array.<number>}

Computes the VIF of a given matrix.

Source:
Parameters:
Name Type Description
arg0_X Matrix | Array
Returns:
Type:
Array.<number>

(static) conditionNumber(arg0_X, arg1_epsilonopt) → {number}

Returns the condition number of a given matrix.

Source:
Parameters:
Name Type Attributes Default Description
arg0_X Matrix | Array
arg1_epsilon number <optional>
1e-12
Returns:
Type:
number

(static) coupleAgeSexCohorts(arg0_male_rates, arg1_female_rates, arg2_band_widths, arg3_start_indexopt, arg4_optionsopt) → {Object}

Smooths age cohorts and couples sex ratios simultaneously. Enforces non-increasing monotonicity along the age dimension using weighted PAVA on total cohort population density, then allocates totals between male and female using the model's empirical sex ratio bounded within a biological plausibility envelope (Option 1).

Source:
Parameters:
Name Type Attributes Default Description
arg0_male_rates Float32Array | Array.<number>

Raw male cohort values.

arg1_female_rates Float32Array | Array.<number>

Raw female cohort values.

arg2_band_widths Float32Array | Array.<number>

Cohort duration in years (e.g. 1 for 00, 4 for 01, 5 for others).

arg3_start_index number <optional>
0

Index from which to enforce age monotonicity (defaults to 0 on annualised density).

arg4_options Object <optional>
Name Type Attributes Default Description
baseline_sex_ratios Float32Array | Array.<number> <optional>

Optional target sex-ratio curve M/F by cohort.

sex_ratio_bounds Array.<Array.<number>> <optional>

Optional min/max sex-ratio bounds by cohort.

enforce_fixed_sex_ratios boolean <optional>
false

If true, strictly forces M/F = baseline_sex_ratios.

buffers Object <optional>

Optional pre-allocated flat buffers for zero GC overhead.

female_output Float32Array <optional>

Optional target female output buffer.

male_output Float32Array <optional>

Optional target male output buffer.

total_output Float32Array <optional>

Optional target total output buffer.

Returns:
Type:
Object

Coupled smoothed cohort arrays.

(static) coupleAgeSexCohortsWhittaker(arg0_male_rates, arg1_female_rates, arg2_band_widthsopt, arg3_start_indexopt, arg4_optionsopt) → {Object}

Graduates total age-cohort density and reallocates it between sexes.

Defaults are appropriate for stochastic model-generated compositions: raw sex ratios are preserved, monotonicity is disabled, and the total population of the graduated suffix is preserved by final rescaling.

Density is normalised by the mean density of the graduated suffix. huber_delta is therefore expressed relative to that mean.

Fidelity weights default to band widths. These are integration weights, not estimated inverse-variance weights for a multinomial model.

Sex-ratio allocation applies to every cohort, including the prefix. Density graduation and total rescaling apply only from start_index.

Legacy options.buffers is not used; working calculations use Float64Array.

Source:
Parameters:
Name Type Attributes Default Description
arg0_male_rates Float32Array | Float64Array | Array.<number>
arg1_female_rates Float32Array | Float64Array | Array.<number>
arg2_band_widths Float32Array | Float64Array | Array.<number> <optional>
arg3_start_index number | null <optional>
2

Negative or null disables graduation.

arg4_options Object <optional>
Name Type Attributes Default Description
baseline_sex_ratios Array.<number> | Float32Array | Float64Array <optional>
do_not_smooth boolean <optional>
false
enforce_biological_sex_ratios boolean <optional>
false

Legacy name for applying supplied bounds.

enforce_fixed_sex_ratios boolean <optional>
false
female_output Float32Array | Float64Array <optional>
huber_delta number <optional>
0.05
lambda number <optional>
20.0
male_output Float32Array | Float64Array <optional>
max_iterations number <optional>
20000
mu number <optional>
0.0
preserve_sex_ratios boolean <optional>

Defaults to true unless another ratio policy is enabled.

preserve_total boolean <optional>
true
sex_ratio_bounds Array.<Array.<number>> <optional>
tolerance number <optional>
1e-8
total_output Float32Array | Float64Array <optional>
weights Array.<number> | Float32Array | Float64Array <optional>
Returns:
Type:
Object

(static) evaluateMultinomialModel(arg0_model, arg1_covariates_obj) → {Object}

Evaluates a trained multinomial logit model against a covariates object, returning overall accuracy and a confusion matrix.

Source:
Parameters:
Name Type Description
arg0_model string | Object

JSON model object or file path to JSON model.

arg1_covariates_obj Object

{ keys, X, Y }

Returns:
Type:
Object
  • { accuracy, confusion_matrix, sample_count }

(static) generateALRRaster(arg0_output_file_path, arg1_optionsopt) → {Promise.<void>}

Generates multi-class probability rasters from a trained ALR compositional model.

Source:
Parameters:
Name Type Attributes Description
arg0_output_file_path string

Output file path prefix or base name.

arg1_options Object <optional>
Name Type Attributes Default Description
covariates_obj Object
model_obj Object | string
height number <optional>
2160
width number <optional>
4320
Returns:
Type:
Promise.<void>

(static) generateMultinomialRaster(arg0_output_file_path, arg1_optionsopt) → {Promise.<void>}

Generates raster predictions from a trained multinomial logit model. Supports argmax class maps, single-class probability surfaces, or one probability raster per class.

Source:
Parameters:
Name Type Attributes Description
arg0_output_file_path string
arg1_options Object <optional>
Name Type Attributes Default Description
class number | string <optional>

Class label for "probability" output_mode.

covariates_obj Object
format string <optional>
"int32"
formatting_parameters Array <optional>
guard_clause function <optional>

(local_index:number, rasters_obj:Object) - false skips pixel processing.

model_obj Object | string <optional>

File path or JSON object.

output_mode string <optional>
"class"

"class" | "probability" | "probabilities".

height number <optional>
2160
width number <optional>
4320
Returns:
Type:
Promise.<void>

(static) generateMultinomialRastersParallel(arg0_items, arg1_task_generator, arg2_optionsopt) → {Promise.<Array.<Object>>}

Concurrently generates a series of Multinomial Logit predicted rasters across background worker processes.

Source:
Parameters:
Name Type Attributes Description
arg0_items Array.<any>

Array of years, models, or tasks to generate.

arg1_task_generator function

(local_item: any, local_index: number) => { output_file_path, model_obj, covariates_map, options }

arg2_options Object <optional>
Name Type Attributes Default Description
concurrency number <optional>
name string <optional>
"Multinomial Logit Raster Generation"
Returns:
Type:
Promise.<Array.<Object>>

(static) generateOLSRaster(arg0_output_file_path, arg1_optionsopt) → {Promise.<void>}

Generates an OLS raster from a stack of coefficients.

Source:
Parameters:
Name Type Attributes Description
arg0_output_file_path string
arg1_options Object <optional>
Name Type Attributes Default Description
covariates_obj Object
format string <optional>
"int32"
formatting_parameters Array <optional>
guard_clause function <optional>

(local_index:number, rasters_obj:Object) - false skips pixel processing.

model_obj Object | string <optional>

File path or JSON object.

utility_format string <optional>
"int32"
height number <optional>
2160
width number <optional>
4320
Returns:
Type:
Promise.<void>

(static) generateOLSRastersParallel(arg0_items, arg1_task_generator, arg2_optionsopt) → {Promise.<Array.<Object>>}

Concurrently generates a series of OLS predicted rasters across background worker processes.

Source:
Parameters:
Name Type Attributes Description
arg0_items Array.<any>

Array of years, models, or tasks to generate.

arg1_task_generator function

(local_item: any, local_index: number) => { output_file_path, model_obj, covariates_map, options }

arg2_options Object <optional>
Name Type Attributes Default Description
concurrency number <optional>
name string <optional>
"OLS Raster Generation"
Returns:
Type:
Promise.<Array.<Object>>

(static) geomeanOLSModels(arg0_input_folder_path, arg1_ols_prefix, arg2_optionsopt) → {Promise.<{coefficients: {}, raw_coefficients: {}}>}

Geometrically average OLS models across a folder path, with base OLS prefixes.

Source:
Parameters:
Name Type Attributes Description
arg0_input_folder_path string
arg1_ols_prefix string
arg2_options Object <optional>
Name Type Attributes Description
weighting_function function <optional>

(arg0_coefficient:number) | number

Returns:
Type:
Promise.<{coefficients: {}, raw_coefficients: {}}>

(static) getClassLabel(arg0_Y, arg1_index) → {any}

Returns the class label at a given index of Y, unwrapping single-element arrays.

Source:
Parameters:
Name Type Description
arg0_Y Array
arg1_index number
Returns:
Type:
any

(static) getLogisticKernelWeight(arg0_value, arg1_start_valopt, arg2_end_valopt, arg3_optionsopt) → {number}

Computes a normalised logistic transition kernel weight w in [0, 1] over a domain [start_val, end_val]. Returns 0 for values <= start_val, 1 for values >= end_val, and an S-curve blend for intermediate values.

Source:
Parameters:
Name Type Attributes Default Description
arg0_value number
arg1_start_val number <optional>
1750
arg2_end_val number <optional>
1850
arg3_options Object <optional>
Name Type Attributes Default Description
steepness number <optional>
8
Returns:
Type:
number

(static) loadCovariateRasters(arg0_covariates_obj, arg1_optionsopt) → {Object}

Loads a set of covariate rasters, resolving function- or string-valued paths and dropping rasters that fail to load. Shared by all covariate-stacking routines.

Source:
Parameters:
Name Type Attributes Description
arg0_covariates_obj Object
arg1_options Object <optional>
Name Type Attributes Default Description
data_only boolean <optional>
false

Store .data arrays instead of rasters.

formatting_parameters Array <optional>
[]

Spread into function-valued covariates.

year number <optional>

If set, function-valued covariates receive this single argument instead.

Returns:
Type:
Object
  • { rasters_obj, valid_keys }

(static) loadMultinomialCovariates(arg0_class_file_path, arg1_optionsopt) → {Promise.<Object>}

Loads a stack of covariates for a categorical class raster for multinomial logit training. Unlike loadOLSCovariates, zero-valued class labels are meaningful and retained.

Source:
Parameters:
Name Type Attributes Description
arg0_class_file_path string

Raster whose pixel values are integer class labels.

arg1_options Object <optional>
Name Type Attributes Default Description
covariates_obj Object
class_format string <optional>
"int32"
formatting_parameters Array.<any> <optional>
nodata_value number <optional>

Class label treated as nodata and dropped.

Returns:
Type:
Promise.<Object>
  • { keys, X, Y }

(static) loadOLSCovariates(arg0_utility_file_path, arg1_optionsopt) → {Promise.<Object>}

Loads a stack of covariates for a specific utility file path for OLS training.

Source:
Parameters:
Name Type Attributes Description
arg0_utility_file_path string
arg1_options Object <optional>
Name Type Attributes Default Description
covariates_obj Object
formatting_parameters Array.<any> <optional>
utility_format string <optional>
"int32"
Returns:
Type:
Promise.<Object>

(static) loadPointMultinomialCovariates(arg0_points, arg1_year, arg2_optionsopt) → {Promise.<Object>}

Loads a stack of covariates for point-based categorical data (e.g. household survey age/sex buckets) for multinomial logit training for a specific year.

Source:
Parameters:
Name Type Attributes Description
arg0_points Array.<Object>

Array of objects with { coords: [lng, lat], target: number, year: number }

arg1_year number

The target year to load covariates and sample points for.

arg2_options Object <optional>
Name Type Attributes Description
covariates_obj Object
covariates_year number <optional>

Mapped year to override path resolution.

get_pixel_function function <optional>

Custom coordinate-to-pixel mapping function.

Returns:
Type:
Promise.<Object>
  • { keys, X, Y }

(static) loadPointOLSCovariates(arg0_points, arg1_year, arg2_optionsopt) → {Promise.<Object>}

Loads a stack of covariates for point-based data for OLS training for a specific year.

Source:
Parameters:
Name Type Attributes Description
arg0_points Array.<Object>

Array of objects with { coords: [lng, lat], target: number, year: number }

arg1_year number

The target year to load covariates and sample points for.

arg2_options Object <optional>
Name Type Attributes Description
covariates_obj Object
covariates_year number <optional>

Mapped year to override path resolution.

get_pixel_function function <optional>

Custom coordinate-to-pixel mapping function.

Returns:
Type:
Promise.<Object>

(static) multinomialLogitRegression(arg0_X, arg1_Y, arg2_optionsopt) → {Object|null}

Performs L2-regularised Multinomial Logistic Regression (softmax regression) via batch gradient descent with momentum. The first observed class is the reference class with coefficients fixed at zero for identifiability.

Source:
Parameters:
Name Type Attributes Description
arg0_X Matrix | Array
arg1_Y Matrix | Array

Nx1 matrix of integer class labels.

arg2_options Object <optional>
Name Type Attributes Default Description
debug boolean <optional>
false
lambda number <optional>
1e-3

L2 regularisation strength (ridge analogue).

learning_rate number <optional>
0.5
max_iterations number <optional>
1000
momentum number <optional>
0.9
sample_weights Array.<number> <optional>

Non-negative observation weights.

tolerance number <optional>
1e-8
Returns:
Type:
Object | null
  • { beta, classes, converged, iterations, log_likelihood }

(static) pavaDecreasing(arg0_values, arg1_weightsopt, arg2_start_indexopt, arg3_optionsopt) → {Float32Array|Array.<number>}

Enforces non-increasing monotonicity on a sequence using the weighted Pool Adjacent Violators Algorithm (PAVA). Values before arg2_start_index are preserved unconstrained.

Source:
Parameters:
Name Type Attributes Default Description
arg0_values Float32Array | Array.<number>

Array of values to smooth.

arg1_weights Float32Array | Array.<number> <optional>

Optional weights (e.g. cohort band widths).

arg2_start_index number <optional>
0

Index from which to enforce non-increasing monotonicity.

arg3_options Object <optional>
Name Type Attributes Description
buffers Object <optional>

Optional pre-allocated flat buffers for zero GC overhead.

Name Type Attributes Description
block_vals Float32Array <optional>
block_weights Float32Array <optional>
block_counts Int32Array <optional>
output Float32Array | Array.<number> <optional>

Optional target output buffer.

Returns:
Type:
Float32Array | Array.<number>

Monotonically decreasing output array.

(static) predictALRProbabilities(arg0_features_obj, arg1_model_obj) → {Object}

Computes predicted compositional class probabilities for a single feature object using a trained ALR model.

Source:
Parameters:
Name Type Description
arg0_features_obj Object

Feature mapping.

arg1_model_obj Object

Trained ALR model object with .categories, .reference_category, and .coefficients.

Returns:
Type:
Object

Mapping of category names to probabilities summing to 1.0.

(static) predictMultinomialEnsemble(arg0_features_obj, arg1_models, arg2_weightsopt) → {Object}

Predicts class probabilities from an ensemble of models using a convex combination in probability space.

Source:
Parameters:
Name Type Attributes Description
arg0_features_obj Object

Map of covariate keys to feature values.

arg1_models Array.<(Object|string)>

Array of model objects or file paths.

arg2_weights Array.<number> <optional>

Optional array of model weights.

Returns:
Type:
Object
  • Map of class labels to blended probabilities.

(static) predictMultinomialProbabilities(arg0_features_obj, arg1_model_obj) → {Object}

Predicts class probabilities for a single feature object against a trained multinomial logit model. Supports both discrete multinomial_logit models and probability-space multinomial_ensemble mixtures.

Source:
Parameters:
Name Type Description
arg0_features_obj Object

Map of covariate keys to feature values.

arg1_model_obj Object

Trained model object with .classes and .coefficients.

Returns:
Type:
Object
  • Map of class labels to probabilities.

(static) processOLSModel(arg0_model, arg1_optionsopt) → {Promise.<Object>}

Processes and adjusts OLS model coefficients against target and covariate rasters using Multiplicative Update Rules (NMF).

Source:
Parameters:
Name Type Attributes Description
arg0_model string | Object

JSON model object or file path to JSON model.

arg1_options Object <optional>
Name Type Attributes Default Description
covariates_obj Object <optional>

Map of covariate keys to functions or file paths.

debug boolean <optional>
false
output_file_path string <optional>

Path to save the adjusted model JSON.

steps Array.<any> | any <optional>

Array of steps or parameter sets (e.g., years) passed into target and covariate functions.

target string | function <optional>

File path or function returning file path for target raster.

target_format string <optional>
"float32"
Returns:
Type:
Promise.<Object>

(static) removeHighVIFFeatures(arg0_X, arg1_thresholdopt) → {Array.<Array.<number>>}

Removes high VIF features for a given matrix.

Source:
Parameters:
Name Type Attributes Default Description
arg0_X Matrix | Array
arg1_threshold number <optional>
10
Returns:
Type:
Array.<Array.<number>>

(static) ridgeRegression(arg0_X, arg1_Y, arg2_lambdaopt) → {Matrix|Array}

Performs Ridge Regression on two matrices with RMS scale stabilization and pseudo-inverse fallbacks.

Source:
Parameters:
Name Type Attributes Default Description
arg0_X Matrix | Array
arg1_Y Matrix | Array
arg2_lambda number <optional>
1e-3
Returns:
Type:
Matrix | Array

(static) softmax(arg0_logits) → {Array.<number>}

Computes a numerically-stable softmax over an array of logits.

Source:
Parameters:
Name Type Description
arg0_logits Array.<number>
Returns:
Type:
Array.<number>

(static) trainALRModel(arg0_output_file_path, arg1_covariates_obj, arg2_optionsopt) → {Promise.<(Object|null)>}

Trains an Additive Log-Ratio (ALR) regularised ridge regression model for continuous compositional targets. Bypasses gradient descent under-convergence by solving normal equations analytically.

Source:
Parameters:
Name Type Attributes Description
arg0_output_file_path string

File path to save the trained model.

arg1_covariates_obj Object

{ keys, X, Y, categories, [reference_category] }

arg2_options Object <optional>
Name Type Attributes Default Description
key string <optional>
lambda number <optional>
1e-3

Ridge penalty strength.

smoothing number <optional>
1e-6

Log-ratio epsilon smoothing.

Returns:
Type:
Promise.<(Object|null)>

(static) trainMultinomialLogitModel(arg0_output_file_path, arg1_covariates_obj, arg2_optionsopt) → {Promise.<(Object|null)>}

Trains a multinomial logit model given a fitted covariates object { X, Y, keys } and saves it to JSON. Coefficients are stored per non-reference class.

Source:
Parameters:
Name Type Attributes Description
arg0_output_file_path string
arg1_covariates_obj Object

{ keys, X, Y }

arg2_options Object <optional>
Name Type Attributes Default Description
compute_standard_errors boolean <optional>
false

Hessian-based uncertainty.

debug boolean <optional>
false
key string <optional>
lambda number <optional>
1e-3
learning_rate number <optional>
0.5
max_iterations number <optional>
1000
momentum number <optional>
0.9
tolerance number <optional>
1e-8
Returns:
Type:
Promise.<(Object|null)>

(static) trainMultinomialLogitModelsParallel(arg0_items, arg1_task_generator, arg2_optionsopt) → {Promise.<Array.<Object>>}

Concurrently trains a series of multinomial logit models across background worker processes.

Source:
Parameters:
Name Type Attributes Description
arg0_items Array.<any>

Array of tasks, years, or cohort descriptors.

arg1_task_generator function

(local_item: any, local_index: number) => { categories, covariates_map, filter_format, filter_raster_path, model_path, options, target_paths }

arg2_options Object <optional>
Name Type Attributes Default Description
concurrency number <optional>

Worker thread count.

name string <optional>
"Multinomial Logit Training"
Returns:
Type:
Promise.<Array.<Object>>

(static) trainOLSModel(arg0_output_file_path, arg1_covariates_obj, arg2_optionsopt) → {Promise.<Object>}

Trains a raster-based OLS model given a fitted covariates object { X, Y, keys }.

Source:
Parameters:
Name Type Attributes Description
arg0_output_file_path string
arg1_covariates_obj Object
arg2_options Object <optional>
Name Type Attributes Default Description
dynamic_lambda boolean <optional>
false

Condition numbers are dynamically selected if true.

lambda number <optional>
1e9
remove_high_vif_features boolean <optional>
false

Whether to remove high VIF features.

key string <optional>
weighting_function function <optional>

(arg0_coefficient:number) | number

Returns:
Type:
Promise.<Object>

(static) trainOLSModelsParallel(arg0_items, arg1_task_generator, arg2_optionsopt) → {Promise.<Array.<Object>>}

Concurrently trains a series of OLS models across background worker processes.

Source:
Parameters:
Name Type Attributes Description
arg0_items Array.<any>

Array of years, models, or tasks to train.

arg1_task_generator function

(local_item: any, local_index: number) => { output_file_path, target_file_path, target_format, covariates_map, options, points, target_year }

arg2_options Object <optional>
Name Type Attributes Default Description
concurrency number <optional>

Worker thread count.

name string <optional>
"OLS Model Training"
Returns:
Type:
Promise.<Array.<Object>>

(static) whittakerHendersonRobust(arg0_values, arg1_weightsopt, arg2_start_indexopt, arg3_optionsopt) → {Float32Array|Float64Array}

Performs Whittaker-Henderson graduation with weighted Huber fidelity, second-difference roughness, and optional soft non-increasing monotonicity.

Penalties apply only within [start_index, values.length). Values before start_index are copied without modification.

Source:
Parameters:
Name Type Attributes Default Description
arg0_values Float32Array | Float64Array | Array.<number>
arg1_weights Float32Array | Float64Array | Array.<number> <optional>
arg2_start_index number <optional>
0
arg3_options Object <optional>
Name Type Attributes Default Description
output Float32Array | Float64Array <optional>
huber_delta number <optional>
0.05
lambda number <optional>
20.0
max_iterations number <optional>
20000
min_value number <optional>
-Infinity
mu number <optional>
0.0
tolerance number <optional>
1e-8

Absolute KKT residual tolerance.

Returns:
Type:
Float32Array | Float64Array

Statistics

The namespace for all UF/Statistics utility functions, typically for static methods.

Source:

Methods

(static) _computeXT_X(arg0_X) → {Array.<Array.<number>>}

Computes the X^T * X matrix manually to save memory.

Source:
Parameters:
Name Type Description
arg0_X Array.<Array.<number>>
Returns:
Type:
Array.<Array.<number>>

(static) argmaxMultinomialClass(arg0_probabilities, arg1_classes) → {any}

Returns the class label with the highest probability.

Source:
Parameters:
Name Type Description
arg0_probabilities Object

Map of class labels to probabilities.

arg1_classes Array
Returns:
Type:
any

(static) computeMultinomialLogits(arg0_row_X, arg1_beta) → {Array.<number>}

Computes logits for a single sample against a CxK coefficient matrix. Row 0 of beta is assumed to be the zeroed reference class.

Source:
Parameters:
Name Type Description
arg0_row_X Array.<number>
arg1_beta Array.<Array.<number>>
Returns:
Type:
Array.<number>

(static) computeMultinomialStandardErrors(arg0_X, arg1_Y, arg2_result, arg3_lambdaopt) → {Object}

Computes approximate per-class standard errors from the Hessian at convergence. Uses the standard class-vs-rest approximation H_c = Σ p_ic(1-p_ic) x_i x_i^T + λI.

Source:
Parameters:
Name Type Attributes Default Description
arg0_X Array.<Array.<number>>
arg1_Y Array.<Array.<number>>
arg2_result Object

Result object from Statistics.multinomialLogitRegression.

arg3_lambda number <optional>
1e-3
Returns:
Type:
Object
  • Map of class labels to arrays of standard errors.

(static) computeVIF(arg0_X) → {Array.<number>}

Computes the VIF of a given matrix.

Source:
Parameters:
Name Type Description
arg0_X Matrix | Array
Returns:
Type:
Array.<number>

(static) conditionNumber(arg0_X, arg1_epsilonopt) → {number}

Returns the condition number of a given matrix.

Source:
Parameters:
Name Type Attributes Default Description
arg0_X Matrix | Array
arg1_epsilon number <optional>
1e-12
Returns:
Type:
number

(static) coupleAgeSexCohorts(arg0_male_rates, arg1_female_rates, arg2_band_widths, arg3_start_indexopt, arg4_optionsopt) → {Object}

Smooths age cohorts and couples sex ratios simultaneously. Enforces non-increasing monotonicity along the age dimension using weighted PAVA on total cohort population density, then allocates totals between male and female using the model's empirical sex ratio bounded within a biological plausibility envelope (Option 1).

Source:
Parameters:
Name Type Attributes Default Description
arg0_male_rates Float32Array | Array.<number>

Raw male cohort values.

arg1_female_rates Float32Array | Array.<number>

Raw female cohort values.

arg2_band_widths Float32Array | Array.<number>

Cohort duration in years (e.g. 1 for 00, 4 for 01, 5 for others).

arg3_start_index number <optional>
0

Index from which to enforce age monotonicity (defaults to 0 on annualised density).

arg4_options Object <optional>
Name Type Attributes Default Description
baseline_sex_ratios Float32Array | Array.<number> <optional>

Optional target sex-ratio curve M/F by cohort.

sex_ratio_bounds Array.<Array.<number>> <optional>

Optional min/max sex-ratio bounds by cohort.

enforce_fixed_sex_ratios boolean <optional>
false

If true, strictly forces M/F = baseline_sex_ratios.

buffers Object <optional>

Optional pre-allocated flat buffers for zero GC overhead.

female_output Float32Array <optional>

Optional target female output buffer.

male_output Float32Array <optional>

Optional target male output buffer.

total_output Float32Array <optional>

Optional target total output buffer.

Returns:
Type:
Object

Coupled smoothed cohort arrays.

(static) coupleAgeSexCohortsWhittaker(arg0_male_rates, arg1_female_rates, arg2_band_widthsopt, arg3_start_indexopt, arg4_optionsopt) → {Object}

Graduates total age-cohort density and reallocates it between sexes.

Defaults are appropriate for stochastic model-generated compositions: raw sex ratios are preserved, monotonicity is disabled, and the total population of the graduated suffix is preserved by final rescaling.

Density is normalised by the mean density of the graduated suffix. huber_delta is therefore expressed relative to that mean.

Fidelity weights default to band widths. These are integration weights, not estimated inverse-variance weights for a multinomial model.

Sex-ratio allocation applies to every cohort, including the prefix. Density graduation and total rescaling apply only from start_index.

Legacy options.buffers is not used; working calculations use Float64Array.

Source:
Parameters:
Name Type Attributes Default Description
arg0_male_rates Float32Array | Float64Array | Array.<number>
arg1_female_rates Float32Array | Float64Array | Array.<number>
arg2_band_widths Float32Array | Float64Array | Array.<number> <optional>
arg3_start_index number | null <optional>
2

Negative or null disables graduation.

arg4_options Object <optional>
Name Type Attributes Default Description
baseline_sex_ratios Array.<number> | Float32Array | Float64Array <optional>
do_not_smooth boolean <optional>
false
enforce_biological_sex_ratios boolean <optional>
false

Legacy name for applying supplied bounds.

enforce_fixed_sex_ratios boolean <optional>
false
female_output Float32Array | Float64Array <optional>
huber_delta number <optional>
0.05
lambda number <optional>
20.0
male_output Float32Array | Float64Array <optional>
max_iterations number <optional>
20000
mu number <optional>
0.0
preserve_sex_ratios boolean <optional>

Defaults to true unless another ratio policy is enabled.

preserve_total boolean <optional>
true
sex_ratio_bounds Array.<Array.<number>> <optional>
tolerance number <optional>
1e-8
total_output Float32Array | Float64Array <optional>
weights Array.<number> | Float32Array | Float64Array <optional>
Returns:
Type:
Object

(static) evaluateMultinomialModel(arg0_model, arg1_covariates_obj) → {Object}

Evaluates a trained multinomial logit model against a covariates object, returning overall accuracy and a confusion matrix.

Source:
Parameters:
Name Type Description
arg0_model string | Object

JSON model object or file path to JSON model.

arg1_covariates_obj Object

{ keys, X, Y }

Returns:
Type:
Object
  • { accuracy, confusion_matrix, sample_count }

(static) generateALRRaster(arg0_output_file_path, arg1_optionsopt) → {Promise.<void>}

Generates multi-class probability rasters from a trained ALR compositional model.

Source:
Parameters:
Name Type Attributes Description
arg0_output_file_path string

Output file path prefix or base name.

arg1_options Object <optional>
Name Type Attributes Default Description
covariates_obj Object
model_obj Object | string
height number <optional>
2160
width number <optional>
4320
Returns:
Type:
Promise.<void>

(static) generateMultinomialRaster(arg0_output_file_path, arg1_optionsopt) → {Promise.<void>}

Generates raster predictions from a trained multinomial logit model. Supports argmax class maps, single-class probability surfaces, or one probability raster per class.

Source:
Parameters:
Name Type Attributes Description
arg0_output_file_path string
arg1_options Object <optional>
Name Type Attributes Default Description
class number | string <optional>

Class label for "probability" output_mode.

covariates_obj Object
format string <optional>
"int32"
formatting_parameters Array <optional>
guard_clause function <optional>

(local_index:number, rasters_obj:Object) - false skips pixel processing.

model_obj Object | string <optional>

File path or JSON object.

output_mode string <optional>
"class"

"class" | "probability" | "probabilities".

height number <optional>
2160
width number <optional>
4320
Returns:
Type:
Promise.<void>

(static) generateMultinomialRastersParallel(arg0_items, arg1_task_generator, arg2_optionsopt) → {Promise.<Array.<Object>>}

Concurrently generates a series of Multinomial Logit predicted rasters across background worker processes.

Source:
Parameters:
Name Type Attributes Description
arg0_items Array.<any>

Array of years, models, or tasks to generate.

arg1_task_generator function

(local_item: any, local_index: number) => { output_file_path, model_obj, covariates_map, options }

arg2_options Object <optional>
Name Type Attributes Default Description
concurrency number <optional>
name string <optional>
"Multinomial Logit Raster Generation"
Returns:
Type:
Promise.<Array.<Object>>

(static) generateOLSRaster(arg0_output_file_path, arg1_optionsopt) → {Promise.<void>}

Generates an OLS raster from a stack of coefficients.

Source:
Parameters:
Name Type Attributes Description
arg0_output_file_path string
arg1_options Object <optional>
Name Type Attributes Default Description
covariates_obj Object
format string <optional>
"int32"
formatting_parameters Array <optional>
guard_clause function <optional>

(local_index:number, rasters_obj:Object) - false skips pixel processing.

model_obj Object | string <optional>

File path or JSON object.

utility_format string <optional>
"int32"
height number <optional>
2160
width number <optional>
4320
Returns:
Type:
Promise.<void>

(static) generateOLSRastersParallel(arg0_items, arg1_task_generator, arg2_optionsopt) → {Promise.<Array.<Object>>}

Concurrently generates a series of OLS predicted rasters across background worker processes.

Source:
Parameters:
Name Type Attributes Description
arg0_items Array.<any>

Array of years, models, or tasks to generate.

arg1_task_generator function

(local_item: any, local_index: number) => { output_file_path, model_obj, covariates_map, options }

arg2_options Object <optional>
Name Type Attributes Default Description
concurrency number <optional>
name string <optional>
"OLS Raster Generation"
Returns:
Type:
Promise.<Array.<Object>>

(static) geomeanOLSModels(arg0_input_folder_path, arg1_ols_prefix, arg2_optionsopt) → {Promise.<{coefficients: {}, raw_coefficients: {}}>}

Geometrically average OLS models across a folder path, with base OLS prefixes.

Source:
Parameters:
Name Type Attributes Description
arg0_input_folder_path string
arg1_ols_prefix string
arg2_options Object <optional>
Name Type Attributes Description
weighting_function function <optional>

(arg0_coefficient:number) | number

Returns:
Type:
Promise.<{coefficients: {}, raw_coefficients: {}}>

(static) getClassLabel(arg0_Y, arg1_index) → {any}

Returns the class label at a given index of Y, unwrapping single-element arrays.

Source:
Parameters:
Name Type Description
arg0_Y Array
arg1_index number
Returns:
Type:
any

(static) getLogisticKernelWeight(arg0_value, arg1_start_valopt, arg2_end_valopt, arg3_optionsopt) → {number}

Computes a normalised logistic transition kernel weight w in [0, 1] over a domain [start_val, end_val]. Returns 0 for values <= start_val, 1 for values >= end_val, and an S-curve blend for intermediate values.

Source:
Parameters:
Name Type Attributes Default Description
arg0_value number
arg1_start_val number <optional>
1750
arg2_end_val number <optional>
1850
arg3_options Object <optional>
Name Type Attributes Default Description
steepness number <optional>
8
Returns:
Type:
number

(static) loadCovariateRasters(arg0_covariates_obj, arg1_optionsopt) → {Object}

Loads a set of covariate rasters, resolving function- or string-valued paths and dropping rasters that fail to load. Shared by all covariate-stacking routines.

Source:
Parameters:
Name Type Attributes Description
arg0_covariates_obj Object
arg1_options Object <optional>
Name Type Attributes Default Description
data_only boolean <optional>
false

Store .data arrays instead of rasters.

formatting_parameters Array <optional>
[]

Spread into function-valued covariates.

year number <optional>

If set, function-valued covariates receive this single argument instead.

Returns:
Type:
Object
  • { rasters_obj, valid_keys }

(static) loadMultinomialCovariates(arg0_class_file_path, arg1_optionsopt) → {Promise.<Object>}

Loads a stack of covariates for a categorical class raster for multinomial logit training. Unlike loadOLSCovariates, zero-valued class labels are meaningful and retained.

Source:
Parameters:
Name Type Attributes Description
arg0_class_file_path string

Raster whose pixel values are integer class labels.

arg1_options Object <optional>
Name Type Attributes Default Description
covariates_obj Object
class_format string <optional>
"int32"
formatting_parameters Array.<any> <optional>
nodata_value number <optional>

Class label treated as nodata and dropped.

Returns:
Type:
Promise.<Object>
  • { keys, X, Y }

(static) loadOLSCovariates(arg0_utility_file_path, arg1_optionsopt) → {Promise.<Object>}

Loads a stack of covariates for a specific utility file path for OLS training.

Source:
Parameters:
Name Type Attributes Description
arg0_utility_file_path string
arg1_options Object <optional>
Name Type Attributes Default Description
covariates_obj Object
formatting_parameters Array.<any> <optional>
utility_format string <optional>
"int32"
Returns:
Type:
Promise.<Object>

(static) loadPointMultinomialCovariates(arg0_points, arg1_year, arg2_optionsopt) → {Promise.<Object>}

Loads a stack of covariates for point-based categorical data (e.g. household survey age/sex buckets) for multinomial logit training for a specific year.

Source:
Parameters:
Name Type Attributes Description
arg0_points Array.<Object>

Array of objects with { coords: [lng, lat], target: number, year: number }

arg1_year number

The target year to load covariates and sample points for.

arg2_options Object <optional>
Name Type Attributes Description
covariates_obj Object
covariates_year number <optional>

Mapped year to override path resolution.

get_pixel_function function <optional>

Custom coordinate-to-pixel mapping function.

Returns:
Type:
Promise.<Object>
  • { keys, X, Y }

(static) loadPointOLSCovariates(arg0_points, arg1_year, arg2_optionsopt) → {Promise.<Object>}

Loads a stack of covariates for point-based data for OLS training for a specific year.

Source:
Parameters:
Name Type Attributes Description
arg0_points Array.<Object>

Array of objects with { coords: [lng, lat], target: number, year: number }

arg1_year number

The target year to load covariates and sample points for.

arg2_options Object <optional>
Name Type Attributes Description
covariates_obj Object
covariates_year number <optional>

Mapped year to override path resolution.

get_pixel_function function <optional>

Custom coordinate-to-pixel mapping function.

Returns:
Type:
Promise.<Object>

(static) multinomialLogitRegression(arg0_X, arg1_Y, arg2_optionsopt) → {Object|null}

Performs L2-regularised Multinomial Logistic Regression (softmax regression) via batch gradient descent with momentum. The first observed class is the reference class with coefficients fixed at zero for identifiability.

Source:
Parameters:
Name Type Attributes Description
arg0_X Matrix | Array
arg1_Y Matrix | Array

Nx1 matrix of integer class labels.

arg2_options Object <optional>
Name Type Attributes Default Description
debug boolean <optional>
false
lambda number <optional>
1e-3

L2 regularisation strength (ridge analogue).

learning_rate number <optional>
0.5
max_iterations number <optional>
1000
momentum number <optional>
0.9
sample_weights Array.<number> <optional>

Non-negative observation weights.

tolerance number <optional>
1e-8
Returns:
Type:
Object | null
  • { beta, classes, converged, iterations, log_likelihood }

(static) pavaDecreasing(arg0_values, arg1_weightsopt, arg2_start_indexopt, arg3_optionsopt) → {Float32Array|Array.<number>}

Enforces non-increasing monotonicity on a sequence using the weighted Pool Adjacent Violators Algorithm (PAVA). Values before arg2_start_index are preserved unconstrained.

Source:
Parameters:
Name Type Attributes Default Description
arg0_values Float32Array | Array.<number>

Array of values to smooth.

arg1_weights Float32Array | Array.<number> <optional>

Optional weights (e.g. cohort band widths).

arg2_start_index number <optional>
0

Index from which to enforce non-increasing monotonicity.

arg3_options Object <optional>
Name Type Attributes Description
buffers Object <optional>

Optional pre-allocated flat buffers for zero GC overhead.

Name Type Attributes Description
block_vals Float32Array <optional>
block_weights Float32Array <optional>
block_counts Int32Array <optional>
output Float32Array | Array.<number> <optional>

Optional target output buffer.

Returns:
Type:
Float32Array | Array.<number>

Monotonically decreasing output array.

(static) predictALRProbabilities(arg0_features_obj, arg1_model_obj) → {Object}

Computes predicted compositional class probabilities for a single feature object using a trained ALR model.

Source:
Parameters:
Name Type Description
arg0_features_obj Object

Feature mapping.

arg1_model_obj Object

Trained ALR model object with .categories, .reference_category, and .coefficients.

Returns:
Type:
Object

Mapping of category names to probabilities summing to 1.0.

(static) predictMultinomialEnsemble(arg0_features_obj, arg1_models, arg2_weightsopt) → {Object}

Predicts class probabilities from an ensemble of models using a convex combination in probability space.

Source:
Parameters:
Name Type Attributes Description
arg0_features_obj Object

Map of covariate keys to feature values.

arg1_models Array.<(Object|string)>

Array of model objects or file paths.

arg2_weights Array.<number> <optional>

Optional array of model weights.

Returns:
Type:
Object
  • Map of class labels to blended probabilities.

(static) predictMultinomialProbabilities(arg0_features_obj, arg1_model_obj) → {Object}

Predicts class probabilities for a single feature object against a trained multinomial logit model. Supports both discrete multinomial_logit models and probability-space multinomial_ensemble mixtures.

Source:
Parameters:
Name Type Description
arg0_features_obj Object

Map of covariate keys to feature values.

arg1_model_obj Object

Trained model object with .classes and .coefficients.

Returns:
Type:
Object
  • Map of class labels to probabilities.

(static) processOLSModel(arg0_model, arg1_optionsopt) → {Promise.<Object>}

Processes and adjusts OLS model coefficients against target and covariate rasters using Multiplicative Update Rules (NMF).

Source:
Parameters:
Name Type Attributes Description
arg0_model string | Object

JSON model object or file path to JSON model.

arg1_options Object <optional>
Name Type Attributes Default Description
covariates_obj Object <optional>

Map of covariate keys to functions or file paths.

debug boolean <optional>
false
output_file_path string <optional>

Path to save the adjusted model JSON.

steps Array.<any> | any <optional>

Array of steps or parameter sets (e.g., years) passed into target and covariate functions.

target string | function <optional>

File path or function returning file path for target raster.

target_format string <optional>
"float32"
Returns:
Type:
Promise.<Object>

(static) removeHighVIFFeatures(arg0_X, arg1_thresholdopt) → {Array.<Array.<number>>}

Removes high VIF features for a given matrix.

Source:
Parameters:
Name Type Attributes Default Description
arg0_X Matrix | Array
arg1_threshold number <optional>
10
Returns:
Type:
Array.<Array.<number>>

(static) ridgeRegression(arg0_X, arg1_Y, arg2_lambdaopt) → {Matrix|Array}

Performs Ridge Regression on two matrices with RMS scale stabilization and pseudo-inverse fallbacks.

Source:
Parameters:
Name Type Attributes Default Description
arg0_X Matrix | Array
arg1_Y Matrix | Array
arg2_lambda number <optional>
1e-3
Returns:
Type:
Matrix | Array

(static) softmax(arg0_logits) → {Array.<number>}

Computes a numerically-stable softmax over an array of logits.

Source:
Parameters:
Name Type Description
arg0_logits Array.<number>
Returns:
Type:
Array.<number>

(static) trainALRModel(arg0_output_file_path, arg1_covariates_obj, arg2_optionsopt) → {Promise.<(Object|null)>}

Trains an Additive Log-Ratio (ALR) regularised ridge regression model for continuous compositional targets. Bypasses gradient descent under-convergence by solving normal equations analytically.

Source:
Parameters:
Name Type Attributes Description
arg0_output_file_path string

File path to save the trained model.

arg1_covariates_obj Object

{ keys, X, Y, categories, [reference_category] }

arg2_options Object <optional>
Name Type Attributes Default Description
key string <optional>
lambda number <optional>
1e-3

Ridge penalty strength.

smoothing number <optional>
1e-6

Log-ratio epsilon smoothing.

Returns:
Type:
Promise.<(Object|null)>

(static) trainMultinomialLogitModel(arg0_output_file_path, arg1_covariates_obj, arg2_optionsopt) → {Promise.<(Object|null)>}

Trains a multinomial logit model given a fitted covariates object { X, Y, keys } and saves it to JSON. Coefficients are stored per non-reference class.

Source:
Parameters:
Name Type Attributes Description
arg0_output_file_path string
arg1_covariates_obj Object

{ keys, X, Y }

arg2_options Object <optional>
Name Type Attributes Default Description
compute_standard_errors boolean <optional>
false

Hessian-based uncertainty.

debug boolean <optional>
false
key string <optional>
lambda number <optional>
1e-3
learning_rate number <optional>
0.5
max_iterations number <optional>
1000
momentum number <optional>
0.9
tolerance number <optional>
1e-8
Returns:
Type:
Promise.<(Object|null)>

(static) trainMultinomialLogitModelsParallel(arg0_items, arg1_task_generator, arg2_optionsopt) → {Promise.<Array.<Object>>}

Concurrently trains a series of multinomial logit models across background worker processes.

Source:
Parameters:
Name Type Attributes Description
arg0_items Array.<any>

Array of tasks, years, or cohort descriptors.

arg1_task_generator function

(local_item: any, local_index: number) => { categories, covariates_map, filter_format, filter_raster_path, model_path, options, target_paths }

arg2_options Object <optional>
Name Type Attributes Default Description
concurrency number <optional>

Worker thread count.

name string <optional>
"Multinomial Logit Training"
Returns:
Type:
Promise.<Array.<Object>>

(static) trainOLSModel(arg0_output_file_path, arg1_covariates_obj, arg2_optionsopt) → {Promise.<Object>}

Trains a raster-based OLS model given a fitted covariates object { X, Y, keys }.

Source:
Parameters:
Name Type Attributes Description
arg0_output_file_path string
arg1_covariates_obj Object
arg2_options Object <optional>
Name Type Attributes Default Description
dynamic_lambda boolean <optional>
false

Condition numbers are dynamically selected if true.

lambda number <optional>
1e9
remove_high_vif_features boolean <optional>
false

Whether to remove high VIF features.

key string <optional>
weighting_function function <optional>

(arg0_coefficient:number) | number

Returns:
Type:
Promise.<Object>

(static) trainOLSModelsParallel(arg0_items, arg1_task_generator, arg2_optionsopt) → {Promise.<Array.<Object>>}

Concurrently trains a series of OLS models across background worker processes.

Source:
Parameters:
Name Type Attributes Description
arg0_items Array.<any>

Array of years, models, or tasks to train.

arg1_task_generator function

(local_item: any, local_index: number) => { output_file_path, target_file_path, target_format, covariates_map, options, points, target_year }

arg2_options Object <optional>
Name Type Attributes Default Description
concurrency number <optional>

Worker thread count.

name string <optional>
"OLS Model Training"
Returns:
Type:
Promise.<Array.<Object>>

(static) whittakerHendersonRobust(arg0_values, arg1_weightsopt, arg2_start_indexopt, arg3_optionsopt) → {Float32Array|Float64Array}

Performs Whittaker-Henderson graduation with weighted Huber fidelity, second-difference roughness, and optional soft non-increasing monotonicity.

Penalties apply only within [start_index, values.length). Values before start_index are copied without modification.

Source:
Parameters:
Name Type Attributes Default Description
arg0_values Float32Array | Float64Array | Array.<number>
arg1_weights Float32Array | Float64Array | Array.<number> <optional>
arg2_start_index number <optional>
0
arg3_options Object <optional>
Name Type Attributes Default Description
output Float32Array | Float64Array <optional>
huber_delta number <optional>
0.05
lambda number <optional>
20.0
max_iterations number <optional>
20000
min_value number <optional>
-Infinity
mu number <optional>
0.0
tolerance number <optional>
1e-8

Absolute KKT residual tolerance.

Returns:
Type:
Float32Array | Float64Array

Statistics

The namespace for all UF/Statistics utility functions, typically for static methods.

Source:

Methods

(static) _computeXT_X(arg0_X) → {Array.<Array.<number>>}

Computes the X^T * X matrix manually to save memory.

Source:
Parameters:
Name Type Description
arg0_X Array.<Array.<number>>
Returns:
Type:
Array.<Array.<number>>

(static) argmaxMultinomialClass(arg0_probabilities, arg1_classes) → {any}

Returns the class label with the highest probability.

Source:
Parameters:
Name Type Description
arg0_probabilities Object

Map of class labels to probabilities.

arg1_classes Array
Returns:
Type:
any

(static) computeMultinomialLogits(arg0_row_X, arg1_beta) → {Array.<number>}

Computes logits for a single sample against a CxK coefficient matrix. Row 0 of beta is assumed to be the zeroed reference class.

Source:
Parameters:
Name Type Description
arg0_row_X Array.<number>
arg1_beta Array.<Array.<number>>
Returns:
Type:
Array.<number>

(static) computeMultinomialStandardErrors(arg0_X, arg1_Y, arg2_result, arg3_lambdaopt) → {Object}

Computes approximate per-class standard errors from the Hessian at convergence. Uses the standard class-vs-rest approximation H_c = Σ p_ic(1-p_ic) x_i x_i^T + λI.

Source:
Parameters:
Name Type Attributes Default Description
arg0_X Array.<Array.<number>>
arg1_Y Array.<Array.<number>>
arg2_result Object

Result object from Statistics.multinomialLogitRegression.

arg3_lambda number <optional>
1e-3
Returns:
Type:
Object
  • Map of class labels to arrays of standard errors.

(static) computeVIF(arg0_X) → {Array.<number>}

Computes the VIF of a given matrix.

Source:
Parameters:
Name Type Description
arg0_X Matrix | Array
Returns:
Type:
Array.<number>

(static) conditionNumber(arg0_X, arg1_epsilonopt) → {number}

Returns the condition number of a given matrix.

Source:
Parameters:
Name Type Attributes Default Description
arg0_X Matrix | Array
arg1_epsilon number <optional>
1e-12
Returns:
Type:
number

(static) coupleAgeSexCohorts(arg0_male_rates, arg1_female_rates, arg2_band_widths, arg3_start_indexopt, arg4_optionsopt) → {Object}

Smooths age cohorts and couples sex ratios simultaneously. Enforces non-increasing monotonicity along the age dimension using weighted PAVA on total cohort population density, then allocates totals between male and female using the model's empirical sex ratio bounded within a biological plausibility envelope (Option 1).

Source:
Parameters:
Name Type Attributes Default Description
arg0_male_rates Float32Array | Array.<number>

Raw male cohort values.

arg1_female_rates Float32Array | Array.<number>

Raw female cohort values.

arg2_band_widths Float32Array | Array.<number>

Cohort duration in years (e.g. 1 for 00, 4 for 01, 5 for others).

arg3_start_index number <optional>
0

Index from which to enforce age monotonicity (defaults to 0 on annualised density).

arg4_options Object <optional>
Name Type Attributes Default Description
baseline_sex_ratios Float32Array | Array.<number> <optional>

Optional target sex-ratio curve M/F by cohort.

sex_ratio_bounds Array.<Array.<number>> <optional>

Optional min/max sex-ratio bounds by cohort.

enforce_fixed_sex_ratios boolean <optional>
false

If true, strictly forces M/F = baseline_sex_ratios.

buffers Object <optional>

Optional pre-allocated flat buffers for zero GC overhead.

female_output Float32Array <optional>

Optional target female output buffer.

male_output Float32Array <optional>

Optional target male output buffer.

total_output Float32Array <optional>

Optional target total output buffer.

Returns:
Type:
Object

Coupled smoothed cohort arrays.

(static) coupleAgeSexCohortsWhittaker(arg0_male_rates, arg1_female_rates, arg2_band_widthsopt, arg3_start_indexopt, arg4_optionsopt) → {Object}

Graduates total age-cohort density and reallocates it between sexes.

Defaults are appropriate for stochastic model-generated compositions: raw sex ratios are preserved, monotonicity is disabled, and the total population of the graduated suffix is preserved by final rescaling.

Density is normalised by the mean density of the graduated suffix. huber_delta is therefore expressed relative to that mean.

Fidelity weights default to band widths. These are integration weights, not estimated inverse-variance weights for a multinomial model.

Sex-ratio allocation applies to every cohort, including the prefix. Density graduation and total rescaling apply only from start_index.

Legacy options.buffers is not used; working calculations use Float64Array.

Source:
Parameters:
Name Type Attributes Default Description
arg0_male_rates Float32Array | Float64Array | Array.<number>
arg1_female_rates Float32Array | Float64Array | Array.<number>
arg2_band_widths Float32Array | Float64Array | Array.<number> <optional>
arg3_start_index number | null <optional>
2

Negative or null disables graduation.

arg4_options Object <optional>
Name Type Attributes Default Description
baseline_sex_ratios Array.<number> | Float32Array | Float64Array <optional>
do_not_smooth boolean <optional>
false
enforce_biological_sex_ratios boolean <optional>
false

Legacy name for applying supplied bounds.

enforce_fixed_sex_ratios boolean <optional>
false
female_output Float32Array | Float64Array <optional>
huber_delta number <optional>
0.05
lambda number <optional>
20.0
male_output Float32Array | Float64Array <optional>
max_iterations number <optional>
20000
mu number <optional>
0.0
preserve_sex_ratios boolean <optional>

Defaults to true unless another ratio policy is enabled.

preserve_total boolean <optional>
true
sex_ratio_bounds Array.<Array.<number>> <optional>
tolerance number <optional>
1e-8
total_output Float32Array | Float64Array <optional>
weights Array.<number> | Float32Array | Float64Array <optional>
Returns:
Type:
Object

(static) evaluateMultinomialModel(arg0_model, arg1_covariates_obj) → {Object}

Evaluates a trained multinomial logit model against a covariates object, returning overall accuracy and a confusion matrix.

Source:
Parameters:
Name Type Description
arg0_model string | Object

JSON model object or file path to JSON model.

arg1_covariates_obj Object

{ keys, X, Y }

Returns:
Type:
Object
  • { accuracy, confusion_matrix, sample_count }

(static) generateALRRaster(arg0_output_file_path, arg1_optionsopt) → {Promise.<void>}

Generates multi-class probability rasters from a trained ALR compositional model.

Source:
Parameters:
Name Type Attributes Description
arg0_output_file_path string

Output file path prefix or base name.

arg1_options Object <optional>
Name Type Attributes Default Description
covariates_obj Object
model_obj Object | string
height number <optional>
2160
width number <optional>
4320
Returns:
Type:
Promise.<void>

(static) generateMultinomialRaster(arg0_output_file_path, arg1_optionsopt) → {Promise.<void>}

Generates raster predictions from a trained multinomial logit model. Supports argmax class maps, single-class probability surfaces, or one probability raster per class.

Source:
Parameters:
Name Type Attributes Description
arg0_output_file_path string
arg1_options Object <optional>
Name Type Attributes Default Description
class number | string <optional>

Class label for "probability" output_mode.

covariates_obj Object
format string <optional>
"int32"
formatting_parameters Array <optional>
guard_clause function <optional>

(local_index:number, rasters_obj:Object) - false skips pixel processing.

model_obj Object | string <optional>

File path or JSON object.

output_mode string <optional>
"class"

"class" | "probability" | "probabilities".

height number <optional>
2160
width number <optional>
4320
Returns:
Type:
Promise.<void>

(static) generateMultinomialRastersParallel(arg0_items, arg1_task_generator, arg2_optionsopt) → {Promise.<Array.<Object>>}

Concurrently generates a series of Multinomial Logit predicted rasters across background worker processes.

Source:
Parameters:
Name Type Attributes Description
arg0_items Array.<any>

Array of years, models, or tasks to generate.

arg1_task_generator function

(local_item: any, local_index: number) => { output_file_path, model_obj, covariates_map, options }

arg2_options Object <optional>
Name Type Attributes Default Description
concurrency number <optional>
name string <optional>
"Multinomial Logit Raster Generation"
Returns:
Type:
Promise.<Array.<Object>>

(static) generateOLSRaster(arg0_output_file_path, arg1_optionsopt) → {Promise.<void>}

Generates an OLS raster from a stack of coefficients.

Source:
Parameters:
Name Type Attributes Description
arg0_output_file_path string
arg1_options Object <optional>
Name Type Attributes Default Description
covariates_obj Object
format string <optional>
"int32"
formatting_parameters Array <optional>
guard_clause function <optional>

(local_index:number, rasters_obj:Object) - false skips pixel processing.

model_obj Object | string <optional>

File path or JSON object.

utility_format string <optional>
"int32"
height number <optional>
2160
width number <optional>
4320
Returns:
Type:
Promise.<void>

(static) generateOLSRastersParallel(arg0_items, arg1_task_generator, arg2_optionsopt) → {Promise.<Array.<Object>>}

Concurrently generates a series of OLS predicted rasters across background worker processes.

Source:
Parameters:
Name Type Attributes Description
arg0_items Array.<any>

Array of years, models, or tasks to generate.

arg1_task_generator function

(local_item: any, local_index: number) => { output_file_path, model_obj, covariates_map, options }

arg2_options Object <optional>
Name Type Attributes Default Description
concurrency number <optional>
name string <optional>
"OLS Raster Generation"
Returns:
Type:
Promise.<Array.<Object>>

(static) geomeanOLSModels(arg0_input_folder_path, arg1_ols_prefix, arg2_optionsopt) → {Promise.<{coefficients: {}, raw_coefficients: {}}>}

Geometrically average OLS models across a folder path, with base OLS prefixes.

Source:
Parameters:
Name Type Attributes Description
arg0_input_folder_path string
arg1_ols_prefix string
arg2_options Object <optional>
Name Type Attributes Description
weighting_function function <optional>

(arg0_coefficient:number) | number

Returns:
Type:
Promise.<{coefficients: {}, raw_coefficients: {}}>

(static) getClassLabel(arg0_Y, arg1_index) → {any}

Returns the class label at a given index of Y, unwrapping single-element arrays.

Source:
Parameters:
Name Type Description
arg0_Y Array
arg1_index number
Returns:
Type:
any

(static) getLogisticKernelWeight(arg0_value, arg1_start_valopt, arg2_end_valopt, arg3_optionsopt) → {number}

Computes a normalised logistic transition kernel weight w in [0, 1] over a domain [start_val, end_val]. Returns 0 for values <= start_val, 1 for values >= end_val, and an S-curve blend for intermediate values.

Source:
Parameters:
Name Type Attributes Default Description
arg0_value number
arg1_start_val number <optional>
1750
arg2_end_val number <optional>
1850
arg3_options Object <optional>
Name Type Attributes Default Description
steepness number <optional>
8
Returns:
Type:
number

(static) loadCovariateRasters(arg0_covariates_obj, arg1_optionsopt) → {Object}

Loads a set of covariate rasters, resolving function- or string-valued paths and dropping rasters that fail to load. Shared by all covariate-stacking routines.

Source:
Parameters:
Name Type Attributes Description
arg0_covariates_obj Object
arg1_options Object <optional>
Name Type Attributes Default Description
data_only boolean <optional>
false

Store .data arrays instead of rasters.

formatting_parameters Array <optional>
[]

Spread into function-valued covariates.

year number <optional>

If set, function-valued covariates receive this single argument instead.

Returns:
Type:
Object
  • { rasters_obj, valid_keys }

(static) loadMultinomialCovariates(arg0_class_file_path, arg1_optionsopt) → {Promise.<Object>}

Loads a stack of covariates for a categorical class raster for multinomial logit training. Unlike loadOLSCovariates, zero-valued class labels are meaningful and retained.

Source:
Parameters:
Name Type Attributes Description
arg0_class_file_path string

Raster whose pixel values are integer class labels.

arg1_options Object <optional>
Name Type Attributes Default Description
covariates_obj Object
class_format string <optional>
"int32"
formatting_parameters Array.<any> <optional>
nodata_value number <optional>

Class label treated as nodata and dropped.

Returns:
Type:
Promise.<Object>
  • { keys, X, Y }

(static) loadOLSCovariates(arg0_utility_file_path, arg1_optionsopt) → {Promise.<Object>}

Loads a stack of covariates for a specific utility file path for OLS training.

Source:
Parameters:
Name Type Attributes Description
arg0_utility_file_path string
arg1_options Object <optional>
Name Type Attributes Default Description
covariates_obj Object
formatting_parameters Array.<any> <optional>
utility_format string <optional>
"int32"
Returns:
Type:
Promise.<Object>

(static) loadPointMultinomialCovariates(arg0_points, arg1_year, arg2_optionsopt) → {Promise.<Object>}

Loads a stack of covariates for point-based categorical data (e.g. household survey age/sex buckets) for multinomial logit training for a specific year.

Source:
Parameters:
Name Type Attributes Description
arg0_points Array.<Object>

Array of objects with { coords: [lng, lat], target: number, year: number }

arg1_year number

The target year to load covariates and sample points for.

arg2_options Object <optional>
Name Type Attributes Description
covariates_obj Object
covariates_year number <optional>

Mapped year to override path resolution.

get_pixel_function function <optional>

Custom coordinate-to-pixel mapping function.

Returns:
Type:
Promise.<Object>
  • { keys, X, Y }

(static) loadPointOLSCovariates(arg0_points, arg1_year, arg2_optionsopt) → {Promise.<Object>}

Loads a stack of covariates for point-based data for OLS training for a specific year.

Source:
Parameters:
Name Type Attributes Description
arg0_points Array.<Object>

Array of objects with { coords: [lng, lat], target: number, year: number }

arg1_year number

The target year to load covariates and sample points for.

arg2_options Object <optional>
Name Type Attributes Description
covariates_obj Object
covariates_year number <optional>

Mapped year to override path resolution.

get_pixel_function function <optional>

Custom coordinate-to-pixel mapping function.

Returns:
Type:
Promise.<Object>

(static) multinomialLogitRegression(arg0_X, arg1_Y, arg2_optionsopt) → {Object|null}

Performs L2-regularised Multinomial Logistic Regression (softmax regression) via batch gradient descent with momentum. The first observed class is the reference class with coefficients fixed at zero for identifiability.

Source:
Parameters:
Name Type Attributes Description
arg0_X Matrix | Array
arg1_Y Matrix | Array

Nx1 matrix of integer class labels.

arg2_options Object <optional>
Name Type Attributes Default Description
debug boolean <optional>
false
lambda number <optional>
1e-3

L2 regularisation strength (ridge analogue).

learning_rate number <optional>
0.5
max_iterations number <optional>
1000
momentum number <optional>
0.9
sample_weights Array.<number> <optional>

Non-negative observation weights.

tolerance number <optional>
1e-8
Returns:
Type:
Object | null
  • { beta, classes, converged, iterations, log_likelihood }

(static) pavaDecreasing(arg0_values, arg1_weightsopt, arg2_start_indexopt, arg3_optionsopt) → {Float32Array|Array.<number>}

Enforces non-increasing monotonicity on a sequence using the weighted Pool Adjacent Violators Algorithm (PAVA). Values before arg2_start_index are preserved unconstrained.

Source:
Parameters:
Name Type Attributes Default Description
arg0_values Float32Array | Array.<number>

Array of values to smooth.

arg1_weights Float32Array | Array.<number> <optional>

Optional weights (e.g. cohort band widths).

arg2_start_index number <optional>
0

Index from which to enforce non-increasing monotonicity.

arg3_options Object <optional>
Name Type Attributes Description
buffers Object <optional>

Optional pre-allocated flat buffers for zero GC overhead.

Name Type Attributes Description
block_vals Float32Array <optional>
block_weights Float32Array <optional>
block_counts Int32Array <optional>
output Float32Array | Array.<number> <optional>

Optional target output buffer.

Returns:
Type:
Float32Array | Array.<number>

Monotonically decreasing output array.

(static) predictALRProbabilities(arg0_features_obj, arg1_model_obj) → {Object}

Computes predicted compositional class probabilities for a single feature object using a trained ALR model.

Source:
Parameters:
Name Type Description
arg0_features_obj Object

Feature mapping.

arg1_model_obj Object

Trained ALR model object with .categories, .reference_category, and .coefficients.

Returns:
Type:
Object

Mapping of category names to probabilities summing to 1.0.

(static) predictMultinomialEnsemble(arg0_features_obj, arg1_models, arg2_weightsopt) → {Object}

Predicts class probabilities from an ensemble of models using a convex combination in probability space.

Source:
Parameters:
Name Type Attributes Description
arg0_features_obj Object

Map of covariate keys to feature values.

arg1_models Array.<(Object|string)>

Array of model objects or file paths.

arg2_weights Array.<number> <optional>

Optional array of model weights.

Returns:
Type:
Object
  • Map of class labels to blended probabilities.

(static) predictMultinomialProbabilities(arg0_features_obj, arg1_model_obj) → {Object}

Predicts class probabilities for a single feature object against a trained multinomial logit model. Supports both discrete multinomial_logit models and probability-space multinomial_ensemble mixtures.

Source:
Parameters:
Name Type Description
arg0_features_obj Object

Map of covariate keys to feature values.

arg1_model_obj Object

Trained model object with .classes and .coefficients.

Returns:
Type:
Object
  • Map of class labels to probabilities.

(static) processOLSModel(arg0_model, arg1_optionsopt) → {Promise.<Object>}

Processes and adjusts OLS model coefficients against target and covariate rasters using Multiplicative Update Rules (NMF).

Source:
Parameters:
Name Type Attributes Description
arg0_model string | Object

JSON model object or file path to JSON model.

arg1_options Object <optional>
Name Type Attributes Default Description
covariates_obj Object <optional>

Map of covariate keys to functions or file paths.

debug boolean <optional>
false
output_file_path string <optional>

Path to save the adjusted model JSON.

steps Array.<any> | any <optional>

Array of steps or parameter sets (e.g., years) passed into target and covariate functions.

target string | function <optional>

File path or function returning file path for target raster.

target_format string <optional>
"float32"
Returns:
Type:
Promise.<Object>

(static) removeHighVIFFeatures(arg0_X, arg1_thresholdopt) → {Array.<Array.<number>>}

Removes high VIF features for a given matrix.

Source:
Parameters:
Name Type Attributes Default Description
arg0_X Matrix | Array
arg1_threshold number <optional>
10
Returns:
Type:
Array.<Array.<number>>

(static) ridgeRegression(arg0_X, arg1_Y, arg2_lambdaopt) → {Matrix|Array}

Performs Ridge Regression on two matrices with RMS scale stabilization and pseudo-inverse fallbacks.

Source:
Parameters:
Name Type Attributes Default Description
arg0_X Matrix | Array
arg1_Y Matrix | Array
arg2_lambda number <optional>
1e-3
Returns:
Type:
Matrix | Array

(static) softmax(arg0_logits) → {Array.<number>}

Computes a numerically-stable softmax over an array of logits.

Source:
Parameters:
Name Type Description
arg0_logits Array.<number>
Returns:
Type:
Array.<number>

(static) trainALRModel(arg0_output_file_path, arg1_covariates_obj, arg2_optionsopt) → {Promise.<(Object|null)>}

Trains an Additive Log-Ratio (ALR) regularised ridge regression model for continuous compositional targets. Bypasses gradient descent under-convergence by solving normal equations analytically.

Source:
Parameters:
Name Type Attributes Description
arg0_output_file_path string

File path to save the trained model.

arg1_covariates_obj Object

{ keys, X, Y, categories, [reference_category] }

arg2_options Object <optional>
Name Type Attributes Default Description
key string <optional>
lambda number <optional>
1e-3

Ridge penalty strength.

smoothing number <optional>
1e-6

Log-ratio epsilon smoothing.

Returns:
Type:
Promise.<(Object|null)>

(static) trainMultinomialLogitModel(arg0_output_file_path, arg1_covariates_obj, arg2_optionsopt) → {Promise.<(Object|null)>}

Trains a multinomial logit model given a fitted covariates object { X, Y, keys } and saves it to JSON. Coefficients are stored per non-reference class.

Source:
Parameters:
Name Type Attributes Description
arg0_output_file_path string
arg1_covariates_obj Object

{ keys, X, Y }

arg2_options Object <optional>
Name Type Attributes Default Description
compute_standard_errors boolean <optional>
false

Hessian-based uncertainty.

debug boolean <optional>
false
key string <optional>
lambda number <optional>
1e-3
learning_rate number <optional>
0.5
max_iterations number <optional>
1000
momentum number <optional>
0.9
tolerance number <optional>
1e-8
Returns:
Type:
Promise.<(Object|null)>

(static) trainMultinomialLogitModelsParallel(arg0_items, arg1_task_generator, arg2_optionsopt) → {Promise.<Array.<Object>>}

Concurrently trains a series of multinomial logit models across background worker processes.

Source:
Parameters:
Name Type Attributes Description
arg0_items Array.<any>

Array of tasks, years, or cohort descriptors.

arg1_task_generator function

(local_item: any, local_index: number) => { categories, covariates_map, filter_format, filter_raster_path, model_path, options, target_paths }

arg2_options Object <optional>
Name Type Attributes Default Description
concurrency number <optional>

Worker thread count.

name string <optional>
"Multinomial Logit Training"
Returns:
Type:
Promise.<Array.<Object>>

(static) trainOLSModel(arg0_output_file_path, arg1_covariates_obj, arg2_optionsopt) → {Promise.<Object>}

Trains a raster-based OLS model given a fitted covariates object { X, Y, keys }.

Source:
Parameters:
Name Type Attributes Description
arg0_output_file_path string
arg1_covariates_obj Object
arg2_options Object <optional>
Name Type Attributes Default Description
dynamic_lambda boolean <optional>
false

Condition numbers are dynamically selected if true.

lambda number <optional>
1e9
remove_high_vif_features boolean <optional>
false

Whether to remove high VIF features.

key string <optional>
weighting_function function <optional>

(arg0_coefficient:number) | number

Returns:
Type:
Promise.<Object>

(static) trainOLSModelsParallel(arg0_items, arg1_task_generator, arg2_optionsopt) → {Promise.<Array.<Object>>}

Concurrently trains a series of OLS models across background worker processes.

Source:
Parameters:
Name Type Attributes Description
arg0_items Array.<any>

Array of years, models, or tasks to train.

arg1_task_generator function

(local_item: any, local_index: number) => { output_file_path, target_file_path, target_format, covariates_map, options, points, target_year }

arg2_options Object <optional>
Name Type Attributes Default Description
concurrency number <optional>

Worker thread count.

name string <optional>
"OLS Model Training"
Returns:
Type:
Promise.<Array.<Object>>

(static) whittakerHendersonRobust(arg0_values, arg1_weightsopt, arg2_start_indexopt, arg3_optionsopt) → {Float32Array|Float64Array}

Performs Whittaker-Henderson graduation with weighted Huber fidelity, second-difference roughness, and optional soft non-increasing monotonicity.

Penalties apply only within [start_index, values.length). Values before start_index are copied without modification.

Source:
Parameters:
Name Type Attributes Default Description
arg0_values Float32Array | Float64Array | Array.<number>
arg1_weights Float32Array | Float64Array | Array.<number> <optional>
arg2_start_index number <optional>
0
arg3_options Object <optional>
Name Type Attributes Default Description
output Float32Array | Float64Array <optional>
huber_delta number <optional>
0.05
lambda number <optional>
20.0
max_iterations number <optional>
20000
min_value number <optional>
-Infinity
mu number <optional>
0.0
tolerance number <optional>
1e-8

Absolute KKT residual tolerance.

Returns:
Type:
Float32Array | Float64Array

Statistics

The namespace for all UF/Statistics utility functions, typically for static methods.

Source:

Methods

(static) _computeXT_X(arg0_X) → {Array.<Array.<number>>}

Computes the X^T * X matrix manually to save memory.

Source:
Parameters:
Name Type Description
arg0_X Array.<Array.<number>>
Returns:
Type:
Array.<Array.<number>>

(static) argmaxMultinomialClass(arg0_probabilities, arg1_classes) → {any}

Returns the class label with the highest probability.

Source:
Parameters:
Name Type Description
arg0_probabilities Object

Map of class labels to probabilities.

arg1_classes Array
Returns:
Type:
any

(static) computeMultinomialLogits(arg0_row_X, arg1_beta) → {Array.<number>}

Computes logits for a single sample against a CxK coefficient matrix. Row 0 of beta is assumed to be the zeroed reference class.

Source:
Parameters:
Name Type Description
arg0_row_X Array.<number>
arg1_beta Array.<Array.<number>>
Returns:
Type:
Array.<number>

(static) computeMultinomialStandardErrors(arg0_X, arg1_Y, arg2_result, arg3_lambdaopt) → {Object}

Computes approximate per-class standard errors from the Hessian at convergence. Uses the standard class-vs-rest approximation H_c = Σ p_ic(1-p_ic) x_i x_i^T + λI.

Source:
Parameters:
Name Type Attributes Default Description
arg0_X Array.<Array.<number>>
arg1_Y Array.<Array.<number>>
arg2_result Object

Result object from Statistics.multinomialLogitRegression.

arg3_lambda number <optional>
1e-3
Returns:
Type:
Object
  • Map of class labels to arrays of standard errors.

(static) computeVIF(arg0_X) → {Array.<number>}

Computes the VIF of a given matrix.

Source:
Parameters:
Name Type Description
arg0_X Matrix | Array
Returns:
Type:
Array.<number>

(static) conditionNumber(arg0_X, arg1_epsilonopt) → {number}

Returns the condition number of a given matrix.

Source:
Parameters:
Name Type Attributes Default Description
arg0_X Matrix | Array
arg1_epsilon number <optional>
1e-12
Returns:
Type:
number

(static) coupleAgeSexCohorts(arg0_male_rates, arg1_female_rates, arg2_band_widths, arg3_start_indexopt, arg4_optionsopt) → {Object}

Smooths age cohorts and couples sex ratios simultaneously. Enforces non-increasing monotonicity along the age dimension using weighted PAVA on total cohort population density, then allocates totals between male and female using the model's empirical sex ratio bounded within a biological plausibility envelope (Option 1).

Source:
Parameters:
Name Type Attributes Default Description
arg0_male_rates Float32Array | Array.<number>

Raw male cohort values.

arg1_female_rates Float32Array | Array.<number>

Raw female cohort values.

arg2_band_widths Float32Array | Array.<number>

Cohort duration in years (e.g. 1 for 00, 4 for 01, 5 for others).

arg3_start_index number <optional>
0

Index from which to enforce age monotonicity (defaults to 0 on annualised density).

arg4_options Object <optional>
Name Type Attributes Default Description
baseline_sex_ratios Float32Array | Array.<number> <optional>

Optional target sex-ratio curve M/F by cohort.

sex_ratio_bounds Array.<Array.<number>> <optional>

Optional min/max sex-ratio bounds by cohort.

enforce_fixed_sex_ratios boolean <optional>
false

If true, strictly forces M/F = baseline_sex_ratios.

buffers Object <optional>

Optional pre-allocated flat buffers for zero GC overhead.

female_output Float32Array <optional>

Optional target female output buffer.

male_output Float32Array <optional>

Optional target male output buffer.

total_output Float32Array <optional>

Optional target total output buffer.

Returns:
Type:
Object

Coupled smoothed cohort arrays.

(static) coupleAgeSexCohortsWhittaker(arg0_male_rates, arg1_female_rates, arg2_band_widthsopt, arg3_start_indexopt, arg4_optionsopt) → {Object}

Graduates total age-cohort density and reallocates it between sexes.

Defaults are appropriate for stochastic model-generated compositions: raw sex ratios are preserved, monotonicity is disabled, and the total population of the graduated suffix is preserved by final rescaling.

Density is normalised by the mean density of the graduated suffix. huber_delta is therefore expressed relative to that mean.

Fidelity weights default to band widths. These are integration weights, not estimated inverse-variance weights for a multinomial model.

Sex-ratio allocation applies to every cohort, including the prefix. Density graduation and total rescaling apply only from start_index.

Legacy options.buffers is not used; working calculations use Float64Array.

Source:
Parameters:
Name Type Attributes Default Description
arg0_male_rates Float32Array | Float64Array | Array.<number>
arg1_female_rates Float32Array | Float64Array | Array.<number>
arg2_band_widths Float32Array | Float64Array | Array.<number> <optional>
arg3_start_index number | null <optional>
2

Negative or null disables graduation.

arg4_options Object <optional>
Name Type Attributes Default Description
baseline_sex_ratios Array.<number> | Float32Array | Float64Array <optional>
do_not_smooth boolean <optional>
false
enforce_biological_sex_ratios boolean <optional>
false

Legacy name for applying supplied bounds.

enforce_fixed_sex_ratios boolean <optional>
false
female_output Float32Array | Float64Array <optional>
huber_delta number <optional>
0.05
lambda number <optional>
20.0
male_output Float32Array | Float64Array <optional>
max_iterations number <optional>
20000
mu number <optional>
0.0
preserve_sex_ratios boolean <optional>

Defaults to true unless another ratio policy is enabled.

preserve_total boolean <optional>
true
sex_ratio_bounds Array.<Array.<number>> <optional>
tolerance number <optional>
1e-8
total_output Float32Array | Float64Array <optional>
weights Array.<number> | Float32Array | Float64Array <optional>
Returns:
Type:
Object

(static) evaluateMultinomialModel(arg0_model, arg1_covariates_obj) → {Object}

Evaluates a trained multinomial logit model against a covariates object, returning overall accuracy and a confusion matrix.

Source:
Parameters:
Name Type Description
arg0_model string | Object

JSON model object or file path to JSON model.

arg1_covariates_obj Object

{ keys, X, Y }

Returns:
Type:
Object
  • { accuracy, confusion_matrix, sample_count }

(static) generateALRRaster(arg0_output_file_path, arg1_optionsopt) → {Promise.<void>}

Generates multi-class probability rasters from a trained ALR compositional model.

Source:
Parameters:
Name Type Attributes Description
arg0_output_file_path string

Output file path prefix or base name.

arg1_options Object <optional>
Name Type Attributes Default Description
covariates_obj Object
model_obj Object | string
height number <optional>
2160
width number <optional>
4320
Returns:
Type:
Promise.<void>

(static) generateMultinomialRaster(arg0_output_file_path, arg1_optionsopt) → {Promise.<void>}

Generates raster predictions from a trained multinomial logit model. Supports argmax class maps, single-class probability surfaces, or one probability raster per class.

Source:
Parameters:
Name Type Attributes Description
arg0_output_file_path string
arg1_options Object <optional>
Name Type Attributes Default Description
class number | string <optional>

Class label for "probability" output_mode.

covariates_obj Object
format string <optional>
"int32"
formatting_parameters Array <optional>
guard_clause function <optional>

(local_index:number, rasters_obj:Object) - false skips pixel processing.

model_obj Object | string <optional>

File path or JSON object.

output_mode string <optional>
"class"

"class" | "probability" | "probabilities".

height number <optional>
2160
width number <optional>
4320
Returns:
Type:
Promise.<void>

(static) generateMultinomialRastersParallel(arg0_items, arg1_task_generator, arg2_optionsopt) → {Promise.<Array.<Object>>}

Concurrently generates a series of Multinomial Logit predicted rasters across background worker processes.

Source:
Parameters:
Name Type Attributes Description
arg0_items Array.<any>

Array of years, models, or tasks to generate.

arg1_task_generator function

(local_item: any, local_index: number) => { output_file_path, model_obj, covariates_map, options }

arg2_options Object <optional>
Name Type Attributes Default Description
concurrency number <optional>
name string <optional>
"Multinomial Logit Raster Generation"
Returns:
Type:
Promise.<Array.<Object>>

(static) generateOLSRaster(arg0_output_file_path, arg1_optionsopt) → {Promise.<void>}

Generates an OLS raster from a stack of coefficients.

Source:
Parameters:
Name Type Attributes Description
arg0_output_file_path string
arg1_options Object <optional>
Name Type Attributes Default Description
covariates_obj Object
format string <optional>
"int32"
formatting_parameters Array <optional>
guard_clause function <optional>

(local_index:number, rasters_obj:Object) - false skips pixel processing.

model_obj Object | string <optional>

File path or JSON object.

utility_format string <optional>
"int32"
height number <optional>
2160
width number <optional>
4320
Returns:
Type:
Promise.<void>

(static) generateOLSRastersParallel(arg0_items, arg1_task_generator, arg2_optionsopt) → {Promise.<Array.<Object>>}

Concurrently generates a series of OLS predicted rasters across background worker processes.

Source:
Parameters:
Name Type Attributes Description
arg0_items Array.<any>

Array of years, models, or tasks to generate.

arg1_task_generator function

(local_item: any, local_index: number) => { output_file_path, model_obj, covariates_map, options }

arg2_options Object <optional>
Name Type Attributes Default Description
concurrency number <optional>
name string <optional>
"OLS Raster Generation"
Returns:
Type:
Promise.<Array.<Object>>

(static) geomeanOLSModels(arg0_input_folder_path, arg1_ols_prefix, arg2_optionsopt) → {Promise.<{coefficients: {}, raw_coefficients: {}}>}

Geometrically average OLS models across a folder path, with base OLS prefixes.

Source:
Parameters:
Name Type Attributes Description
arg0_input_folder_path string
arg1_ols_prefix string
arg2_options Object <optional>
Name Type Attributes Description
weighting_function function <optional>

(arg0_coefficient:number) | number

Returns:
Type:
Promise.<{coefficients: {}, raw_coefficients: {}}>

(static) getClassLabel(arg0_Y, arg1_index) → {any}

Returns the class label at a given index of Y, unwrapping single-element arrays.

Source:
Parameters:
Name Type Description
arg0_Y Array
arg1_index number
Returns:
Type:
any

(static) getLogisticKernelWeight(arg0_value, arg1_start_valopt, arg2_end_valopt, arg3_optionsopt) → {number}

Computes a normalised logistic transition kernel weight w in [0, 1] over a domain [start_val, end_val]. Returns 0 for values <= start_val, 1 for values >= end_val, and an S-curve blend for intermediate values.

Source:
Parameters:
Name Type Attributes Default Description
arg0_value number
arg1_start_val number <optional>
1750
arg2_end_val number <optional>
1850
arg3_options Object <optional>
Name Type Attributes Default Description
steepness number <optional>
8
Returns:
Type:
number

(static) loadCovariateRasters(arg0_covariates_obj, arg1_optionsopt) → {Object}

Loads a set of covariate rasters, resolving function- or string-valued paths and dropping rasters that fail to load. Shared by all covariate-stacking routines.

Source:
Parameters:
Name Type Attributes Description
arg0_covariates_obj Object
arg1_options Object <optional>
Name Type Attributes Default Description
data_only boolean <optional>
false

Store .data arrays instead of rasters.

formatting_parameters Array <optional>
[]

Spread into function-valued covariates.

year number <optional>

If set, function-valued covariates receive this single argument instead.

Returns:
Type:
Object
  • { rasters_obj, valid_keys }

(static) loadMultinomialCovariates(arg0_class_file_path, arg1_optionsopt) → {Promise.<Object>}

Loads a stack of covariates for a categorical class raster for multinomial logit training. Unlike loadOLSCovariates, zero-valued class labels are meaningful and retained.

Source:
Parameters:
Name Type Attributes Description
arg0_class_file_path string

Raster whose pixel values are integer class labels.

arg1_options Object <optional>
Name Type Attributes Default Description
covariates_obj Object
class_format string <optional>
"int32"
formatting_parameters Array.<any> <optional>
nodata_value number <optional>

Class label treated as nodata and dropped.

Returns:
Type:
Promise.<Object>
  • { keys, X, Y }

(static) loadOLSCovariates(arg0_utility_file_path, arg1_optionsopt) → {Promise.<Object>}

Loads a stack of covariates for a specific utility file path for OLS training.

Source:
Parameters:
Name Type Attributes Description
arg0_utility_file_path string
arg1_options Object <optional>
Name Type Attributes Default Description
covariates_obj Object
formatting_parameters Array.<any> <optional>
utility_format string <optional>
"int32"
Returns:
Type:
Promise.<Object>

(static) loadPointMultinomialCovariates(arg0_points, arg1_year, arg2_optionsopt) → {Promise.<Object>}

Loads a stack of covariates for point-based categorical data (e.g. household survey age/sex buckets) for multinomial logit training for a specific year.

Source:
Parameters:
Name Type Attributes Description
arg0_points Array.<Object>

Array of objects with { coords: [lng, lat], target: number, year: number }

arg1_year number

The target year to load covariates and sample points for.

arg2_options Object <optional>
Name Type Attributes Description
covariates_obj Object
covariates_year number <optional>

Mapped year to override path resolution.

get_pixel_function function <optional>

Custom coordinate-to-pixel mapping function.

Returns:
Type:
Promise.<Object>
  • { keys, X, Y }

(static) loadPointOLSCovariates(arg0_points, arg1_year, arg2_optionsopt) → {Promise.<Object>}

Loads a stack of covariates for point-based data for OLS training for a specific year.

Source:
Parameters:
Name Type Attributes Description
arg0_points Array.<Object>

Array of objects with { coords: [lng, lat], target: number, year: number }

arg1_year number

The target year to load covariates and sample points for.

arg2_options Object <optional>
Name Type Attributes Description
covariates_obj Object
covariates_year number <optional>

Mapped year to override path resolution.

get_pixel_function function <optional>

Custom coordinate-to-pixel mapping function.

Returns:
Type:
Promise.<Object>

(static) multinomialLogitRegression(arg0_X, arg1_Y, arg2_optionsopt) → {Object|null}

Performs L2-regularised Multinomial Logistic Regression (softmax regression) via batch gradient descent with momentum. The first observed class is the reference class with coefficients fixed at zero for identifiability.

Source:
Parameters:
Name Type Attributes Description
arg0_X Matrix | Array
arg1_Y Matrix | Array

Nx1 matrix of integer class labels.

arg2_options Object <optional>
Name Type Attributes Default Description
debug boolean <optional>
false
lambda number <optional>
1e-3

L2 regularisation strength (ridge analogue).

learning_rate number <optional>
0.5
max_iterations number <optional>
1000
momentum number <optional>
0.9
sample_weights Array.<number> <optional>

Non-negative observation weights.

tolerance number <optional>
1e-8
Returns:
Type:
Object | null
  • { beta, classes, converged, iterations, log_likelihood }

(static) pavaDecreasing(arg0_values, arg1_weightsopt, arg2_start_indexopt, arg3_optionsopt) → {Float32Array|Array.<number>}

Enforces non-increasing monotonicity on a sequence using the weighted Pool Adjacent Violators Algorithm (PAVA). Values before arg2_start_index are preserved unconstrained.

Source:
Parameters:
Name Type Attributes Default Description
arg0_values Float32Array | Array.<number>

Array of values to smooth.

arg1_weights Float32Array | Array.<number> <optional>

Optional weights (e.g. cohort band widths).

arg2_start_index number <optional>
0

Index from which to enforce non-increasing monotonicity.

arg3_options Object <optional>
Name Type Attributes Description
buffers Object <optional>

Optional pre-allocated flat buffers for zero GC overhead.

Name Type Attributes Description
block_vals Float32Array <optional>
block_weights Float32Array <optional>
block_counts Int32Array <optional>
output Float32Array | Array.<number> <optional>

Optional target output buffer.

Returns:
Type:
Float32Array | Array.<number>

Monotonically decreasing output array.

(static) predictALRProbabilities(arg0_features_obj, arg1_model_obj) → {Object}

Computes predicted compositional class probabilities for a single feature object using a trained ALR model.

Source:
Parameters:
Name Type Description
arg0_features_obj Object

Feature mapping.

arg1_model_obj Object

Trained ALR model object with .categories, .reference_category, and .coefficients.

Returns:
Type:
Object

Mapping of category names to probabilities summing to 1.0.

(static) predictMultinomialEnsemble(arg0_features_obj, arg1_models, arg2_weightsopt) → {Object}

Predicts class probabilities from an ensemble of models using a convex combination in probability space.

Source:
Parameters:
Name Type Attributes Description
arg0_features_obj Object

Map of covariate keys to feature values.

arg1_models Array.<(Object|string)>

Array of model objects or file paths.

arg2_weights Array.<number> <optional>

Optional array of model weights.

Returns:
Type:
Object
  • Map of class labels to blended probabilities.

(static) predictMultinomialProbabilities(arg0_features_obj, arg1_model_obj) → {Object}

Predicts class probabilities for a single feature object against a trained multinomial logit model. Supports both discrete multinomial_logit models and probability-space multinomial_ensemble mixtures.

Source:
Parameters:
Name Type Description
arg0_features_obj Object

Map of covariate keys to feature values.

arg1_model_obj Object

Trained model object with .classes and .coefficients.

Returns:
Type:
Object
  • Map of class labels to probabilities.

(static) processOLSModel(arg0_model, arg1_optionsopt) → {Promise.<Object>}

Processes and adjusts OLS model coefficients against target and covariate rasters using Multiplicative Update Rules (NMF).

Source:
Parameters:
Name Type Attributes Description
arg0_model string | Object

JSON model object or file path to JSON model.

arg1_options Object <optional>
Name Type Attributes Default Description
covariates_obj Object <optional>

Map of covariate keys to functions or file paths.

debug boolean <optional>
false
output_file_path string <optional>

Path to save the adjusted model JSON.

steps Array.<any> | any <optional>

Array of steps or parameter sets (e.g., years) passed into target and covariate functions.

target string | function <optional>

File path or function returning file path for target raster.

target_format string <optional>
"float32"
Returns:
Type:
Promise.<Object>

(static) removeHighVIFFeatures(arg0_X, arg1_thresholdopt) → {Array.<Array.<number>>}

Removes high VIF features for a given matrix.

Source:
Parameters:
Name Type Attributes Default Description
arg0_X Matrix | Array
arg1_threshold number <optional>
10
Returns:
Type:
Array.<Array.<number>>

(static) ridgeRegression(arg0_X, arg1_Y, arg2_lambdaopt) → {Matrix|Array}

Performs Ridge Regression on two matrices with RMS scale stabilization and pseudo-inverse fallbacks.

Source:
Parameters:
Name Type Attributes Default Description
arg0_X Matrix | Array
arg1_Y Matrix | Array
arg2_lambda number <optional>
1e-3
Returns:
Type:
Matrix | Array

(static) softmax(arg0_logits) → {Array.<number>}

Computes a numerically-stable softmax over an array of logits.

Source:
Parameters:
Name Type Description
arg0_logits Array.<number>
Returns:
Type:
Array.<number>

(static) trainALRModel(arg0_output_file_path, arg1_covariates_obj, arg2_optionsopt) → {Promise.<(Object|null)>}

Trains an Additive Log-Ratio (ALR) regularised ridge regression model for continuous compositional targets. Bypasses gradient descent under-convergence by solving normal equations analytically.

Source:
Parameters:
Name Type Attributes Description
arg0_output_file_path string

File path to save the trained model.

arg1_covariates_obj Object

{ keys, X, Y, categories, [reference_category] }

arg2_options Object <optional>
Name Type Attributes Default Description
key string <optional>
lambda number <optional>
1e-3

Ridge penalty strength.

smoothing number <optional>
1e-6

Log-ratio epsilon smoothing.

Returns:
Type:
Promise.<(Object|null)>

(static) trainMultinomialLogitModel(arg0_output_file_path, arg1_covariates_obj, arg2_optionsopt) → {Promise.<(Object|null)>}

Trains a multinomial logit model given a fitted covariates object { X, Y, keys } and saves it to JSON. Coefficients are stored per non-reference class.

Source:
Parameters:
Name Type Attributes Description
arg0_output_file_path string
arg1_covariates_obj Object

{ keys, X, Y }

arg2_options Object <optional>
Name Type Attributes Default Description
compute_standard_errors boolean <optional>
false

Hessian-based uncertainty.

debug boolean <optional>
false
key string <optional>
lambda number <optional>
1e-3
learning_rate number <optional>
0.5
max_iterations number <optional>
1000
momentum number <optional>
0.9
tolerance number <optional>
1e-8
Returns:
Type:
Promise.<(Object|null)>

(static) trainMultinomialLogitModelsParallel(arg0_items, arg1_task_generator, arg2_optionsopt) → {Promise.<Array.<Object>>}

Concurrently trains a series of multinomial logit models across background worker processes.

Source:
Parameters:
Name Type Attributes Description
arg0_items Array.<any>

Array of tasks, years, or cohort descriptors.

arg1_task_generator function

(local_item: any, local_index: number) => { categories, covariates_map, filter_format, filter_raster_path, model_path, options, target_paths }

arg2_options Object <optional>
Name Type Attributes Default Description
concurrency number <optional>

Worker thread count.

name string <optional>
"Multinomial Logit Training"
Returns:
Type:
Promise.<Array.<Object>>

(static) trainOLSModel(arg0_output_file_path, arg1_covariates_obj, arg2_optionsopt) → {Promise.<Object>}

Trains a raster-based OLS model given a fitted covariates object { X, Y, keys }.

Source:
Parameters:
Name Type Attributes Description
arg0_output_file_path string
arg1_covariates_obj Object
arg2_options Object <optional>
Name Type Attributes Default Description
dynamic_lambda boolean <optional>
false

Condition numbers are dynamically selected if true.

lambda number <optional>
1e9
remove_high_vif_features boolean <optional>
false

Whether to remove high VIF features.

key string <optional>
weighting_function function <optional>

(arg0_coefficient:number) | number

Returns:
Type:
Promise.<Object>

(static) trainOLSModelsParallel(arg0_items, arg1_task_generator, arg2_optionsopt) → {Promise.<Array.<Object>>}

Concurrently trains a series of OLS models across background worker processes.

Source:
Parameters:
Name Type Attributes Description
arg0_items Array.<any>

Array of years, models, or tasks to train.

arg1_task_generator function

(local_item: any, local_index: number) => { output_file_path, target_file_path, target_format, covariates_map, options, points, target_year }

arg2_options Object <optional>
Name Type Attributes Default Description
concurrency number <optional>

Worker thread count.

name string <optional>
"OLS Model Training"
Returns:
Type:
Promise.<Array.<Object>>

(static) whittakerHendersonRobust(arg0_values, arg1_weightsopt, arg2_start_indexopt, arg3_optionsopt) → {Float32Array|Float64Array}

Performs Whittaker-Henderson graduation with weighted Huber fidelity, second-difference roughness, and optional soft non-increasing monotonicity.

Penalties apply only within [start_index, values.length). Values before start_index are copied without modification.

Source:
Parameters:
Name Type Attributes Default Description
arg0_values Float32Array | Float64Array | Array.<number>
arg1_weights Float32Array | Float64Array | Array.<number> <optional>
arg2_start_index number <optional>
0
arg3_options Object <optional>
Name Type Attributes Default Description
output Float32Array | Float64Array <optional>
huber_delta number <optional>
0.05
lambda number <optional>
20.0
max_iterations number <optional>
20000
min_value number <optional>
-Infinity
mu number <optional>
0.0
tolerance number <optional>
1e-8

Absolute KKT residual tolerance.

Returns:
Type:
Float32Array | Float64Array

Statistics

The namespace for all UF/Statistics utility functions, typically for static methods.

Source:

Methods

(static) _computeXT_X(arg0_X) → {Array.<Array.<number>>}

Computes the X^T * X matrix manually to save memory.

Source:
Parameters:
Name Type Description
arg0_X Array.<Array.<number>>
Returns:
Type:
Array.<Array.<number>>

(static) argmaxMultinomialClass(arg0_probabilities, arg1_classes) → {any}

Returns the class label with the highest probability.

Source:
Parameters:
Name Type Description
arg0_probabilities Object

Map of class labels to probabilities.

arg1_classes Array
Returns:
Type:
any

(static) computeMultinomialLogits(arg0_row_X, arg1_beta) → {Array.<number>}

Computes logits for a single sample against a CxK coefficient matrix. Row 0 of beta is assumed to be the zeroed reference class.

Source:
Parameters:
Name Type Description
arg0_row_X Array.<number>
arg1_beta Array.<Array.<number>>
Returns:
Type:
Array.<number>

(static) computeMultinomialStandardErrors(arg0_X, arg1_Y, arg2_result, arg3_lambdaopt) → {Object}

Computes approximate per-class standard errors from the Hessian at convergence. Uses the standard class-vs-rest approximation H_c = Σ p_ic(1-p_ic) x_i x_i^T + λI.

Source:
Parameters:
Name Type Attributes Default Description
arg0_X Array.<Array.<number>>
arg1_Y Array.<Array.<number>>
arg2_result Object

Result object from Statistics.multinomialLogitRegression.

arg3_lambda number <optional>
1e-3
Returns:
Type:
Object
  • Map of class labels to arrays of standard errors.

(static) computeVIF(arg0_X) → {Array.<number>}

Computes the VIF of a given matrix.

Source:
Parameters:
Name Type Description
arg0_X Matrix | Array
Returns:
Type:
Array.<number>

(static) conditionNumber(arg0_X, arg1_epsilonopt) → {number}

Returns the condition number of a given matrix.

Source:
Parameters:
Name Type Attributes Default Description
arg0_X Matrix | Array
arg1_epsilon number <optional>
1e-12
Returns:
Type:
number

(static) coupleAgeSexCohorts(arg0_male_rates, arg1_female_rates, arg2_band_widths, arg3_start_indexopt, arg4_optionsopt) → {Object}

Smooths age cohorts and couples sex ratios simultaneously. Enforces non-increasing monotonicity along the age dimension using weighted PAVA on total cohort population density, then allocates totals between male and female using the model's empirical sex ratio bounded within a biological plausibility envelope (Option 1).

Source:
Parameters:
Name Type Attributes Default Description
arg0_male_rates Float32Array | Array.<number>

Raw male cohort values.

arg1_female_rates Float32Array | Array.<number>

Raw female cohort values.

arg2_band_widths Float32Array | Array.<number>

Cohort duration in years (e.g. 1 for 00, 4 for 01, 5 for others).

arg3_start_index number <optional>
0

Index from which to enforce age monotonicity (defaults to 0 on annualised density).

arg4_options Object <optional>
Name Type Attributes Default Description
baseline_sex_ratios Float32Array | Array.<number> <optional>

Optional target sex-ratio curve M/F by cohort.

sex_ratio_bounds Array.<Array.<number>> <optional>

Optional min/max sex-ratio bounds by cohort.

enforce_fixed_sex_ratios boolean <optional>
false

If true, strictly forces M/F = baseline_sex_ratios.

buffers Object <optional>

Optional pre-allocated flat buffers for zero GC overhead.

female_output Float32Array <optional>

Optional target female output buffer.

male_output Float32Array <optional>

Optional target male output buffer.

total_output Float32Array <optional>

Optional target total output buffer.

Returns:
Type:
Object

Coupled smoothed cohort arrays.

(static) coupleAgeSexCohortsWhittaker(arg0_male_rates, arg1_female_rates, arg2_band_widthsopt, arg3_start_indexopt, arg4_optionsopt) → {Object}

Graduates total age-cohort density and reallocates it between sexes.

Defaults are appropriate for stochastic model-generated compositions: raw sex ratios are preserved, monotonicity is disabled, and the total population of the graduated suffix is preserved by final rescaling.

Density is normalised by the mean density of the graduated suffix. huber_delta is therefore expressed relative to that mean.

Fidelity weights default to band widths. These are integration weights, not estimated inverse-variance weights for a multinomial model.

Sex-ratio allocation applies to every cohort, including the prefix. Density graduation and total rescaling apply only from start_index.

Legacy options.buffers is not used; working calculations use Float64Array.

Source:
Parameters:
Name Type Attributes Default Description
arg0_male_rates Float32Array | Float64Array | Array.<number>
arg1_female_rates Float32Array | Float64Array | Array.<number>
arg2_band_widths Float32Array | Float64Array | Array.<number> <optional>
arg3_start_index number | null <optional>
2

Negative or null disables graduation.

arg4_options Object <optional>
Name Type Attributes Default Description
baseline_sex_ratios Array.<number> | Float32Array | Float64Array <optional>
do_not_smooth boolean <optional>
false
enforce_biological_sex_ratios boolean <optional>
false

Legacy name for applying supplied bounds.

enforce_fixed_sex_ratios boolean <optional>
false
female_output Float32Array | Float64Array <optional>
huber_delta number <optional>
0.05
lambda number <optional>
20.0
male_output Float32Array | Float64Array <optional>
max_iterations number <optional>
20000
mu number <optional>
0.0
preserve_sex_ratios boolean <optional>

Defaults to true unless another ratio policy is enabled.

preserve_total boolean <optional>
true
sex_ratio_bounds Array.<Array.<number>> <optional>
tolerance number <optional>
1e-8
total_output Float32Array | Float64Array <optional>
weights Array.<number> | Float32Array | Float64Array <optional>
Returns:
Type:
Object

(static) evaluateMultinomialModel(arg0_model, arg1_covariates_obj) → {Object}

Evaluates a trained multinomial logit model against a covariates object, returning overall accuracy and a confusion matrix.

Source:
Parameters:
Name Type Description
arg0_model string | Object

JSON model object or file path to JSON model.

arg1_covariates_obj Object

{ keys, X, Y }

Returns:
Type:
Object
  • { accuracy, confusion_matrix, sample_count }

(static) generateALRRaster(arg0_output_file_path, arg1_optionsopt) → {Promise.<void>}

Generates multi-class probability rasters from a trained ALR compositional model.

Source:
Parameters:
Name Type Attributes Description
arg0_output_file_path string

Output file path prefix or base name.

arg1_options Object <optional>
Name Type Attributes Default Description
covariates_obj Object
model_obj Object | string
height number <optional>
2160
width number <optional>
4320
Returns:
Type:
Promise.<void>

(static) generateMultinomialRaster(arg0_output_file_path, arg1_optionsopt) → {Promise.<void>}

Generates raster predictions from a trained multinomial logit model. Supports argmax class maps, single-class probability surfaces, or one probability raster per class.

Source:
Parameters:
Name Type Attributes Description
arg0_output_file_path string
arg1_options Object <optional>
Name Type Attributes Default Description
class number | string <optional>

Class label for "probability" output_mode.

covariates_obj Object
format string <optional>
"int32"
formatting_parameters Array <optional>
guard_clause function <optional>

(local_index:number, rasters_obj:Object) - false skips pixel processing.

model_obj Object | string <optional>

File path or JSON object.

output_mode string <optional>
"class"

"class" | "probability" | "probabilities".

height number <optional>
2160
width number <optional>
4320
Returns:
Type:
Promise.<void>

(static) generateMultinomialRastersParallel(arg0_items, arg1_task_generator, arg2_optionsopt) → {Promise.<Array.<Object>>}

Concurrently generates a series of Multinomial Logit predicted rasters across background worker processes.

Source:
Parameters:
Name Type Attributes Description
arg0_items Array.<any>

Array of years, models, or tasks to generate.

arg1_task_generator function

(local_item: any, local_index: number) => { output_file_path, model_obj, covariates_map, options }

arg2_options Object <optional>
Name Type Attributes Default Description
concurrency number <optional>
name string <optional>
"Multinomial Logit Raster Generation"
Returns:
Type:
Promise.<Array.<Object>>

(static) generateOLSRaster(arg0_output_file_path, arg1_optionsopt) → {Promise.<void>}

Generates an OLS raster from a stack of coefficients.

Source:
Parameters:
Name Type Attributes Description
arg0_output_file_path string
arg1_options Object <optional>
Name Type Attributes Default Description
covariates_obj Object
format string <optional>
"int32"
formatting_parameters Array <optional>
guard_clause function <optional>

(local_index:number, rasters_obj:Object) - false skips pixel processing.

model_obj Object | string <optional>

File path or JSON object.

utility_format string <optional>
"int32"
height number <optional>
2160
width number <optional>
4320
Returns:
Type:
Promise.<void>

(static) generateOLSRastersParallel(arg0_items, arg1_task_generator, arg2_optionsopt) → {Promise.<Array.<Object>>}

Concurrently generates a series of OLS predicted rasters across background worker processes.

Source:
Parameters:
Name Type Attributes Description
arg0_items Array.<any>

Array of years, models, or tasks to generate.

arg1_task_generator function

(local_item: any, local_index: number) => { output_file_path, model_obj, covariates_map, options }

arg2_options Object <optional>
Name Type Attributes Default Description
concurrency number <optional>
name string <optional>
"OLS Raster Generation"
Returns:
Type:
Promise.<Array.<Object>>

(static) geomeanOLSModels(arg0_input_folder_path, arg1_ols_prefix, arg2_optionsopt) → {Promise.<{coefficients: {}, raw_coefficients: {}}>}

Geometrically average OLS models across a folder path, with base OLS prefixes.

Source:
Parameters:
Name Type Attributes Description
arg0_input_folder_path string
arg1_ols_prefix string
arg2_options Object <optional>
Name Type Attributes Description
weighting_function function <optional>

(arg0_coefficient:number) | number

Returns:
Type:
Promise.<{coefficients: {}, raw_coefficients: {}}>

(static) getClassLabel(arg0_Y, arg1_index) → {any}

Returns the class label at a given index of Y, unwrapping single-element arrays.

Source:
Parameters:
Name Type Description
arg0_Y Array
arg1_index number
Returns:
Type:
any

(static) getLogisticKernelWeight(arg0_value, arg1_start_valopt, arg2_end_valopt, arg3_optionsopt) → {number}

Computes a normalised logistic transition kernel weight w in [0, 1] over a domain [start_val, end_val]. Returns 0 for values <= start_val, 1 for values >= end_val, and an S-curve blend for intermediate values.

Source:
Parameters:
Name Type Attributes Default Description
arg0_value number
arg1_start_val number <optional>
1750
arg2_end_val number <optional>
1850
arg3_options Object <optional>
Name Type Attributes Default Description
steepness number <optional>
8
Returns:
Type:
number

(static) loadCovariateRasters(arg0_covariates_obj, arg1_optionsopt) → {Object}

Loads a set of covariate rasters, resolving function- or string-valued paths and dropping rasters that fail to load. Shared by all covariate-stacking routines.

Source:
Parameters:
Name Type Attributes Description
arg0_covariates_obj Object
arg1_options Object <optional>
Name Type Attributes Default Description
data_only boolean <optional>
false

Store .data arrays instead of rasters.

formatting_parameters Array <optional>
[]

Spread into function-valued covariates.

year number <optional>

If set, function-valued covariates receive this single argument instead.

Returns:
Type:
Object
  • { rasters_obj, valid_keys }

(static) loadMultinomialCovariates(arg0_class_file_path, arg1_optionsopt) → {Promise.<Object>}

Loads a stack of covariates for a categorical class raster for multinomial logit training. Unlike loadOLSCovariates, zero-valued class labels are meaningful and retained.

Source:
Parameters:
Name Type Attributes Description
arg0_class_file_path string

Raster whose pixel values are integer class labels.

arg1_options Object <optional>
Name Type Attributes Default Description
covariates_obj Object
class_format string <optional>
"int32"
formatting_parameters Array.<any> <optional>
nodata_value number <optional>

Class label treated as nodata and dropped.

Returns:
Type:
Promise.<Object>
  • { keys, X, Y }

(static) loadOLSCovariates(arg0_utility_file_path, arg1_optionsopt) → {Promise.<Object>}

Loads a stack of covariates for a specific utility file path for OLS training.

Source:
Parameters:
Name Type Attributes Description
arg0_utility_file_path string
arg1_options Object <optional>
Name Type Attributes Default Description
covariates_obj Object
formatting_parameters Array.<any> <optional>
utility_format string <optional>
"int32"
Returns:
Type:
Promise.<Object>

(static) loadPointMultinomialCovariates(arg0_points, arg1_year, arg2_optionsopt) → {Promise.<Object>}

Loads a stack of covariates for point-based categorical data (e.g. household survey age/sex buckets) for multinomial logit training for a specific year.

Source:
Parameters:
Name Type Attributes Description
arg0_points Array.<Object>

Array of objects with { coords: [lng, lat], target: number, year: number }

arg1_year number

The target year to load covariates and sample points for.

arg2_options Object <optional>
Name Type Attributes Description
covariates_obj Object
covariates_year number <optional>

Mapped year to override path resolution.

get_pixel_function function <optional>

Custom coordinate-to-pixel mapping function.

Returns:
Type:
Promise.<Object>
  • { keys, X, Y }

(static) loadPointOLSCovariates(arg0_points, arg1_year, arg2_optionsopt) → {Promise.<Object>}

Loads a stack of covariates for point-based data for OLS training for a specific year.

Source:
Parameters:
Name Type Attributes Description
arg0_points Array.<Object>

Array of objects with { coords: [lng, lat], target: number, year: number }

arg1_year number

The target year to load covariates and sample points for.

arg2_options Object <optional>
Name Type Attributes Description
covariates_obj Object
covariates_year number <optional>

Mapped year to override path resolution.

get_pixel_function function <optional>

Custom coordinate-to-pixel mapping function.

Returns:
Type:
Promise.<Object>

(static) multinomialLogitRegression(arg0_X, arg1_Y, arg2_optionsopt) → {Object|null}

Performs L2-regularised Multinomial Logistic Regression (softmax regression) via batch gradient descent with momentum. The first observed class is the reference class with coefficients fixed at zero for identifiability.

Source:
Parameters:
Name Type Attributes Description
arg0_X Matrix | Array
arg1_Y Matrix | Array

Nx1 matrix of integer class labels.

arg2_options Object <optional>
Name Type Attributes Default Description
debug boolean <optional>
false
lambda number <optional>
1e-3

L2 regularisation strength (ridge analogue).

learning_rate number <optional>
0.5
max_iterations number <optional>
1000
momentum number <optional>
0.9
sample_weights Array.<number> <optional>

Non-negative observation weights.

tolerance number <optional>
1e-8
Returns:
Type:
Object | null
  • { beta, classes, converged, iterations, log_likelihood }

(static) pavaDecreasing(arg0_values, arg1_weightsopt, arg2_start_indexopt, arg3_optionsopt) → {Float32Array|Array.<number>}

Enforces non-increasing monotonicity on a sequence using the weighted Pool Adjacent Violators Algorithm (PAVA). Values before arg2_start_index are preserved unconstrained.

Source:
Parameters:
Name Type Attributes Default Description
arg0_values Float32Array | Array.<number>

Array of values to smooth.

arg1_weights Float32Array | Array.<number> <optional>

Optional weights (e.g. cohort band widths).

arg2_start_index number <optional>
0

Index from which to enforce non-increasing monotonicity.

arg3_options Object <optional>
Name Type Attributes Description
buffers Object <optional>

Optional pre-allocated flat buffers for zero GC overhead.

Name Type Attributes Description
block_vals Float32Array <optional>
block_weights Float32Array <optional>
block_counts Int32Array <optional>
output Float32Array | Array.<number> <optional>

Optional target output buffer.

Returns:
Type:
Float32Array | Array.<number>

Monotonically decreasing output array.

(static) predictALRProbabilities(arg0_features_obj, arg1_model_obj) → {Object}

Computes predicted compositional class probabilities for a single feature object using a trained ALR model.

Source:
Parameters:
Name Type Description
arg0_features_obj Object

Feature mapping.

arg1_model_obj Object

Trained ALR model object with .categories, .reference_category, and .coefficients.

Returns:
Type:
Object

Mapping of category names to probabilities summing to 1.0.

(static) predictMultinomialEnsemble(arg0_features_obj, arg1_models, arg2_weightsopt) → {Object}

Predicts class probabilities from an ensemble of models using a convex combination in probability space.

Source:
Parameters:
Name Type Attributes Description
arg0_features_obj Object

Map of covariate keys to feature values.

arg1_models Array.<(Object|string)>

Array of model objects or file paths.

arg2_weights Array.<number> <optional>

Optional array of model weights.

Returns:
Type:
Object
  • Map of class labels to blended probabilities.

(static) predictMultinomialProbabilities(arg0_features_obj, arg1_model_obj) → {Object}

Predicts class probabilities for a single feature object against a trained multinomial logit model. Supports both discrete multinomial_logit models and probability-space multinomial_ensemble mixtures.

Source:
Parameters:
Name Type Description
arg0_features_obj Object

Map of covariate keys to feature values.

arg1_model_obj Object

Trained model object with .classes and .coefficients.

Returns:
Type:
Object
  • Map of class labels to probabilities.

(static) processOLSModel(arg0_model, arg1_optionsopt) → {Promise.<Object>}

Processes and adjusts OLS model coefficients against target and covariate rasters using Multiplicative Update Rules (NMF).

Source:
Parameters:
Name Type Attributes Description
arg0_model string | Object

JSON model object or file path to JSON model.

arg1_options Object <optional>
Name Type Attributes Default Description
covariates_obj Object <optional>

Map of covariate keys to functions or file paths.

debug boolean <optional>
false
output_file_path string <optional>

Path to save the adjusted model JSON.

steps Array.<any> | any <optional>

Array of steps or parameter sets (e.g., years) passed into target and covariate functions.

target string | function <optional>

File path or function returning file path for target raster.

target_format string <optional>
"float32"
Returns:
Type:
Promise.<Object>

(static) removeHighVIFFeatures(arg0_X, arg1_thresholdopt) → {Array.<Array.<number>>}

Removes high VIF features for a given matrix.

Source:
Parameters:
Name Type Attributes Default Description
arg0_X Matrix | Array
arg1_threshold number <optional>
10
Returns:
Type:
Array.<Array.<number>>

(static) ridgeRegression(arg0_X, arg1_Y, arg2_lambdaopt) → {Matrix|Array}

Performs Ridge Regression on two matrices with RMS scale stabilization and pseudo-inverse fallbacks.

Source:
Parameters:
Name Type Attributes Default Description
arg0_X Matrix | Array
arg1_Y Matrix | Array
arg2_lambda number <optional>
1e-3
Returns:
Type:
Matrix | Array

(static) softmax(arg0_logits) → {Array.<number>}

Computes a numerically-stable softmax over an array of logits.

Source:
Parameters:
Name Type Description
arg0_logits Array.<number>
Returns:
Type:
Array.<number>

(static) trainALRModel(arg0_output_file_path, arg1_covariates_obj, arg2_optionsopt) → {Promise.<(Object|null)>}

Trains an Additive Log-Ratio (ALR) regularised ridge regression model for continuous compositional targets. Bypasses gradient descent under-convergence by solving normal equations analytically.

Source:
Parameters:
Name Type Attributes Description
arg0_output_file_path string

File path to save the trained model.

arg1_covariates_obj Object

{ keys, X, Y, categories, [reference_category] }

arg2_options Object <optional>
Name Type Attributes Default Description
key string <optional>
lambda number <optional>
1e-3

Ridge penalty strength.

smoothing number <optional>
1e-6

Log-ratio epsilon smoothing.

Returns:
Type:
Promise.<(Object|null)>

(static) trainMultinomialLogitModel(arg0_output_file_path, arg1_covariates_obj, arg2_optionsopt) → {Promise.<(Object|null)>}

Trains a multinomial logit model given a fitted covariates object { X, Y, keys } and saves it to JSON. Coefficients are stored per non-reference class.

Source:
Parameters:
Name Type Attributes Description
arg0_output_file_path string
arg1_covariates_obj Object

{ keys, X, Y }

arg2_options Object <optional>
Name Type Attributes Default Description
compute_standard_errors boolean <optional>
false

Hessian-based uncertainty.

debug boolean <optional>
false
key string <optional>
lambda number <optional>
1e-3
learning_rate number <optional>
0.5
max_iterations number <optional>
1000
momentum number <optional>
0.9
tolerance number <optional>
1e-8
Returns:
Type:
Promise.<(Object|null)>

(static) trainMultinomialLogitModelsParallel(arg0_items, arg1_task_generator, arg2_optionsopt) → {Promise.<Array.<Object>>}

Concurrently trains a series of multinomial logit models across background worker processes.

Source:
Parameters:
Name Type Attributes Description
arg0_items Array.<any>

Array of tasks, years, or cohort descriptors.

arg1_task_generator function

(local_item: any, local_index: number) => { categories, covariates_map, filter_format, filter_raster_path, model_path, options, target_paths }

arg2_options Object <optional>
Name Type Attributes Default Description
concurrency number <optional>

Worker thread count.

name string <optional>
"Multinomial Logit Training"
Returns:
Type:
Promise.<Array.<Object>>

(static) trainOLSModel(arg0_output_file_path, arg1_covariates_obj, arg2_optionsopt) → {Promise.<Object>}

Trains a raster-based OLS model given a fitted covariates object { X, Y, keys }.

Source:
Parameters:
Name Type Attributes Description
arg0_output_file_path string
arg1_covariates_obj Object
arg2_options Object <optional>
Name Type Attributes Default Description
dynamic_lambda boolean <optional>
false

Condition numbers are dynamically selected if true.

lambda number <optional>
1e9
remove_high_vif_features boolean <optional>
false

Whether to remove high VIF features.

key string <optional>
weighting_function function <optional>

(arg0_coefficient:number) | number

Returns:
Type:
Promise.<Object>

(static) trainOLSModelsParallel(arg0_items, arg1_task_generator, arg2_optionsopt) → {Promise.<Array.<Object>>}

Concurrently trains a series of OLS models across background worker processes.

Source:
Parameters:
Name Type Attributes Description
arg0_items Array.<any>

Array of years, models, or tasks to train.

arg1_task_generator function

(local_item: any, local_index: number) => { output_file_path, target_file_path, target_format, covariates_map, options, points, target_year }

arg2_options Object <optional>
Name Type Attributes Default Description
concurrency number <optional>

Worker thread count.

name string <optional>
"OLS Model Training"
Returns:
Type:
Promise.<Array.<Object>>

(static) whittakerHendersonRobust(arg0_values, arg1_weightsopt, arg2_start_indexopt, arg3_optionsopt) → {Float32Array|Float64Array}

Performs Whittaker-Henderson graduation with weighted Huber fidelity, second-difference roughness, and optional soft non-increasing monotonicity.

Penalties apply only within [start_index, values.length). Values before start_index are copied without modification.

Source:
Parameters:
Name Type Attributes Default Description
arg0_values Float32Array | Float64Array | Array.<number>
arg1_weights Float32Array | Float64Array | Array.<number> <optional>
arg2_start_index number <optional>
0
arg3_options Object <optional>
Name Type Attributes Default Description
output Float32Array | Float64Array <optional>
huber_delta number <optional>
0.05
lambda number <optional>
20.0
max_iterations number <optional>
20000
min_value number <optional>
-Infinity
mu number <optional>
0.0
tolerance number <optional>
1e-8

Absolute KKT residual tolerance.

Returns:
Type:
Float32Array | Float64Array

Statistics

The namespace for all UF/Statistics utility functions, typically for static methods.

Source:

Methods

(static) _computeXT_X(arg0_X) → {Array.<Array.<number>>}

Computes the X^T * X matrix manually to save memory.

Source:
Parameters:
Name Type Description
arg0_X Array.<Array.<number>>
Returns:
Type:
Array.<Array.<number>>

(static) argmaxMultinomialClass(arg0_probabilities, arg1_classes) → {any}

Returns the class label with the highest probability.

Source:
Parameters:
Name Type Description
arg0_probabilities Object

Map of class labels to probabilities.

arg1_classes Array
Returns:
Type:
any

(static) computeMultinomialLogits(arg0_row_X, arg1_beta) → {Array.<number>}

Computes logits for a single sample against a CxK coefficient matrix. Row 0 of beta is assumed to be the zeroed reference class.

Source:
Parameters:
Name Type Description
arg0_row_X Array.<number>
arg1_beta Array.<Array.<number>>
Returns:
Type:
Array.<number>

(static) computeMultinomialStandardErrors(arg0_X, arg1_Y, arg2_result, arg3_lambdaopt) → {Object}

Computes approximate per-class standard errors from the Hessian at convergence. Uses the standard class-vs-rest approximation H_c = Σ p_ic(1-p_ic) x_i x_i^T + λI.

Source:
Parameters:
Name Type Attributes Default Description
arg0_X Array.<Array.<number>>
arg1_Y Array.<Array.<number>>
arg2_result Object

Result object from Statistics.multinomialLogitRegression.

arg3_lambda number <optional>
1e-3
Returns:
Type:
Object
  • Map of class labels to arrays of standard errors.

(static) computeVIF(arg0_X) → {Array.<number>}

Computes the VIF of a given matrix.

Source:
Parameters:
Name Type Description
arg0_X Matrix | Array
Returns:
Type:
Array.<number>

(static) conditionNumber(arg0_X, arg1_epsilonopt) → {number}

Returns the condition number of a given matrix.

Source:
Parameters:
Name Type Attributes Default Description
arg0_X Matrix | Array
arg1_epsilon number <optional>
1e-12
Returns:
Type:
number

(static) coupleAgeSexCohorts(arg0_male_rates, arg1_female_rates, arg2_band_widths, arg3_start_indexopt, arg4_optionsopt) → {Object}

Smooths age cohorts and couples sex ratios simultaneously. Enforces non-increasing monotonicity along the age dimension using weighted PAVA on total cohort population density, then allocates totals between male and female using the model's empirical sex ratio bounded within a biological plausibility envelope (Option 1).

Source:
Parameters:
Name Type Attributes Default Description
arg0_male_rates Float32Array | Array.<number>

Raw male cohort values.

arg1_female_rates Float32Array | Array.<number>

Raw female cohort values.

arg2_band_widths Float32Array | Array.<number>

Cohort duration in years (e.g. 1 for 00, 4 for 01, 5 for others).

arg3_start_index number <optional>
0

Index from which to enforce age monotonicity (defaults to 0 on annualised density).

arg4_options Object <optional>
Name Type Attributes Default Description
baseline_sex_ratios Float32Array | Array.<number> <optional>

Optional target sex-ratio curve M/F by cohort.

sex_ratio_bounds Array.<Array.<number>> <optional>

Optional min/max sex-ratio bounds by cohort.

enforce_fixed_sex_ratios boolean <optional>
false

If true, strictly forces M/F = baseline_sex_ratios.

buffers Object <optional>

Optional pre-allocated flat buffers for zero GC overhead.

female_output Float32Array <optional>

Optional target female output buffer.

male_output Float32Array <optional>

Optional target male output buffer.

total_output Float32Array <optional>

Optional target total output buffer.

Returns:
Type:
Object

Coupled smoothed cohort arrays.

(static) coupleAgeSexCohortsWhittaker(arg0_male_rates, arg1_female_rates, arg2_band_widthsopt, arg3_start_indexopt, arg4_optionsopt) → {Object}

Graduates total age-cohort density and reallocates it between sexes.

Defaults are appropriate for stochastic model-generated compositions: raw sex ratios are preserved, monotonicity is disabled, and the total population of the graduated suffix is preserved by final rescaling.

Density is normalised by the mean density of the graduated suffix. huber_delta is therefore expressed relative to that mean.

Fidelity weights default to band widths. These are integration weights, not estimated inverse-variance weights for a multinomial model.

Sex-ratio allocation applies to every cohort, including the prefix. Density graduation and total rescaling apply only from start_index.

Legacy options.buffers is not used; working calculations use Float64Array.

Source:
Parameters:
Name Type Attributes Default Description
arg0_male_rates Float32Array | Float64Array | Array.<number>
arg1_female_rates Float32Array | Float64Array | Array.<number>
arg2_band_widths Float32Array | Float64Array | Array.<number> <optional>
arg3_start_index number | null <optional>
2

Negative or null disables graduation.

arg4_options Object <optional>
Name Type Attributes Default Description
baseline_sex_ratios Array.<number> | Float32Array | Float64Array <optional>
do_not_smooth boolean <optional>
false
enforce_biological_sex_ratios boolean <optional>
false

Legacy name for applying supplied bounds.

enforce_fixed_sex_ratios boolean <optional>
false
female_output Float32Array | Float64Array <optional>
huber_delta number <optional>
0.05
lambda number <optional>
20.0
male_output Float32Array | Float64Array <optional>
max_iterations number <optional>
20000
mu number <optional>
0.0
preserve_sex_ratios boolean <optional>

Defaults to true unless another ratio policy is enabled.

preserve_total boolean <optional>
true
sex_ratio_bounds Array.<Array.<number>> <optional>
tolerance number <optional>
1e-8
total_output Float32Array | Float64Array <optional>
weights Array.<number> | Float32Array | Float64Array <optional>
Returns:
Type:
Object

(static) evaluateMultinomialModel(arg0_model, arg1_covariates_obj) → {Object}

Evaluates a trained multinomial logit model against a covariates object, returning overall accuracy and a confusion matrix.

Source:
Parameters:
Name Type Description
arg0_model string | Object

JSON model object or file path to JSON model.

arg1_covariates_obj Object

{ keys, X, Y }

Returns:
Type:
Object
  • { accuracy, confusion_matrix, sample_count }

(static) generateALRRaster(arg0_output_file_path, arg1_optionsopt) → {Promise.<void>}

Generates multi-class probability rasters from a trained ALR compositional model.

Source:
Parameters:
Name Type Attributes Description
arg0_output_file_path string

Output file path prefix or base name.

arg1_options Object <optional>
Name Type Attributes Default Description
covariates_obj Object
model_obj Object | string
height number <optional>
2160
width number <optional>
4320
Returns:
Type:
Promise.<void>

(static) generateMultinomialRaster(arg0_output_file_path, arg1_optionsopt) → {Promise.<void>}

Generates raster predictions from a trained multinomial logit model. Supports argmax class maps, single-class probability surfaces, or one probability raster per class.

Source:
Parameters:
Name Type Attributes Description
arg0_output_file_path string
arg1_options Object <optional>
Name Type Attributes Default Description
class number | string <optional>

Class label for "probability" output_mode.

covariates_obj Object
format string <optional>
"int32"
formatting_parameters Array <optional>
guard_clause function <optional>

(local_index:number, rasters_obj:Object) - false skips pixel processing.

model_obj Object | string <optional>

File path or JSON object.

output_mode string <optional>
"class"

"class" | "probability" | "probabilities".

height number <optional>
2160
width number <optional>
4320
Returns:
Type:
Promise.<void>

(static) generateMultinomialRastersParallel(arg0_items, arg1_task_generator, arg2_optionsopt) → {Promise.<Array.<Object>>}

Concurrently generates a series of Multinomial Logit predicted rasters across background worker processes.

Source:
Parameters:
Name Type Attributes Description
arg0_items Array.<any>

Array of years, models, or tasks to generate.

arg1_task_generator function

(local_item: any, local_index: number) => { output_file_path, model_obj, covariates_map, options }

arg2_options Object <optional>
Name Type Attributes Default Description
concurrency number <optional>
name string <optional>
"Multinomial Logit Raster Generation"
Returns:
Type:
Promise.<Array.<Object>>

(static) generateOLSRaster(arg0_output_file_path, arg1_optionsopt) → {Promise.<void>}

Generates an OLS raster from a stack of coefficients.

Source:
Parameters:
Name Type Attributes Description
arg0_output_file_path string
arg1_options Object <optional>
Name Type Attributes Default Description
covariates_obj Object
format string <optional>
"int32"
formatting_parameters Array <optional>
guard_clause function <optional>

(local_index:number, rasters_obj:Object) - false skips pixel processing.

model_obj Object | string <optional>

File path or JSON object.

utility_format string <optional>
"int32"
height number <optional>
2160
width number <optional>
4320
Returns:
Type:
Promise.<void>

(static) generateOLSRastersParallel(arg0_items, arg1_task_generator, arg2_optionsopt) → {Promise.<Array.<Object>>}

Concurrently generates a series of OLS predicted rasters across background worker processes.

Source:
Parameters:
Name Type Attributes Description
arg0_items Array.<any>

Array of years, models, or tasks to generate.

arg1_task_generator function

(local_item: any, local_index: number) => { output_file_path, model_obj, covariates_map, options }

arg2_options Object <optional>
Name Type Attributes Default Description
concurrency number <optional>
name string <optional>
"OLS Raster Generation"
Returns:
Type:
Promise.<Array.<Object>>

(static) geomeanOLSModels(arg0_input_folder_path, arg1_ols_prefix, arg2_optionsopt) → {Promise.<{coefficients: {}, raw_coefficients: {}}>}

Geometrically average OLS models across a folder path, with base OLS prefixes.

Source:
Parameters:
Name Type Attributes Description
arg0_input_folder_path string
arg1_ols_prefix string
arg2_options Object <optional>
Name Type Attributes Description
weighting_function function <optional>

(arg0_coefficient:number) | number

Returns:
Type:
Promise.<{coefficients: {}, raw_coefficients: {}}>

(static) getClassLabel(arg0_Y, arg1_index) → {any}

Returns the class label at a given index of Y, unwrapping single-element arrays.

Source:
Parameters:
Name Type Description
arg0_Y Array
arg1_index number
Returns:
Type:
any

(static) getLogisticKernelWeight(arg0_value, arg1_start_valopt, arg2_end_valopt, arg3_optionsopt) → {number}

Computes a normalised logistic transition kernel weight w in [0, 1] over a domain [start_val, end_val]. Returns 0 for values <= start_val, 1 for values >= end_val, and an S-curve blend for intermediate values.

Source:
Parameters:
Name Type Attributes Default Description
arg0_value number
arg1_start_val number <optional>
1750
arg2_end_val number <optional>
1850
arg3_options Object <optional>
Name Type Attributes Default Description
steepness number <optional>
8
Returns:
Type:
number

(static) loadCovariateRasters(arg0_covariates_obj, arg1_optionsopt) → {Object}

Loads a set of covariate rasters, resolving function- or string-valued paths and dropping rasters that fail to load. Shared by all covariate-stacking routines.

Source:
Parameters:
Name Type Attributes Description
arg0_covariates_obj Object
arg1_options Object <optional>
Name Type Attributes Default Description
data_only boolean <optional>
false

Store .data arrays instead of rasters.

formatting_parameters Array <optional>
[]

Spread into function-valued covariates.

year number <optional>

If set, function-valued covariates receive this single argument instead.

Returns:
Type:
Object
  • { rasters_obj, valid_keys }

(static) loadMultinomialCovariates(arg0_class_file_path, arg1_optionsopt) → {Promise.<Object>}

Loads a stack of covariates for a categorical class raster for multinomial logit training. Unlike loadOLSCovariates, zero-valued class labels are meaningful and retained.

Source:
Parameters:
Name Type Attributes Description
arg0_class_file_path string

Raster whose pixel values are integer class labels.

arg1_options Object <optional>
Name Type Attributes Default Description
covariates_obj Object
class_format string <optional>
"int32"
formatting_parameters Array.<any> <optional>
nodata_value number <optional>

Class label treated as nodata and dropped.

Returns:
Type:
Promise.<Object>
  • { keys, X, Y }

(static) loadOLSCovariates(arg0_utility_file_path, arg1_optionsopt) → {Promise.<Object>}

Loads a stack of covariates for a specific utility file path for OLS training.

Source:
Parameters:
Name Type Attributes Description
arg0_utility_file_path string
arg1_options Object <optional>
Name Type Attributes Default Description
covariates_obj Object
formatting_parameters Array.<any> <optional>
utility_format string <optional>
"int32"
Returns:
Type:
Promise.<Object>

(static) loadPointMultinomialCovariates(arg0_points, arg1_year, arg2_optionsopt) → {Promise.<Object>}

Loads a stack of covariates for point-based categorical data (e.g. household survey age/sex buckets) for multinomial logit training for a specific year.

Source:
Parameters:
Name Type Attributes Description
arg0_points Array.<Object>

Array of objects with { coords: [lng, lat], target: number, year: number }

arg1_year number

The target year to load covariates and sample points for.

arg2_options Object <optional>
Name Type Attributes Description
covariates_obj Object
covariates_year number <optional>

Mapped year to override path resolution.

get_pixel_function function <optional>

Custom coordinate-to-pixel mapping function.

Returns:
Type:
Promise.<Object>
  • { keys, X, Y }

(static) loadPointOLSCovariates(arg0_points, arg1_year, arg2_optionsopt) → {Promise.<Object>}

Loads a stack of covariates for point-based data for OLS training for a specific year.

Source:
Parameters:
Name Type Attributes Description
arg0_points Array.<Object>

Array of objects with { coords: [lng, lat], target: number, year: number }

arg1_year number

The target year to load covariates and sample points for.

arg2_options Object <optional>
Name Type Attributes Description
covariates_obj Object
covariates_year number <optional>

Mapped year to override path resolution.

get_pixel_function function <optional>

Custom coordinate-to-pixel mapping function.

Returns:
Type:
Promise.<Object>

(static) multinomialLogitRegression(arg0_X, arg1_Y, arg2_optionsopt) → {Object|null}

Performs L2-regularised Multinomial Logistic Regression (softmax regression) via batch gradient descent with momentum. The first observed class is the reference class with coefficients fixed at zero for identifiability.

Source:
Parameters:
Name Type Attributes Description
arg0_X Matrix | Array
arg1_Y Matrix | Array

Nx1 matrix of integer class labels.

arg2_options Object <optional>
Name Type Attributes Default Description
debug boolean <optional>
false
lambda number <optional>
1e-3

L2 regularisation strength (ridge analogue).

learning_rate number <optional>
0.5
max_iterations number <optional>
1000
momentum number <optional>
0.9
sample_weights Array.<number> <optional>

Non-negative observation weights.

tolerance number <optional>
1e-8
Returns:
Type:
Object | null
  • { beta, classes, converged, iterations, log_likelihood }

(static) pavaDecreasing(arg0_values, arg1_weightsopt, arg2_start_indexopt, arg3_optionsopt) → {Float32Array|Array.<number>}

Enforces non-increasing monotonicity on a sequence using the weighted Pool Adjacent Violators Algorithm (PAVA). Values before arg2_start_index are preserved unconstrained.

Source:
Parameters:
Name Type Attributes Default Description
arg0_values Float32Array | Array.<number>

Array of values to smooth.

arg1_weights Float32Array | Array.<number> <optional>

Optional weights (e.g. cohort band widths).

arg2_start_index number <optional>
0

Index from which to enforce non-increasing monotonicity.

arg3_options Object <optional>
Name Type Attributes Description
buffers Object <optional>

Optional pre-allocated flat buffers for zero GC overhead.

Name Type Attributes Description
block_vals Float32Array <optional>
block_weights Float32Array <optional>
block_counts Int32Array <optional>
output Float32Array | Array.<number> <optional>

Optional target output buffer.

Returns:
Type:
Float32Array | Array.<number>

Monotonically decreasing output array.

(static) predictALRProbabilities(arg0_features_obj, arg1_model_obj) → {Object}

Computes predicted compositional class probabilities for a single feature object using a trained ALR model.

Source:
Parameters:
Name Type Description
arg0_features_obj Object

Feature mapping.

arg1_model_obj Object

Trained ALR model object with .categories, .reference_category, and .coefficients.

Returns:
Type:
Object

Mapping of category names to probabilities summing to 1.0.

(static) predictMultinomialEnsemble(arg0_features_obj, arg1_models, arg2_weightsopt) → {Object}

Predicts class probabilities from an ensemble of models using a convex combination in probability space.

Source:
Parameters:
Name Type Attributes Description
arg0_features_obj Object

Map of covariate keys to feature values.

arg1_models Array.<(Object|string)>

Array of model objects or file paths.

arg2_weights Array.<number> <optional>

Optional array of model weights.

Returns:
Type:
Object
  • Map of class labels to blended probabilities.

(static) predictMultinomialProbabilities(arg0_features_obj, arg1_model_obj) → {Object}

Predicts class probabilities for a single feature object against a trained multinomial logit model. Supports both discrete multinomial_logit models and probability-space multinomial_ensemble mixtures.

Source:
Parameters:
Name Type Description
arg0_features_obj Object

Map of covariate keys to feature values.

arg1_model_obj Object

Trained model object with .classes and .coefficients.

Returns:
Type:
Object
  • Map of class labels to probabilities.

(static) processOLSModel(arg0_model, arg1_optionsopt) → {Promise.<Object>}

Processes and adjusts OLS model coefficients against target and covariate rasters using Multiplicative Update Rules (NMF).

Source:
Parameters:
Name Type Attributes Description
arg0_model string | Object

JSON model object or file path to JSON model.

arg1_options Object <optional>
Name Type Attributes Default Description
covariates_obj Object <optional>

Map of covariate keys to functions or file paths.

debug boolean <optional>
false
output_file_path string <optional>

Path to save the adjusted model JSON.

steps Array.<any> | any <optional>

Array of steps or parameter sets (e.g., years) passed into target and covariate functions.

target string | function <optional>

File path or function returning file path for target raster.

target_format string <optional>
"float32"
Returns:
Type:
Promise.<Object>

(static) removeHighVIFFeatures(arg0_X, arg1_thresholdopt) → {Array.<Array.<number>>}

Removes high VIF features for a given matrix.

Source:
Parameters:
Name Type Attributes Default Description
arg0_X Matrix | Array
arg1_threshold number <optional>
10
Returns:
Type:
Array.<Array.<number>>

(static) ridgeRegression(arg0_X, arg1_Y, arg2_lambdaopt) → {Matrix|Array}

Performs Ridge Regression on two matrices with RMS scale stabilization and pseudo-inverse fallbacks.

Source:
Parameters:
Name Type Attributes Default Description
arg0_X Matrix | Array
arg1_Y Matrix | Array
arg2_lambda number <optional>
1e-3
Returns:
Type:
Matrix | Array

(static) softmax(arg0_logits) → {Array.<number>}

Computes a numerically-stable softmax over an array of logits.

Source:
Parameters:
Name Type Description
arg0_logits Array.<number>
Returns:
Type:
Array.<number>

(static) trainALRModel(arg0_output_file_path, arg1_covariates_obj, arg2_optionsopt) → {Promise.<(Object|null)>}

Trains an Additive Log-Ratio (ALR) regularised ridge regression model for continuous compositional targets. Bypasses gradient descent under-convergence by solving normal equations analytically.

Source:
Parameters:
Name Type Attributes Description
arg0_output_file_path string

File path to save the trained model.

arg1_covariates_obj Object

{ keys, X, Y, categories, [reference_category] }

arg2_options Object <optional>
Name Type Attributes Default Description
key string <optional>
lambda number <optional>
1e-3

Ridge penalty strength.

smoothing number <optional>
1e-6

Log-ratio epsilon smoothing.

Returns:
Type:
Promise.<(Object|null)>

(static) trainMultinomialLogitModel(arg0_output_file_path, arg1_covariates_obj, arg2_optionsopt) → {Promise.<(Object|null)>}

Trains a multinomial logit model given a fitted covariates object { X, Y, keys } and saves it to JSON. Coefficients are stored per non-reference class.

Source:
Parameters:
Name Type Attributes Description
arg0_output_file_path string
arg1_covariates_obj Object

{ keys, X, Y }

arg2_options Object <optional>
Name Type Attributes Default Description
compute_standard_errors boolean <optional>
false

Hessian-based uncertainty.

debug boolean <optional>
false
key string <optional>
lambda number <optional>
1e-3
learning_rate number <optional>
0.5
max_iterations number <optional>
1000
momentum number <optional>
0.9
tolerance number <optional>
1e-8
Returns:
Type:
Promise.<(Object|null)>

(static) trainMultinomialLogitModelsParallel(arg0_items, arg1_task_generator, arg2_optionsopt) → {Promise.<Array.<Object>>}

Concurrently trains a series of multinomial logit models across background worker processes.

Source:
Parameters:
Name Type Attributes Description
arg0_items Array.<any>

Array of tasks, years, or cohort descriptors.

arg1_task_generator function

(local_item: any, local_index: number) => { categories, covariates_map, filter_format, filter_raster_path, model_path, options, target_paths }

arg2_options Object <optional>
Name Type Attributes Default Description
concurrency number <optional>

Worker thread count.

name string <optional>
"Multinomial Logit Training"
Returns:
Type:
Promise.<Array.<Object>>

(static) trainOLSModel(arg0_output_file_path, arg1_covariates_obj, arg2_optionsopt) → {Promise.<Object>}

Trains a raster-based OLS model given a fitted covariates object { X, Y, keys }.

Source:
Parameters:
Name Type Attributes Description
arg0_output_file_path string
arg1_covariates_obj Object
arg2_options Object <optional>
Name Type Attributes Default Description
dynamic_lambda boolean <optional>
false

Condition numbers are dynamically selected if true.

lambda number <optional>
1e9
remove_high_vif_features boolean <optional>
false

Whether to remove high VIF features.

key string <optional>
weighting_function function <optional>

(arg0_coefficient:number) | number

Returns:
Type:
Promise.<Object>

(static) trainOLSModelsParallel(arg0_items, arg1_task_generator, arg2_optionsopt) → {Promise.<Array.<Object>>}

Concurrently trains a series of OLS models across background worker processes.

Source:
Parameters:
Name Type Attributes Description
arg0_items Array.<any>

Array of years, models, or tasks to train.

arg1_task_generator function

(local_item: any, local_index: number) => { output_file_path, target_file_path, target_format, covariates_map, options, points, target_year }

arg2_options Object <optional>
Name Type Attributes Default Description
concurrency number <optional>

Worker thread count.

name string <optional>
"OLS Model Training"
Returns:
Type:
Promise.<Array.<Object>>

(static) whittakerHendersonRobust(arg0_values, arg1_weightsopt, arg2_start_indexopt, arg3_optionsopt) → {Float32Array|Float64Array}

Performs Whittaker-Henderson graduation with weighted Huber fidelity, second-difference roughness, and optional soft non-increasing monotonicity.

Penalties apply only within [start_index, values.length). Values before start_index are copied without modification.

Source:
Parameters:
Name Type Attributes Default Description
arg0_values Float32Array | Float64Array | Array.<number>
arg1_weights Float32Array | Float64Array | Array.<number> <optional>
arg2_start_index number <optional>
0
arg3_options Object <optional>
Name Type Attributes Default Description
output Float32Array | Float64Array <optional>
huber_delta number <optional>
0.05
lambda number <optional>
20.0
max_iterations number <optional>
20000
min_value number <optional>
-Infinity
mu number <optional>
0.0
tolerance number <optional>
1e-8

Absolute KKT residual tolerance.

Returns:
Type:
Float32Array | Float64Array

Statistics

The namespace for all UF/Statistics utility functions, typically for static methods.

Source:

Methods

(static) _computeXT_X(arg0_X) → {Array.<Array.<number>>}

Computes the X^T * X matrix manually to save memory.

Source:
Parameters:
Name Type Description
arg0_X Array.<Array.<number>>
Returns:
Type:
Array.<Array.<number>>

(static) argmaxMultinomialClass(arg0_probabilities, arg1_classes) → {any}

Returns the class label with the highest probability.

Source:
Parameters:
Name Type Description
arg0_probabilities Object

Map of class labels to probabilities.

arg1_classes Array
Returns:
Type:
any

(static) computeMultinomialLogits(arg0_row_X, arg1_beta) → {Array.<number>}

Computes logits for a single sample against a CxK coefficient matrix. Row 0 of beta is assumed to be the zeroed reference class.

Source:
Parameters:
Name Type Description
arg0_row_X Array.<number>
arg1_beta Array.<Array.<number>>
Returns:
Type:
Array.<number>

(static) computeMultinomialStandardErrors(arg0_X, arg1_Y, arg2_result, arg3_lambdaopt) → {Object}

Computes approximate per-class standard errors from the Hessian at convergence. Uses the standard class-vs-rest approximation H_c = Σ p_ic(1-p_ic) x_i x_i^T + λI.

Source:
Parameters:
Name Type Attributes Default Description
arg0_X Array.<Array.<number>>
arg1_Y Array.<Array.<number>>
arg2_result Object

Result object from Statistics.multinomialLogitRegression.

arg3_lambda number <optional>
1e-3
Returns:
Type:
Object
  • Map of class labels to arrays of standard errors.

(static) computeVIF(arg0_X) → {Array.<number>}

Computes the VIF of a given matrix.

Source:
Parameters:
Name Type Description
arg0_X Matrix | Array
Returns:
Type:
Array.<number>

(static) conditionNumber(arg0_X, arg1_epsilonopt) → {number}

Returns the condition number of a given matrix.

Source:
Parameters:
Name Type Attributes Default Description
arg0_X Matrix | Array
arg1_epsilon number <optional>
1e-12
Returns:
Type:
number

(static) coupleAgeSexCohorts(arg0_male_rates, arg1_female_rates, arg2_band_widths, arg3_start_indexopt, arg4_optionsopt) → {Object}

Smooths age cohorts and couples sex ratios simultaneously. Enforces non-increasing monotonicity along the age dimension using weighted PAVA on total cohort population density, then allocates totals between male and female using the model's empirical sex ratio bounded within a biological plausibility envelope (Option 1).

Source:
Parameters:
Name Type Attributes Default Description
arg0_male_rates Float32Array | Array.<number>

Raw male cohort values.

arg1_female_rates Float32Array | Array.<number>

Raw female cohort values.

arg2_band_widths Float32Array | Array.<number>

Cohort duration in years (e.g. 1 for 00, 4 for 01, 5 for others).

arg3_start_index number <optional>
0

Index from which to enforce age monotonicity (defaults to 0 on annualised density).

arg4_options Object <optional>
Name Type Attributes Default Description
baseline_sex_ratios Float32Array | Array.<number> <optional>

Optional target sex-ratio curve M/F by cohort.

sex_ratio_bounds Array.<Array.<number>> <optional>

Optional min/max sex-ratio bounds by cohort.

enforce_fixed_sex_ratios boolean <optional>
false

If true, strictly forces M/F = baseline_sex_ratios.

buffers Object <optional>

Optional pre-allocated flat buffers for zero GC overhead.

female_output Float32Array <optional>

Optional target female output buffer.

male_output Float32Array <optional>

Optional target male output buffer.

total_output Float32Array <optional>

Optional target total output buffer.

Returns:
Type:
Object

Coupled smoothed cohort arrays.

(static) coupleAgeSexCohortsWhittaker(arg0_male_rates, arg1_female_rates, arg2_band_widthsopt, arg3_start_indexopt, arg4_optionsopt) → {Object}

Graduates total age-cohort density and reallocates it between sexes.

Defaults are appropriate for stochastic model-generated compositions: raw sex ratios are preserved, monotonicity is disabled, and the total population of the graduated suffix is preserved by final rescaling.

Density is normalised by the mean density of the graduated suffix. huber_delta is therefore expressed relative to that mean.

Fidelity weights default to band widths. These are integration weights, not estimated inverse-variance weights for a multinomial model.

Sex-ratio allocation applies to every cohort, including the prefix. Density graduation and total rescaling apply only from start_index.

Legacy options.buffers is not used; working calculations use Float64Array.

Source:
Parameters:
Name Type Attributes Default Description
arg0_male_rates Float32Array | Float64Array | Array.<number>
arg1_female_rates Float32Array | Float64Array | Array.<number>
arg2_band_widths Float32Array | Float64Array | Array.<number> <optional>
arg3_start_index number | null <optional>
2

Negative or null disables graduation.

arg4_options Object <optional>
Name Type Attributes Default Description
baseline_sex_ratios Array.<number> | Float32Array | Float64Array <optional>
do_not_smooth boolean <optional>
false
enforce_biological_sex_ratios boolean <optional>
false

Legacy name for applying supplied bounds.

enforce_fixed_sex_ratios boolean <optional>
false
female_output Float32Array | Float64Array <optional>
huber_delta number <optional>
0.05
lambda number <optional>
20.0
male_output Float32Array | Float64Array <optional>
max_iterations number <optional>
20000
mu number <optional>
0.0
preserve_sex_ratios boolean <optional>

Defaults to true unless another ratio policy is enabled.

preserve_total boolean <optional>
true
sex_ratio_bounds Array.<Array.<number>> <optional>
tolerance number <optional>
1e-8
total_output Float32Array | Float64Array <optional>
weights Array.<number> | Float32Array | Float64Array <optional>
Returns:
Type:
Object

(static) evaluateMultinomialModel(arg0_model, arg1_covariates_obj) → {Object}

Evaluates a trained multinomial logit model against a covariates object, returning overall accuracy and a confusion matrix.

Source:
Parameters:
Name Type Description
arg0_model string | Object

JSON model object or file path to JSON model.

arg1_covariates_obj Object

{ keys, X, Y }

Returns:
Type:
Object
  • { accuracy, confusion_matrix, sample_count }

(static) generateALRRaster(arg0_output_file_path, arg1_optionsopt) → {Promise.<void>}

Generates multi-class probability rasters from a trained ALR compositional model.

Source:
Parameters:
Name Type Attributes Description
arg0_output_file_path string

Output file path prefix or base name.

arg1_options Object <optional>
Name Type Attributes Default Description
covariates_obj Object
model_obj Object | string
height number <optional>
2160
width number <optional>
4320
Returns:
Type:
Promise.<void>

(static) generateMultinomialRaster(arg0_output_file_path, arg1_optionsopt) → {Promise.<void>}

Generates raster predictions from a trained multinomial logit model. Supports argmax class maps, single-class probability surfaces, or one probability raster per class.

Source:
Parameters:
Name Type Attributes Description
arg0_output_file_path string
arg1_options Object <optional>
Name Type Attributes Default Description
class number | string <optional>

Class label for "probability" output_mode.

covariates_obj Object
format string <optional>
"int32"
formatting_parameters Array <optional>
guard_clause function <optional>

(local_index:number, rasters_obj:Object) - false skips pixel processing.

model_obj Object | string <optional>

File path or JSON object.

output_mode string <optional>
"class"

"class" | "probability" | "probabilities".

height number <optional>
2160
width number <optional>
4320
Returns:
Type:
Promise.<void>

(static) generateMultinomialRastersParallel(arg0_items, arg1_task_generator, arg2_optionsopt) → {Promise.<Array.<Object>>}

Concurrently generates a series of Multinomial Logit predicted rasters across background worker processes.

Source:
Parameters:
Name Type Attributes Description
arg0_items Array.<any>

Array of years, models, or tasks to generate.

arg1_task_generator function

(local_item: any, local_index: number) => { output_file_path, model_obj, covariates_map, options }

arg2_options Object <optional>
Name Type Attributes Default Description
concurrency number <optional>
name string <optional>
"Multinomial Logit Raster Generation"
Returns:
Type:
Promise.<Array.<Object>>

(static) generateOLSRaster(arg0_output_file_path, arg1_optionsopt) → {Promise.<void>}

Generates an OLS raster from a stack of coefficients.

Source:
Parameters:
Name Type Attributes Description
arg0_output_file_path string
arg1_options Object <optional>
Name Type Attributes Default Description
covariates_obj Object
format string <optional>
"int32"
formatting_parameters Array <optional>
guard_clause function <optional>

(local_index:number, rasters_obj:Object) - false skips pixel processing.

model_obj Object | string <optional>

File path or JSON object.

utility_format string <optional>
"int32"
height number <optional>
2160
width number <optional>
4320
Returns:
Type:
Promise.<void>

(static) generateOLSRastersParallel(arg0_items, arg1_task_generator, arg2_optionsopt) → {Promise.<Array.<Object>>}

Concurrently generates a series of OLS predicted rasters across background worker processes.

Source:
Parameters:
Name Type Attributes Description
arg0_items Array.<any>

Array of years, models, or tasks to generate.

arg1_task_generator function

(local_item: any, local_index: number) => { output_file_path, model_obj, covariates_map, options }

arg2_options Object <optional>
Name Type Attributes Default Description
concurrency number <optional>
name string <optional>
"OLS Raster Generation"
Returns:
Type:
Promise.<Array.<Object>>

(static) geomeanOLSModels(arg0_input_folder_path, arg1_ols_prefix, arg2_optionsopt) → {Promise.<{coefficients: {}, raw_coefficients: {}}>}

Geometrically average OLS models across a folder path, with base OLS prefixes.

Source:
Parameters:
Name Type Attributes Description
arg0_input_folder_path string
arg1_ols_prefix string
arg2_options Object <optional>
Name Type Attributes Description
weighting_function function <optional>

(arg0_coefficient:number) | number

Returns:
Type:
Promise.<{coefficients: {}, raw_coefficients: {}}>

(static) getClassLabel(arg0_Y, arg1_index) → {any}

Returns the class label at a given index of Y, unwrapping single-element arrays.

Source:
Parameters:
Name Type Description
arg0_Y Array
arg1_index number
Returns:
Type:
any

(static) getLogisticKernelWeight(arg0_value, arg1_start_valopt, arg2_end_valopt, arg3_optionsopt) → {number}

Computes a normalised logistic transition kernel weight w in [0, 1] over a domain [start_val, end_val]. Returns 0 for values <= start_val, 1 for values >= end_val, and an S-curve blend for intermediate values.

Source:
Parameters:
Name Type Attributes Default Description
arg0_value number
arg1_start_val number <optional>
1750
arg2_end_val number <optional>
1850
arg3_options Object <optional>
Name Type Attributes Default Description
steepness number <optional>
8
Returns:
Type:
number

(static) loadCovariateRasters(arg0_covariates_obj, arg1_optionsopt) → {Object}

Loads a set of covariate rasters, resolving function- or string-valued paths and dropping rasters that fail to load. Shared by all covariate-stacking routines.

Source:
Parameters:
Name Type Attributes Description
arg0_covariates_obj Object
arg1_options Object <optional>
Name Type Attributes Default Description
data_only boolean <optional>
false

Store .data arrays instead of rasters.

formatting_parameters Array <optional>
[]

Spread into function-valued covariates.

year number <optional>

If set, function-valued covariates receive this single argument instead.

Returns:
Type:
Object
  • { rasters_obj, valid_keys }

(static) loadMultinomialCovariates(arg0_class_file_path, arg1_optionsopt) → {Promise.<Object>}

Loads a stack of covariates for a categorical class raster for multinomial logit training. Unlike loadOLSCovariates, zero-valued class labels are meaningful and retained.

Source:
Parameters:
Name Type Attributes Description
arg0_class_file_path string

Raster whose pixel values are integer class labels.

arg1_options Object <optional>
Name Type Attributes Default Description
covariates_obj Object
class_format string <optional>
"int32"
formatting_parameters Array.<any> <optional>
nodata_value number <optional>

Class label treated as nodata and dropped.

Returns:
Type:
Promise.<Object>
  • { keys, X, Y }

(static) loadOLSCovariates(arg0_utility_file_path, arg1_optionsopt) → {Promise.<Object>}

Loads a stack of covariates for a specific utility file path for OLS training.

Source:
Parameters:
Name Type Attributes Description
arg0_utility_file_path string
arg1_options Object <optional>
Name Type Attributes Default Description
covariates_obj Object
formatting_parameters Array.<any> <optional>
utility_format string <optional>
"int32"
Returns:
Type:
Promise.<Object>

(static) loadPointMultinomialCovariates(arg0_points, arg1_year, arg2_optionsopt) → {Promise.<Object>}

Loads a stack of covariates for point-based categorical data (e.g. household survey age/sex buckets) for multinomial logit training for a specific year.

Source:
Parameters:
Name Type Attributes Description
arg0_points Array.<Object>

Array of objects with { coords: [lng, lat], target: number, year: number }

arg1_year number

The target year to load covariates and sample points for.

arg2_options Object <optional>
Name Type Attributes Description
covariates_obj Object
covariates_year number <optional>

Mapped year to override path resolution.

get_pixel_function function <optional>

Custom coordinate-to-pixel mapping function.

Returns:
Type:
Promise.<Object>
  • { keys, X, Y }

(static) loadPointOLSCovariates(arg0_points, arg1_year, arg2_optionsopt) → {Promise.<Object>}

Loads a stack of covariates for point-based data for OLS training for a specific year.

Source:
Parameters:
Name Type Attributes Description
arg0_points Array.<Object>

Array of objects with { coords: [lng, lat], target: number, year: number }

arg1_year number

The target year to load covariates and sample points for.

arg2_options Object <optional>
Name Type Attributes Description
covariates_obj Object
covariates_year number <optional>

Mapped year to override path resolution.

get_pixel_function function <optional>

Custom coordinate-to-pixel mapping function.

Returns:
Type:
Promise.<Object>

(static) multinomialLogitRegression(arg0_X, arg1_Y, arg2_optionsopt) → {Object|null}

Performs L2-regularised Multinomial Logistic Regression (softmax regression) via batch gradient descent with momentum. The first observed class is the reference class with coefficients fixed at zero for identifiability.

Source:
Parameters:
Name Type Attributes Description
arg0_X Matrix | Array
arg1_Y Matrix | Array

Nx1 matrix of integer class labels.

arg2_options Object <optional>
Name Type Attributes Default Description
debug boolean <optional>
false
lambda number <optional>
1e-3

L2 regularisation strength (ridge analogue).

learning_rate number <optional>
0.5
max_iterations number <optional>
1000
momentum number <optional>
0.9
sample_weights Array.<number> <optional>

Non-negative observation weights.

tolerance number <optional>
1e-8
Returns:
Type:
Object | null
  • { beta, classes, converged, iterations, log_likelihood }

(static) pavaDecreasing(arg0_values, arg1_weightsopt, arg2_start_indexopt, arg3_optionsopt) → {Float32Array|Array.<number>}

Enforces non-increasing monotonicity on a sequence using the weighted Pool Adjacent Violators Algorithm (PAVA). Values before arg2_start_index are preserved unconstrained.

Source:
Parameters:
Name Type Attributes Default Description
arg0_values Float32Array | Array.<number>

Array of values to smooth.

arg1_weights Float32Array | Array.<number> <optional>

Optional weights (e.g. cohort band widths).

arg2_start_index number <optional>
0

Index from which to enforce non-increasing monotonicity.

arg3_options Object <optional>
Name Type Attributes Description
buffers Object <optional>

Optional pre-allocated flat buffers for zero GC overhead.

Name Type Attributes Description
block_vals Float32Array <optional>
block_weights Float32Array <optional>
block_counts Int32Array <optional>
output Float32Array | Array.<number> <optional>

Optional target output buffer.

Returns:
Type:
Float32Array | Array.<number>

Monotonically decreasing output array.

(static) predictALRProbabilities(arg0_features_obj, arg1_model_obj) → {Object}

Computes predicted compositional class probabilities for a single feature object using a trained ALR model.

Source:
Parameters:
Name Type Description
arg0_features_obj Object

Feature mapping.

arg1_model_obj Object

Trained ALR model object with .categories, .reference_category, and .coefficients.

Returns:
Type:
Object

Mapping of category names to probabilities summing to 1.0.

(static) predictMultinomialEnsemble(arg0_features_obj, arg1_models, arg2_weightsopt) → {Object}

Predicts class probabilities from an ensemble of models using a convex combination in probability space.

Source:
Parameters:
Name Type Attributes Description
arg0_features_obj Object

Map of covariate keys to feature values.

arg1_models Array.<(Object|string)>

Array of model objects or file paths.

arg2_weights Array.<number> <optional>

Optional array of model weights.

Returns:
Type:
Object
  • Map of class labels to blended probabilities.

(static) predictMultinomialProbabilities(arg0_features_obj, arg1_model_obj) → {Object}

Predicts class probabilities for a single feature object against a trained multinomial logit model. Supports both discrete multinomial_logit models and probability-space multinomial_ensemble mixtures.

Source:
Parameters:
Name Type Description
arg0_features_obj Object

Map of covariate keys to feature values.

arg1_model_obj Object

Trained model object with .classes and .coefficients.

Returns:
Type:
Object
  • Map of class labels to probabilities.

(static) processOLSModel(arg0_model, arg1_optionsopt) → {Promise.<Object>}

Processes and adjusts OLS model coefficients against target and covariate rasters using Multiplicative Update Rules (NMF).

Source:
Parameters:
Name Type Attributes Description
arg0_model string | Object

JSON model object or file path to JSON model.

arg1_options Object <optional>
Name Type Attributes Default Description
covariates_obj Object <optional>

Map of covariate keys to functions or file paths.

debug boolean <optional>
false
output_file_path string <optional>

Path to save the adjusted model JSON.

steps Array.<any> | any <optional>

Array of steps or parameter sets (e.g., years) passed into target and covariate functions.

target string | function <optional>

File path or function returning file path for target raster.

target_format string <optional>
"float32"
Returns:
Type:
Promise.<Object>

(static) removeHighVIFFeatures(arg0_X, arg1_thresholdopt) → {Array.<Array.<number>>}

Removes high VIF features for a given matrix.

Source:
Parameters:
Name Type Attributes Default Description
arg0_X Matrix | Array
arg1_threshold number <optional>
10
Returns:
Type:
Array.<Array.<number>>

(static) ridgeRegression(arg0_X, arg1_Y, arg2_lambdaopt) → {Matrix|Array}

Performs Ridge Regression on two matrices with RMS scale stabilization and pseudo-inverse fallbacks.

Source:
Parameters:
Name Type Attributes Default Description
arg0_X Matrix | Array
arg1_Y Matrix | Array
arg2_lambda number <optional>
1e-3
Returns:
Type:
Matrix | Array

(static) softmax(arg0_logits) → {Array.<number>}

Computes a numerically-stable softmax over an array of logits.

Source:
Parameters:
Name Type Description
arg0_logits Array.<number>
Returns:
Type:
Array.<number>

(static) trainALRModel(arg0_output_file_path, arg1_covariates_obj, arg2_optionsopt) → {Promise.<(Object|null)>}

Trains an Additive Log-Ratio (ALR) regularised ridge regression model for continuous compositional targets. Bypasses gradient descent under-convergence by solving normal equations analytically.

Source:
Parameters:
Name Type Attributes Description
arg0_output_file_path string

File path to save the trained model.

arg1_covariates_obj Object

{ keys, X, Y, categories, [reference_category] }

arg2_options Object <optional>
Name Type Attributes Default Description
key string <optional>
lambda number <optional>
1e-3

Ridge penalty strength.

smoothing number <optional>
1e-6

Log-ratio epsilon smoothing.

Returns:
Type:
Promise.<(Object|null)>

(static) trainMultinomialLogitModel(arg0_output_file_path, arg1_covariates_obj, arg2_optionsopt) → {Promise.<(Object|null)>}

Trains a multinomial logit model given a fitted covariates object { X, Y, keys } and saves it to JSON. Coefficients are stored per non-reference class.

Source:
Parameters:
Name Type Attributes Description
arg0_output_file_path string
arg1_covariates_obj Object

{ keys, X, Y }

arg2_options Object <optional>
Name Type Attributes Default Description
compute_standard_errors boolean <optional>
false

Hessian-based uncertainty.

debug boolean <optional>
false
key string <optional>
lambda number <optional>
1e-3
learning_rate number <optional>
0.5
max_iterations number <optional>
1000
momentum number <optional>
0.9
tolerance number <optional>
1e-8
Returns:
Type:
Promise.<(Object|null)>

(static) trainMultinomialLogitModelsParallel(arg0_items, arg1_task_generator, arg2_optionsopt) → {Promise.<Array.<Object>>}

Concurrently trains a series of multinomial logit models across background worker processes.

Source:
Parameters:
Name Type Attributes Description
arg0_items Array.<any>

Array of tasks, years, or cohort descriptors.

arg1_task_generator function

(local_item: any, local_index: number) => { categories, covariates_map, filter_format, filter_raster_path, model_path, options, target_paths }

arg2_options Object <optional>
Name Type Attributes Default Description
concurrency number <optional>

Worker thread count.

name string <optional>
"Multinomial Logit Training"
Returns:
Type:
Promise.<Array.<Object>>

(static) trainOLSModel(arg0_output_file_path, arg1_covariates_obj, arg2_optionsopt) → {Promise.<Object>}

Trains a raster-based OLS model given a fitted covariates object { X, Y, keys }.

Source:
Parameters:
Name Type Attributes Description
arg0_output_file_path string
arg1_covariates_obj Object
arg2_options Object <optional>
Name Type Attributes Default Description
dynamic_lambda boolean <optional>
false

Condition numbers are dynamically selected if true.

lambda number <optional>
1e9
remove_high_vif_features boolean <optional>
false

Whether to remove high VIF features.

key string <optional>
weighting_function function <optional>

(arg0_coefficient:number) | number

Returns:
Type:
Promise.<Object>

(static) trainOLSModelsParallel(arg0_items, arg1_task_generator, arg2_optionsopt) → {Promise.<Array.<Object>>}

Concurrently trains a series of OLS models across background worker processes.

Source:
Parameters:
Name Type Attributes Description
arg0_items Array.<any>

Array of years, models, or tasks to train.

arg1_task_generator function

(local_item: any, local_index: number) => { output_file_path, target_file_path, target_format, covariates_map, options, points, target_year }

arg2_options Object <optional>
Name Type Attributes Default Description
concurrency number <optional>

Worker thread count.

name string <optional>
"OLS Model Training"
Returns:
Type:
Promise.<Array.<Object>>

(static) whittakerHendersonRobust(arg0_values, arg1_weightsopt, arg2_start_indexopt, arg3_optionsopt) → {Float32Array|Float64Array}

Performs Whittaker-Henderson graduation with weighted Huber fidelity, second-difference roughness, and optional soft non-increasing monotonicity.

Penalties apply only within [start_index, values.length). Values before start_index are copied without modification.

Source:
Parameters:
Name Type Attributes Default Description
arg0_values Float32Array | Float64Array | Array.<number>
arg1_weights Float32Array | Float64Array | Array.<number> <optional>
arg2_start_index number <optional>
0
arg3_options Object <optional>
Name Type Attributes Default Description
output Float32Array | Float64Array <optional>
huber_delta number <optional>
0.05
lambda number <optional>
20.0
max_iterations number <optional>
20000
min_value number <optional>
-Infinity
mu number <optional>
0.0
tolerance number <optional>
1e-8

Absolute KKT residual tolerance.

Returns:
Type:
Float32Array | Float64Array