Description Usage Arguments Details Value Note
These functions are used internally to generate interpolation grids, for Lagrange multipliers or LDEstimators in package RobAStRDA, to be stored in the respective ‘sysdata.rda’ file.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | .versionSuff(name)
.MakeSmoothGridList(thGrid, Y, df = NULL, gridRestrForSmooth = NULL)
.readGridFromCSV(fromFileCSV)
.generateInterpolators(Grid, approxOrspline = "spline", extrapol = c(NA,NA))
.saveGridToRda(fromFileCSV, toFileRDA = "sysdata.rda", withMerge = FALSE,
withPrint = TRUE, withSmooth = TRUE, df = NULL,
gridRestrForSmooth = NULL)
.mergeGrid(Grid1, Grid2)
.computeInterpolators(sysdataFiles, toFileRDA = "sysdata.rda",
includeGrids = NULL, includeNams = NULL,
excludeGrids = NULL, excludeNams = NULL,
withPrint = TRUE, withSmoothFct = FALSE,
approxOrspline = "spline", extrapol = c(NA,NA))
.mergeF(file,envir, includeGrids = NULL, includeNams = NULL,
excludeGrids = NULL, excludeNams = NULL)
.copy_smoothGrid(gridEntry = NULL, rdafileOld, gridnamOld, FamnamOld, rdafileNew,
gridnamNew, FamnamNew, withSmooth = FALSE, df = NULL,
gridRestrForSmooth = NULL)
.renameGridName(rdafileOld, gridnamOld, FamnamOld, rdafileNew, gridnamNew,
FamnamNew)
|
name |
Grid name to append a suffix according to the R-version. |
thGrid |
numeric; grid values. |
Y |
in case |
df |
argument |
gridRestrForSmooth |
an expression that can be used as index in
|
fromFileCSV |
character; names of the csv files from which the grids are read. |
Grid, gridEntry |
matrix; grid to be used. |
approxOrspline |
character; if |
extrapol |
numeric of length 2; lower and upper bound, upto which
extrapolation is done; beyond, the interpolator returns |
toFileRDA |
character; the ‘.rda’-file to which the interpolators are saved. |
withMerge |
logical of length 1: in case a respective grid already exists, shall we merge the new contents into it, or overwrite the object (default)? |
withPrint |
logical of length 1: shall we issue diagnostic prints? |
withSmooth |
logical of length 1: shall a smoothing spline be used? |
Grid1, Grid2 |
matrices; grids to be merged. |
sysdataFiles |
character; filenames of ‘sysdata.rda’ files from where to extract the interpolation grids. |
includeGrids |
character (or |
includeNams |
character (or |
excludeGrids |
character (or |
excludeNams |
character (or |
withSmoothFct |
logical of length 1: shall a smoothed grid be used for interpolators? |
file |
character; the name of a file to be read out. |
envir |
an environment. |
gridnamOld |
character; name of the grid to be renamed (from). |
FamnamOld |
character; name of the parametric family to be renamed (from). |
rdafileOld |
character; filename of the ‘sysdata.rda’-type file to be read out. |
gridnamNew |
character; name of the grid to be renamed (to). If missing,
it is set to |
FamnamNew |
character; name of the parametric family to be renamed (to).
If missing, it is set to |
rdafileNew |
character; filename of the ‘sysdata.rda’-type file
to be written on. If missing, it is set to |
.versionSuff
, according to the current R-version, appends a suffix
".O" for R<2.16 and ".N" otherwise to argument name
. Needed as
the return values of splinefun
and approxfun
are incompatible
in these two situations: i.e., a function with body of type
.C("R_splinefun", as.double(x),....
) respectively
a function with body of type .splinefun(....))
);
a similar case happens with approxfun
.
.MakeSmoothGridList
smoothes out a given grid (x is contained in
thGrid
, y in Y
) by smooth.spline
; the degree
of smoothing is controlled by df
.
.readGridFromCSV
reads in a grid from a csv file together with the
information given in the corresponding ‘.txt’ file. More specifically,
when generating a ‘.csv’ file in e.g.\ RobExtremes by
.writeGridToCSV
, in addition to writing the interpolation grid
to the ‘.csv’ file, a corresponding ‘.txt’ file is created
containing information on the parametric family and the grid name.
This information is read in again as well here.
.generateInterpolators
for a given grid according to argument
approxOrspline
produces a list of interpolators by calls to either
splinefun
or approxfun
(i.e., one function per y-column).
In addition, in case of (x-)values outside the range of the grid, in the
interpolators, we use linear extrapolation.
.saveGridToRda
for a vector of files in argument fromFileCSV
reads in the grids and writes them to a ‘sysdata.rda’ file.
If ‘sysdata.rda’ already exists and corresponding grids already exist
in ‘sysdata.rda’, argument withMerge
controls whether the
grids are merged or overwritten. In addition, by argument withSmooth
,
one may generate smoothed out grids as well. So in the end,
the ‘sysdata.rda’ file contains grid objects with names by default
starting with a dot, say .Sn
or .OMSE
. These are lists
with parametric families as items (with the names of the parametric
families as names of the list items). Each family item is again a list
with (possible) entries grid
(the original grid read out from
the ‘.csv’-file), gridS
(the smoothed out grid), fct.O
,
the interpolator generated in R<2.16, fct.N
, the interpolator
generated in R>2.16. .saveGridToRda
only generates the grid entries,
whereas the interpolators are created in .computeInterpolators
.
.mergeGrid
merges two grids according to the respective rows of the
matrices.
.computeInterpolators
for a vector of input ‘sysdata.rda’ files
contained in argument sysdataFiles
goes through the contained
grids and produces respective interpolators by calls to
.generateInterpolators
. If withSmoothFct == TRUE
(and
a respective gridS
entry exists in the current grid-family
combination) it uses the gridS
entry, otherwise the grid
entry. By means of optional arguments includeGrids
,
includeNams
, excludeGrids
, excludeNams
one may
explicitely restrict the grid-family combinations for which the
interpolators are generated.
.mergeF
merges the contents of file file
into environment
envir
in the sense, that if both file
and envir
contain a list object a
also the items of a
are merged,
where—as for objects themselves— contents of file
overwrite
contents of envir
. By means of optional arguments includeGrids
,
includeNams
, excludeGrids
, excludeNams
one may
explicitely restrict the grid-family combinations for which the
interpolators are generated.
.copy_smoothGrid
can be used to modify single grid
/
gridS
entries in an existing grid-family combination in an existing
‘sysdata.rda’-file; in particular grid
entries can be replaced
and gridS
entries can be created (or overwritten). To this end,
.copy_smoothGrid
takes out a respective item FamnamOld
(i.e., a parametric family) of grid gridnamOld
from file
rdafileOld
. If argument gridEntry
is non-NULL
, it
replaces the respective grid
-entry by gridEntry
, otherwise
it uses the one present in combination gridnamOld
-FamnamOld
.
If argument withSmooth == TRUE
, it also creates a gridS
entry, smoothing out the entries of the grid
-entry.
The results are copies it to a new grid-family combination
gridnamNew
-FamnamNew
which is saved to file
rdafileNew
.
.renameGridName
is a utility to rename grids and items from a grid.
It takes grid gridnamOld
from file rdafileOld
and takes
the name FamnamOld
of a respective item (i.e., a parametric family),
renames the grid-family combination to gridnamNew
,
FamnamNew
and writes the result back to file rdafileNew
.
.versionSuff |
A character with appended suffix. |
.MakeSmoothGridList |
the grid, i.e.; a matrix with x and y values . |
.readGridFromCSV |
a list with the read-in items, i.e.,
an item |
.generateInterpolators |
a list with items |
.saveGridToRda |
|
.mergeGrid |
the merged grid, i.e.; a matrix. |
.computeInterpolators |
|
.mergeF |
|
.copy_smoothGrid |
|
.renameGridName |
|
These functions are only meant for the developers of package
ROptEst (or respective packages).
They can be used to speed up things by interpolation.
Our use case is a speed up for further scale-shape families (or enhance
existing speed-ups) such that the respective grids are stored in
a ‘sysdata.rda’ file of the present package RobAStRDA
—see mail exchange P.Ruckdeschel - U.Ligges on R-devel—
https://stat.ethz.ch/pipermail/r-devel/2013-February/065794.html.
Special attention has to be paid for R-versions pre and post R-2.16
which is why we use .versionSuff
.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.