Learn R Programming

ROptEst (version 1.0)

internal_interpolate_helpers: Internal helper functions for generating interpolation grids for speed up in package ROptEst

Description

These functions are used internally to generate interpolation grids, for Lagrange multipliers or LDEstimators in package RobExtremes, to be stored in the respective ‘sysdata.rda’ file.

Usage

.RMXE.th(th, PFam, modifyfct, loRad = 0, upRad = Inf, z.start = NULL, A.start = NULL, upper = NULL, lower = NULL, OptOrIter = "iterate", maxiter = 50, tol = .Machine$double.eps^0.4, loRad0 = 1e-3, ...) .MBRE.th(th, PFam, modifyfct, z.start = NULL, A.start = NULL, upper = 1e4, lower = 1e-4, OptOrIter = "iterate", maxiter = 50, tol = .Machine$double.eps^0.4, ...) .OMSE.th(th, PFam, modifyfct, radius = 0.5, z.start = NULL, A.start = NULL, upper = 1e4, lower = 1e-4, OptOrIter = "iterate", maxiter = 50, tol = .Machine$double.eps^0.4, ...)
.getLMGrid(thGrid, PFam, optFct = .RMXE.th, modifyfct, radius = 0.5, GridFileName = "LMGrid.Rdata", withPrint = FALSE, upper = 1e4, lower = 1e-4, OptOrIter = "iterate", maxiter = 50, tol = .Machine$double.eps^0.4, loRad = 0, upRad = Inf, loRad0 = 1e-3, loRad.s = 0.2, up.Rad.s = 1, withStartLM = TRUE, len = 13)
.saveGridToCSV(Grid, toFileCSV, namPFam, nameInSysdata)
.readGridFromCSV <- function(fromFileCSV)
.generateInterpGrid(thGrid, PFam, toFileCSV = "temp.csv", getFun = .getLMGrid, ..., modifyfct, nameInSysdata, GridFileName, withPrint = TRUE, len = 13)

Arguments

th
numeric of length 1; the grid value at which to compute LMs.
PFam
an object of class "ParamFamily", the parametric family at which to evaluate the Lagrange multipliers or LDEstimators; in our use case, it is a shape-scale model, hence the respective (main) parameter must contain "scale" and "shape".
modifyfct
function with arguments th and PFam to move the parametric family to the point of the grid value; returns the moved parametric family.
radius
[for OMSE]: positive numeric of length 1: the radius of the neighborhood for which the LM's are to be computed; defaults to 0.5.
loRad
the lower end point of the interval to be searched in the inner optimization (for the least favorable situation to the user-guessed radius).
upRad
the upper end point of the interval to be searched in the inner optimization (for the least favorable situation to the user-guessed radius).
loRad.s
the lower end point of the interval to be searched in the outer optimization (for the user-guessed radius); if NULL set to loRad in the algorithm.
upRad.s
the upper end point of the interval to be searched in the outer optimization (for the user-guessed radius); if NULL set to upRad in the algorithm.
z.start
initial value for the centering constant.
A.start
initial value for the standardizing matrix.
upper
upper bound for the optimal clipping bound.
lower
lower bound for the optimal clipping bound.
OptOrIter
character; which method to be used for determining Lagrange multipliers A and a: if (partially) matched to "optimize", getLagrangeMultByOptim is used; otherwise: by default, or if matched to "iterate" or to "doubleiterate", getLagrangeMultByIter is used. More specifically, when using getLagrangeMultByIter, and if argument risk is of class "asGRisk", by default and if matched to "iterate" we use only one (inner) iteration, if matched to "doubleiterate" we use up to Maxiter (inner) iterations.
maxiter
the maximum number of iterations.
tol
the desired accuracy (convergence tolerance).
loRad0
for numerical reasons: the effective lower bound for the zero search; internally set to max(loRad,loRad0).
...
additional parameters.
withStartLM
logical of length 1: shall the LM's of the preceding grid value serve as starting value for the next grid value?
withSmooth
logical of length 1: shall a smoothing spline be used?
withPrint
logical of length 1: shall current grid value be printed out?
thGrid
numeric; grid values.
optFct
function with arguments theta, PFam, and modifyfct; determines the Lagrange multipliers.
GridFileName
character; if GridFileName!="", the pure y-grid values are saved under this filename.
Grid
numeric; grid matrix (x- and y-values).
toFileCSV
character; name of the csv file to which the grid is written.
namPFam
character; name of the parametric family for which the grid was generated.
nameInSysdata
character; grid name (e.g., 'OMSE', 'Sn') for which the grid was generated.
fromFileCSV
character; name of the csv file from which the grid is read.
getFun
function with first argument th, second argument PFam and last arguments GridFileName, withPrint; produces the y-values for the interpolation grid.
...
further arguments to be passed on to getFun.
len
integer; number of Lagrange multipliers to be calibrated.

Value

.saveGridToCSVinvisible(NULL)..readGridFromCSV a list with the read-in items, i.e., an item Grid with the grid, an item namPFam with the name of the parametric family, and namInSysdata, the name of the read in grid..generateInterpGridinvisible(NULL).

Details

.MBRE.th computes the Lagrange multipliers for the MBRE estimator, .OMSE.th for the OMSE estimator at radius radius, and .RMXE.th the RMXE estimator.

.getLMGrid in a large loop computes the Lagrange multipliers for optimally robust IFs for each element of a given grid. .saveGridToCSV saves a given grid to a csv file, and in addition, in a file with same name but with file extension ".txt" writes the parametric family and the grid name.

.readGridFromCSV reads in a grid from a csv file together with the information given in the corresponding ".txt" file.

.generateInterpGrid by means of calls to function-argument getFun (e.g. getLMGrid computes the grid, if desired smoothes it, and then saves it to .csv.