downscale_control: Set Options for Downscaling Solver

View source: R/downscale_control.R

downscale_controlR Documentation

Set Options for Downscaling Solver

Description

This function configures the downscalR solver with customizable options. It allows the selection of the solver function and adjustment of solver behavior and stopping conditions, tailored for specific downscaling needs.

Usage

downscale_control(
  solve_fun = "solve_biascorr",
  algorithm = "NLOPT_LN_SBPLX",
  xtol_rel = 1e-20,
  xtol_abs = 1e-20,
  maxeval = 1600,
  MAX_EXP = log(.Machine$double.xmax),
  cutoff = 0,
  max_diff = 1e-08,
  ref_class_adjust_threshold = 1e-08,
  err.txt = ""
)

Arguments

solve_fun

The downscaling function to use. Valid options are "solve_biascorr" for bias correction and "solve_notarget" for non-targeted downscaling. Defaults to "solve_biascorr".

algorithm

Specifies the solver algorithm. The default algorithm is "NLOPT_LN_SBPLX". For more information on available algorithms, refer to the nloptr package.

xtol_rel

The relative tolerance level of the solver, controlling solution precision in relative terms. Default is 1.0e-20, where a lower value indicates higher precision.

xtol_abs

The absolute tolerance level of the solver, specifying solution precision in absolute terms. Default is 1.0e-20, with a lower value indicating higher precision.

maxeval

The maximum number of evaluations the solver will perform, limiting computational effort. Default is 1600.

MAX_EXP

Sets the numerical cutoff to prevent extremely high values in the Multinomial Logit (MNL) function. Default is log(.Machine$double.xmax).

cutoff

An optional cutoff in the share of a pixel to avoid MNL values close to zero. Default is 0.

max_diff

The threshold for acceptable difference to targets. If exceeded, the estimation is redone. Default is 1.0e-8.

ref_class_adjust_threshold

The threshold for adjusting the reference class in the MNL. If the implied target share for the reference class is below this, additional areas are created for numerical stability and removed after solving. Default is 1.0e-8.

err.txt

An optional error message for debugging purposes. Empty by default.

Details

The function returns a list of parameters to be used by the solver. It is essential to provide compatible parameters to ensure accurate downscaling results. The function will stop with an error message if solve_fun is not correctly specified.

Value

Returns a list with the specified options for the downscaling solver.

Examples

# Default settings
opts_default = downscale_control()

# Custom settings
opts_custom = downscale_control(algorithm = "some_other_algorithm",
                                xtol_rel = 1e-5, xtol_abs = 1e-5,
                                maxeval = 2000)

tkrisztin/downscalr documentation built on June 2, 2025, 1:16 a.m.