varlist {simsalapar} | R Documentation |
Variable Specification List - Generation and Class
Description
Generate variable specification lists. These are objects of the
formal (aka “S4”) class "varlist"
. This class
simply extends "namedList"
and has a validity
method (see validObject
).
Usage
varlist(...)
dimnames2varlist(dmn)
## S4 method for signature 'varlist'
show(object)
Arguments
... |
of the form
i.e, a “list” of variable specifications using “sub
lists” |
dmn |
|
object |
a |
Details
value
is typically an atomic vector (is.atomic
)
or a list
, e.g., of function
s; in the
latter case, typically with names
.
type
can be one of "N"
, "frozen"
, "grid"
, or
"inner"
. In short:
"N"
This type is reserved for a (single) variable named
n.sim
which provides the simulation replications; if it is not given,n.sim
is implicitly treated as 1."frozen"
Variables of this type remain fixed (they do not vary) throughout the whole simultion study. They affect the final result but do not appear as a dimension in the result array of the simulation study. This is the default
type
(apart fromn.sim
which defaults to"N"
)."grid"
Variables of this type are used to build a (physical) grid (a
data.frame
) with number of rows equal to the product of the lengths of all variables of this type. The simulation will use this grid to iteraten.sim
times over all of its rows for conducting the required computations. Conceptually, this corresponds to iterating over a virtual grid seen asn.sim
copies of the (physical) grid pasted together. The computations for one row in this virtual grid form one sub-job. One can use one ofdoLapply()
,doForeach()
,doRmpi()
,doMclapply()
, ordoClusterApply()
to iterate over all sub-jobs."inner"
Variables of this type are all dealt with within a sub-job for reasons of convenience, speed, load balancing etc.
The dimnames2varlist()
functions creates a varlist
from
a named list of character
vectors, typically
resulting from dimnames(tt)
of a table
tt
, see the Titanic example below.
For more details, see Hofert and Mächler (2014), and
also the examples in demo(package="simsalapar")
.
Value
an object of formal (aka “S4”) class "varlist"
.
Author(s)
Martin Maechler.
See Also
namedList
; getEl
for easy
extraction of elements from a "varlist"
.
The toLatex
method for varlist
s,
toLatex.varlist
.
doLapply()
, doForeach()
,
doRmpi()
, doMclapply()
,
doClusterApply()
for the functions to iterate over the
virtual grid.
Examples
showClass("varlist")
vList <- varlist(
n.sim = list(value = 1000, expr = quote(N[sim])), # type = N
n = list(type="grid", value = c(20, 100, 500)), # sample sizes
meth = list(type="grid", expr = quote(italic(method)),
value = c("classical", "robust")),
alpha = list(value = 0.95)) # default type = "frozen"
str(vList)# note the default 'expr' for n and alpha; and type of alpha
## For more extensive examples, see also
demo(package="simsalapar")
## coerce to simple list .. and back :
lvl <- as(vList, "list")
stopifnot(identical(
do.call(varlist, lvl),
vList ))
## From a data.frame to a LaTeX table :
str(dimnames(Titanic))
vlTitan <- dimnames2varlist(dimnames(Titanic))
vlTitan # default 'type = "grid"' here
toLatex(vlTitan)