Title: | Simulation Classes Based on Package 'distr' |
---|---|
Description: | S4-classes for setting up a coherent framework for simulation within the distr family of packages. |
Authors: | Florian Camphausen [ctb] (contributed as student in the initial phase --2005), Matthias Kohl [aut, cph], Peter Ruckdeschel [cre, cph], Thomas Stabla [ctb] (contributed as student in the initial phase --2005) |
Maintainer: | Peter Ruckdeschel <[email protected]> |
License: | LGPL-3 |
Version: | 2.8.4 |
Built: | 2024-11-06 02:16:26 UTC |
Source: | https://github.com/r-forge/distr |
distrSim is to provide a conceptual treatment of simulations by means of S4 classes. The package is based on our package distr, hence uses distribution classes as introduced there to describe the distributions under which simulations are performed.
Package: | distrSim |
Version: | 2.8.4 |
Date: | 2024-08-29 |
Depends: | R(>= 3.4), methods, graphics, setRNG(>= 2006.2-1), distr(>= 2.5.2) |
Suggests: | distrEx(>= 2.2) |
Imports: | startupmsg, stats, grDevices |
LazyLoad: | yes |
License: | LGPL-3 |
URL: | https://distr.r-forge.r-project.org/ |
VCS/SVNRevision: | 1463 |
"SeqDataFrame" slots: data(list[of dataframes with common column structure]) "Dataclass" slots: [<name>(<class>)] filename(vectororNULL), name(character), Data(ArrayorNULLorVectororDataframeorSeqDataFrames), runs(numeric), samplesize(numeric), obsDim(numeric) |>"Simulation" (additional) slots: [<name>(<class>)] seed(list), distribution(Distribution) |>"Contsimulation" (additional) slots: [<name>(<class>)] seed(list), ind(vectororNULL), rate(numeric), distribution.id(Distribution), distribution.c(Distribution), Data.id(vectororNULL), Data.c(vectororNULL)
savedata Methods to save the data slot (for Simulation/Contsimulation) simulate Methods to fill the data slot (for Simulation/Contsimulation) plot-methods Methods for Function plot (for Simulation/Contsimulation) print-, show-methods Methods for Function print/show (for Simulation/Contsimulation) summary-methods Methods for Function summary (for Simulation/Contsimulation)
cload loads just the comment slot (for Simulation/Contsimulation)
All slots are inspected / modified by corresponding
accessors / -replacement functions, e.g. rate(X)
for
an object of class "Contsimulation"
.
You may suppress the start-up banner/message completely by setting options("StartupBanner"="off")
somewhere before loading this package by library
or require
in your R-code / R-session.
If option "StartupBanner"
is not defined (default) or setting
options("StartupBanner"=NULL)
or options("StartupBanner"="complete")
the complete start-up banner is displayed.
For any other value of option "StartupBanner"
(i.e., not in c(NULL,"off","complete")
)
only the version information is displayed.
The same can be achieved by wrapping the library
or require
call into
either suppressStartupMessages()
or
onlytypeStartupMessages(.,atypes="version")
.
From version 1.8 of this package on, we have changed the format how data / simulations are stored:
In order to be able to cope with multivariate distributions, regression distributions and (later)
time series distributions, we have switched to the common array format:
samplesize x obsDim x runs; you may check the version under which an object was generated by
getVersion
; for saved objects from earlier versions, we provide the functions
isOldVersion
, and conv2NewVersion-methods
to check whether the object was generated by an older version of this package and to convert
such an object to the new format, respectively.
You may suppress the start-up banner/message completely by setting options("StartupBanner"="off")
somewhere before loading this package by library
or require
in your R-code / R-session.
If option "StartupBanner"
is not defined (default) or setting
options("StartupBanner"=NULL)
or options("StartupBanner"="complete")
the complete start-up banner is displayed.
For any other value of option "StartupBanner"
(i.e., not in c(NULL,"off","complete")
)
only the version information is displayed.
As for general packageStartupMessage
's, you may also suppress all
the start-up banner by wrapping the library
or require
call into suppressPackageStartupMessages()
from
startupmsg-version 0.5 on.
Note: The first two numbers of package versions do not necessarily reflect package-individual development, but rather are chosen for the distrXXX family as a whole in order to ease updating "depends" information.
Global options controlling the plots and summaries of Dataclass and Simulation/Contsimulation
objects may be inspected / set by distrSimoptions()
and getdistrSimOption()
.
Thomas Stabla [email protected],
Florian Camphausen [email protected],
Peter Ruckdeschel [email protected],
Matthias Kohl [email protected]
Maintainer: Peter Ruckdeschel [email protected]
P. Ruckdeschel, M. Kohl, T. Stabla, F. Camphausen (2006):
S4 Classes for Distributions, R News, 6(2), 2-6.
https://CRAN.R-project.org/doc/Rnews/Rnews_2006-2.pdf
A vignette for packages distr, distrSim, distrTEst, and distrEx
is included into the mere documentation package distrDoc and may be called by
require("distrDoc");vignette("distr")
.
A homepage to this package is available under
https://distr.r-forge.r-project.org/
loads the comment file from a saved Dataclass
object
cload(filename)
cload(filename)
filename |
the filename which was declared at the instantiaton of the Dataclass |
Uses function load
to load the comment file from a saved Dataclass
object.
no value is returned
Thomas Stabla [email protected],
Florian Camphausen [email protected],
Peter Ruckdeschel [email protected],
Matthias Kohl [email protected]
Dataclass-class
load
savedata-methods
# see Dataclass and Evaluation for examples ## The function is currently defined as function(filename){ eval.parent(parse(text=paste("load(\"",filename,".comment\")", sep = ""))) }
# see Dataclass and Evaluation for examples ## The function is currently defined as function(filename){ eval.parent(parse(text=paste("load(\"",filename,".comment\")", sep = ""))) }
In an object of type Contsimulation
data can be simulated in any distribution and size. One part
(usually the largest) of the random numbers stems from an ideal distribution, the rest from a contaminating distribution.
Objects can be created by calls of the form Contsimulation(filename, samplesize, runs, seed, distribution.id,
distribution.c, rate)
(observation dimension is deduced from slot distribution.id
).
A Contsimulation
-object includes a filename, the number of runs, the size of the sample, the seed, the distribution
of the ideal and the contaminated data and the contamination rate. The slot Data stays empty until the method simulate has
been used. The same goes for slots Data.id and Data.c.
ind
:Object of class "MatrixorNULLorVector"
: Indicator of the same length as the data; saves whether each
element of the data vector is contaminated or not
Data.id
:Object of class "ArrayorNULLorVector"
: – the ideal data
Data.c
:Object of class "ArrayorNULLorVector"
: – the contaminated data
rate
:Object of class "numeric"
: the contamination rate, so the probability for each random number
to be contaminated
distribution.c
:Object of class "UnivariateDistribution"
: the distribution of the ideal data
distribution.id
:Object of class "UnivariateDistribution"
: the distribution of the contaminated
data
seed
:Object of class "list"
: the seed the simulation has been generated with
name
:Object of class "character"
: a name for the Contsimulation
filename
:Object of class "character"
: the filename the Contsimulation shall be saved
Data
:Object of class "ArrayorNULLorVector"
: the simulated data
samplesize
:Object of class "numeric"
: the size of the sample, so the dimension of the data
obsDim
:Object of class "numeric"
: the observation dimension of the data
runs
:Object of class "numeric"
: the number of runs of the data
Class "Dataclass"
, directly.
signature(object = "Contsimulation")
: returns the contaminated data
signature(object = "Contsimulation")
: returns the ideal data
signature(object = "Contsimulation")
: ERROR: A modification of simulated data is not allowed.
signature(object = "Contsimulation")
: returns the the filename
signature(object = "Contsimulation")
: changes the the filename
signature(object = "Contsimulation")
: returns the the name
signature(object = "Contsimulation")
: changes the the name
signature(object = "Contsimulation")
: returns the distribution of the contaminated data
signature(object = "Contsimulation")
: changes the distribution of the contaminated data
signature(object = "Contsimulation")
: returns the distribution of the ideal data
signature(object = "Contsimulation")
: changes the distribution of the ideal data
signature(object = "Contsimulation")
: returns the seed
signature(object = "Contsimulation")
: changes the seed
signature(object = "Contsimulation")
: returns the indicator which saves which data is contaminated
signature(.Object = "Contsimulation")
: initialize method
signature(object = "Contsimulation")
: returns the contamination rate
signature(object = "Contsimulation")
: changes the contamination rate
signature(object = "Contsimulation")
: returns the dimension of the observations
signature(object = "Contsimulation")
: returns the version of this package, under which this object was generated
signature(object = "Contsimulation")
: returns the number of runs
signature(object = "Contsimulation")
: changes the number of runs
signature(object = "Contsimulation")
: returns the size of the sample
signature(object = "Contsimulation")
: changes the size of the sample
signature(object = "Contsimulation")
: saves the object without the data in the
directory of R. (After loading the data can be reproduced by using simulate.)
signature(x = "Contsimulation")
: generates the random numbers for the simulation
signature(x = "Contsimulation")
: produces a plot of the real data matrix; ; for details confer plot-methods
signature(x = "Contsimulation")
: returns filename, seed, the observation dimension,
the number of runs, the size of the sample, the contamination rate and the distributions, and,
if from a version > 1.8, also the package version under which the object was generated
signature(object = "Contsimulation")
: returns filename, seed, number of runs, the size of the
sample, the rate and a statistical summary for each run of the real data
Changing distributions, seed, runs, samplesize or rate deletes possibly simulated data, as it would not fit to the new parameters.
Thomas Stabla [email protected],
Florian Camphausen [email protected],
Peter Ruckdeschel [email protected],
Matthias Kohl [email protected]
Dataclass-class
Simulation-class
savedata-methods
plot-methods
simulate-methods
summary-methods
getVersion-methods
N <- Norm() # N is a standard normal distribution. C <- Cauchy() # C is a Cauchy distribution cs <- Contsimulation(filename = "csim", runs = 10, samplesize = 3, seed = setRNG(), distribution.id = N, distribution.c = C, rate = 0.1) simulate(cs) # Each of the 30 random numbers is ideal (N-distributed) with # probability 0.9 and contaminated (C-distributed) with # probability = 0.1 Data(cs) Data.id(cs) Data.c(cs) ind(cs) summary(cs) Data(cs) # different data savedata(cs) # saves the object in the working directory of R... load("csim") # loads it again... Data(cs) # ...without the data - use simulate to return it! ## clean up unlink("csim")
N <- Norm() # N is a standard normal distribution. C <- Cauchy() # C is a Cauchy distribution cs <- Contsimulation(filename = "csim", runs = 10, samplesize = 3, seed = setRNG(), distribution.id = N, distribution.c = C, rate = 0.1) simulate(cs) # Each of the 30 random numbers is ideal (N-distributed) with # probability 0.9 and contaminated (C-distributed) with # probability = 0.1 Data(cs) Data.id(cs) Data.c(cs) ind(cs) summary(cs) Data(cs) # different data savedata(cs) # saves the object in the working directory of R... load("csim") # loads it again... Data(cs) # ...without the data - use simulate to return it! ## clean up unlink("csim")
Methods to access and change the Data
-slot
signature(object = "Dataclass")
: returns the data
signature(object = "Dataclass")
: changes the data (does not work with a simulation or a contsimulation
object)
signature(object = "Simulation")
: ERROR: A change of the data is not allowed.
signature(object = "Contsimulation")
: ERROR: A change of the data is not allowed.
Data.c-methods
signature(object = "Dataclass")
: returns the
contaminated data
Data.id-methods
signature(object = "Contsimulation")
: returns the ideal data
Generates an object of class "Dataclass".
Dataclass(Data, ...) ## S4 method for signature 'ArrayorNULLorVector' Dataclass(Data, filename = NULL, name = "Data-Set") ## S4 method for signature 'array' Dataclass(Data, filename = NULL, name = "Data-Set") ## S4 method for signature 'matrix' Dataclass(Data, filename = NULL, name = "Data-Set") ## S4 method for signature 'DataframeorSeqDataFrames' Dataclass(Data, filename = NULL, name = "Data-Set")
Dataclass(Data, ...) ## S4 method for signature 'ArrayorNULLorVector' Dataclass(Data, filename = NULL, name = "Data-Set") ## S4 method for signature 'array' Dataclass(Data, filename = NULL, name = "Data-Set") ## S4 method for signature 'matrix' Dataclass(Data, filename = NULL, name = "Data-Set") ## S4 method for signature 'DataframeorSeqDataFrames' Dataclass(Data, filename = NULL, name = "Data-Set")
Data |
the data to be filled in |
filename |
Object of class |
name |
Object of class |
... |
additional parameters. |
Peter Ruckdeschel [email protected],
In an object of type "Dataclass" data can be saved containing any number of runs in any dimension. All information about the data is stored in a unified way.
Objects can be created by calls to the generating function, method
Dataclass(Data, filename = "Data-set", name = "Data-Set")
.
A Dataclass-object includes, aside from the actual data, a filename
and the size of the sample, the observation dimension, and the number of runs, which give the
number of rows and columns (and, if more than one run, slices)
of the data array.
filename
:Object of class "character"
: the filename the data shall be saved
name
:Object of class "character"
: a name for the Data
Data
:Object of class "ArrayorNULLorVectororDataframeorSeqDataFrames"
:
the actual data, either of type "NULL" (means no data) or "vector" or "array"
or "Dataframe" or "SeqDataFrames"
obsDim
:Object of class "numeric"
:
the observation dimension of the data
runs
:Object of class "numeric"
:
the number of runs of the data
samplesize
:Object of class "numeric"
:
the size of the sample
version
:Object of class "character"
:
the package version under which this object was generated
signature(object = "Dataclass")
:
returns the actual data
signature(object = "Dataclass")
:
changes the data
signature(object = "Dataclass", estimator =
"function")
:
creates an object of type "Evaluation", see there for further information
signature(object = "Dataclass")
:
returns the the filename
signature(object = "Dataclass")
:
changes the the filename
signature(object = "Dataclass")
:
returns the the name
signature(object = "Dataclass")
:
changes the the name
signature(.Object = "Dataclass")
:
initialize method
signature(object = "Dataclass")
:
returns the dimension of the observations
signature(object = "Dataclass")
:
returns the number of runs
signature(object = "Dataclass")
:
returns the size of the sample
signature(object = "Dataclass")
:
returns the version slot of this object
signature(object = "Dataclass")
:
saves the object in the directory of R and also a copy without data
signature(x = "Dataclass")
:
produces a plot of the data matrix; ; for details confer plot-methods
signature(x = "Dataclass")
:
returns filename, the observation dimension, the number of runs
and the size of the sample, and, if from a version > 1.8, also the package version under
which the object was generated
signature(object = "Dataclass")
:
returns the same information as print, moreover a statistical
summary for each run
The saved Dataclass can be loaded with the usual load-command, the saved comment with the function cload.
Thomas Stabla [email protected],
Florian Camphausen [email protected],
Peter Ruckdeschel [email protected],
Matthias Kohl [email protected]
Simulation-class
Contsimulation-class
Evaluation-class
plot-methods
print-methods
summary-methods
load
cload
savedata-methods
getVersion-methods
D66 <- Dataclass(filename="N74", Data = matrix(1:36,6)) D66 # D <- Dataclass(Data = array(c(1,2,3,4,5,6),c(samplesize=2,obsdim=3,Runs=1)), filename = "xyz.sav") # A new object of type "Dataclass" is created. # isOldVersion(D) ##NO! # savedata(D) # creates a file called "xyz.sav" where the information is saved and a # copy "xyz.sav.comment" without data Data(D) <- array(c(11,12,13,14,15,16),c(samplesize=2,obsdim=3,Runs=1)) # changes the data of D cload("xyz.sav") # loads the object without data - it is called "D.comment" D.comment load("xyz.sav") # loads the original object "D" Data(D) # the original data: matrix(c(1,2,3,4,5,6),2) #if you have distrTEst available: #evaluate(object = D, estimator = mean) # returns the mean of each variable ## clean up unlink("xyz.sav") unlink("xyz.sav.comment")
D66 <- Dataclass(filename="N74", Data = matrix(1:36,6)) D66 # D <- Dataclass(Data = array(c(1,2,3,4,5,6),c(samplesize=2,obsdim=3,Runs=1)), filename = "xyz.sav") # A new object of type "Dataclass" is created. # isOldVersion(D) ##NO! # savedata(D) # creates a file called "xyz.sav" where the information is saved and a # copy "xyz.sav.comment" without data Data(D) <- array(c(11,12,13,14,15,16),c(samplesize=2,obsdim=3,Runs=1)) # changes the data of D cload("xyz.sav") # loads the object without data - it is called "D.comment" D.comment load("xyz.sav") # loads the original object "D" Data(D) # the original data: matrix(c(1,2,3,4,5,6),2) #if you have distrTEst available: #evaluate(object = D, estimator = mean) # returns the mean of each variable ## clean up unlink("xyz.sav") unlink("xyz.sav.comment")
distribution-methods
signature(object = "Simulation")
: returns the slot distribution
of the simulation
signature(object = "Simulation")
: changes the slot distribution
of the simulation
distribution-methods
signature(object = "Contsimulation")
: returns the distribution of the contaminated data
signature(object = "Contsimulation")
: changes the distribution of the contaminated data
distribution-methods
signature(object = "Contsimulation")
: returns the distribution of the ideal data
signature(object = "Contsimulation")
: changes the distribution of the ideal data
Provides information on the (intended) masking of and (non-intended) masking by other other functions in package distrSim
distrSimMASK(library = NULL)
distrSimMASK(library = NULL)
library |
a character vector with path names of R libraries, or |
no value is returned
Peter Ruckdeschel [email protected]
## IGNORE_RDIFF_BEGIN distrSimMASK() ## IGNORE_RDIFF_END
## IGNORE_RDIFF_BEGIN distrSimMASK() ## IGNORE_RDIFF_END
With distrSimoptions
and getdistrSimOption
you may inspect and change the global
variables used by package distrSim.
distrSimoptions(...) getdistrSimOption(x)
distrSimoptions(...) getdistrSimOption(x)
... |
any options can be defined, using name = value or by passing a list of such tagged values. |
x |
a character string holding an option name. |
Invoking distrSimoptions()
with no arguments returns a list with the current values of the options.
To access the value of a single option, one should use getdistrSimOption("MaxNumberofSummarizedRuns")
,
e.g., rather than distroptions("MaxNumberofSummarizedRuns")
which is a list of length one.
distrSimoptions()
returns a list of the global options of distrSim. distrSimoptions("MaxNumberofSummarizedRuns")
returns the global option MaxNumberofSummarizedRuns
as a list of length 1. distrSimoptions("MaxNumberofSummarizedRuns" = 3)
sets the value of the global option MaxNumberofSummarizedRuns
to 3.
getdistrSimOption("MaxNumberofSummarizedRuns")
the current value set for option MaxNumberofSummarizedRuns
.
maximal number of observation plotted; defaults to 4000
maximal number of observation dimensions plotted in parallel; defaults to 6
maximal number of runs plotted in parallel; defaults to 6
maximal number of observation dimensions summarized in parallel; defaults to 6
maximal number of runs summarized in parallel; defaults to 6
Peter Ruckdeschel [email protected]
options
, getOption
,
distroptions
, getdistrOption
distrSimoptions() distrSimoptions("MaxNumberofPlottedObsDims") distrSimoptions("MaxNumberofPlottedObsDims" = 5) # or getdistrSimOption("MaxNumberofPlottedObsDims")
distrSimoptions() distrSimoptions("MaxNumberofPlottedObsDims") distrSimoptions("MaxNumberofPlottedObsDims" = 5) # or getdistrSimOption("MaxNumberofPlottedObsDims")
filename-methods
signature(object = "Dataclass")
: returns the filename
signature(object = "Dataclass")
: changes the filename
ind-methods
signature(object = "Contsimulation")
: returns an indicator showing which data is contaminated
name-methods
signature(object = "Dataclass")
: returns the name
signature(object = "Dataclass")
: changes the name
obsDim-methods
signature(object = "Dataclass")
or signature(object = "SeqDataFrames")
: returns the number of obsDim
plot-methods
An S3 object of class c("plotInfo","DiagnInfo")
, i.e., a list
containing the information needed to produce the
respective plot, which at a later stage could be used by different
graphic engines (like, e.g. ggplot
) to produce the plot
in a different framework. A more detailed description will follow in
a subsequent version.
signature(x = "Dataclass", y="missing")
: produces a plot of the data matrix;
optional arguments:
the indices of observations to be plotted;— of this vector runs0
maximally MaxNumberofPlottedObs
runs are plotted where MaxNumberofPlottedObs
is a global option, see distrSimoptions
the indices of runs to be plotted; — of this vector runs0
maximally MaxNumberofPlottedRuns
runs are plotted where MaxNumberofPlottedRuns
is a global option, see distrSimoptions
the indices of observation dimensions to be plotted; — of this vector dims0
maximally MaxNumberofPlottedObsDims
dimensions are plotted where MaxNumberofPlottedObsDims
is a global option, see distrSimoptions
typical plot arguments may be passed; some have slightly different meaning (compare plot.default
):
may be transmitted matrixwise (in a 2 x (number of dimensions) matrix)) or globally, using the usual recycling rules
may be transmitted vectorwise (for the different dimensions) or globally, using the usual recycling rules
are ignored
signature(x = "Simulation", y="missing")
:
produces a plot of the data matrix; optional and typical plot arguments: as with signature(x = "Dataclass", y="missing")
signature(x = "Contsimulation")
: produces a plot of the real data matrix;
optional arguments: as with signature(x = "Dataclass", y="missing")
;
typical plot arguments may be passed; some have slightly different meaning (compare plot.default
):
as with signature(x = "Simulation", y="missing")
and signature(x = "Dataclass", y="missing")
are ignored
as col,cex,pch
for signature(x = "Dataclass", y="missing")
but only for ideal part of the data
as col,cex,pch
for signature(x = "Dataclass", y="missing")
but only for contaminated part of the data
are ignored
print and show - methods
signature(x = "SeqDataFrames")
: extra argument short = FALSE
; if TRUE
the output is cut according to distrSimoptions
.
signature(x = "Dataclass")
: returns name, filename, the observation dimension, the number of runs
and the size of the sample, and, if from a version > 1.8, also the package version under which the object was generated
signature(x = "Simulation")
: as for signature(x = "Dataclass")
and, additionally,
seed and the distribution
signature(x = "Contsimulation")
: as for signature(x = "Dataclass")
and, additionally,
seed, the contamination rate and the distributions
signature(x = "Dataclass")
, signature(x = "Simulation")
,
signature(x = "Contsimulation")
, signature(x = "SeqDataFrames")
: as corresponding print
method
rate-methods
signature(object = "Contsimulation")
: returns the contamination rate
signature(object = "Contsimulation")
: modifies the contamination rate
runs-methods
signature(object = "SeqDataFrames")
: returns the number of runs
signature(object = "Dataclass")
: returns the number of runs
signature(object = "Simulation")
: changes the number of runs
signature(object = "Contsimulation")
: changes the number of runs
samplesize-methods
signature(object = "SeqDataFrames")
: returns the size[s] of the sample[s]
signature(object = "Dataclass")
: returns the size of the sample
signature(object = "Simulation")
: changes the size of the sample
signature(object = "Contsimulation")
: changes the size of the sample
savedata-methods
signature(object = "Dataclass")
: saves the object (with the data) in the directory of R
signature(object = "Simulation")
: saves the object without the data in the directory of R
(After loading the data can be reproduced by using simulate.)
signature(object = "Contsimulation")
: saves the object without the data in the directory of R
(After loading the data can be reproduced by using simulate.)
For an example, see Simulation-class
and Contsimulation-class
Dataclass-class
Simulation-class
Contsimulation-class
Evaluation-class
seed-methods
signature(object = "Simulation")
: returns the slot seed
of an object of class "Simulation"
signature(object = "Simulation")
: changes the slot seed
of an object of class "Simulation"
signature(object = "Contsimulation")
: returns the slot seed
of an object of class "Contsimulation"
signature(object = "Contsimulation")
: changes the slot seed
of an object of class "Contsimulation"
The value to which the seed is set has to be consistent with the setRNG-package;
to draw a “new” simulation, use something like seed(X)<-setRNG();simulate(X)
;
cf. manual to this package, p.~9
An object of type "SeqDataFrames" is a list of data frames, all of which with the same numbers and names of columns (ideally with the same data-types for the columns), but with possibly varying number of rows; with correponding index operators it behaves like a three-dimensional array with dimensions sample size x observation dimension x runs.
There is a validity method checking for each member of the list being a data frame and for the accordance of the column structures of the data frames.
Objects can be created by calls of the form
SeqDataFrames(...)
, where the ... are a list of dataframes
with according column structure.
data
:a list of data frames
signature(x = "SeqDataFrames")
:
returns (slices of) the data
signature(x = "SeqDataFrames")
:
modifies (slices of) the data
signature(x = "SeqDataFrames", obs0 = NULL,
dims0 = NULL, runs0 = NULL, short = FALSE, ...)
:
slices can be printed and, if argument short== TRUE
only a bounded number of dimensions is shown.
signature(object = "SeqDataFrames")
: a call to
print(x)
signature(x = "SeqDataFrames")
:
returns the names of the runs
signature(x = "SeqDataFrames")
:
returns the names of the runs
signature(x = "SeqDataFrames")
:
returns the names of the observation dimensions
signature(x = "SeqDataFrames")
:
returns the dimension of the observations
signature(x = "SeqDataFrames")
:
returns the number of runs
signature(x = "SeqDataFrames")
:
returns the size of the samples for each run
signature(x = "SeqDataFrames")
:
concatenates different a list of SeqDataFrames
object (with
the same column structure) to a new object of class SeqDataFrames
to do so we mask the rbind
method from package base
Thomas Stabla [email protected],
Florian Camphausen [email protected],
Peter Ruckdeschel [email protected],
Matthias Kohl [email protected]
[-methods
print-methods
summary-methods
simulate-methods
signature(object = "Simulation")
: generates the random numbers for the simulation
signature(object = "Contsimulation")
: generates the random numbers for the simulation
In an object of type Simulation
data can be simulated in any distribution and size.
Objects can be created by calls of the form Simulation(filename, samplesize, runs, seed, distribution)
(observation dimension is deduced from slot distribution
).
A Simulation
-object includes a filename, a name for the simulation, the number of runs, the size of the sample, the seed and the distribution of the
random numbers. The slot Data
stays empty until the method simulate has been used.
seed
:Object of class "list"
: the seed the simulation has been generated with
distribution
:Object of class "UnivariateDistribution"
: the distribution of the random numbers
filename
:Object of class "character"
: the filename the simulation shall be saved
name
:Object of class "character"
: a name for the Simulation
Data
:Object of class "ArrayorNULLorVector"
: the simulated data
samplesize
:Object of class "numeric"
: the size of the sample
obsDim
:Object of class "numeric"
: the dimension of the observations of the data
runs
:Object of class "numeric"
: the number of runs of the data
version
:Object of class "character"
: the version of this package, under which this object was generated
Class "Dataclass"
, directly.
signature(object = "Simulation")
: returns the simulated data.
signature(object = "Simulation")
: ERROR: A modification of simulated data is not allowed.
signature(object = "Simulation")
: returns the the filename
signature(object = "Simulation")
: changes the the filename
signature(object = "Simulation")
: returns the the name
signature(object = "Simulation")
: changes the the name
signature(object = "Simulation")
: returns the distribution
signature(object = "Simulation")
: changes the distribution
signature(object = "Simulation")
: returns the seed
signature(object = "Simulation")
: changes the seed
signature(object = "Simulation")
: returns the dimension of the observations
signature(object = "Simulation")
: returns the version of this package, under which this object was generated
signature(object = "Simulation")
: returns the number of runs
signature(object = "Simulation")
: changes the number of runs
signature(object = "Simulation")
: returns the size of the sample
signature(object = "Simulation")
: changes the size of the sample
signature(object = "Simulation")
: saves the object without the data in the directory of R
(After loading the data can be reproduced by using simulate.)
signature(.Object = "Simulation")
: initialize method
signature(x = "Simulation")
: produces a plot of the data matrix; for details confer plot-methods
signature(x = "Simulation")
: returns filename, seed, the observation dimension,
the number of runs, the size of the sample, the distribution generating the simulations,
and, if from a version > 1.8, also the package version under which the object was generated
signature(x = "Simulation")
: the same as print
.
signature(x = "Simulation")
: generates the random numbers for the simulation
signature(object = "Simulation")
: returns filename, seed, number of runs, the size of the sample
and a statistical summary for each run
Changing distribution, seed, runs or samplesize deletes possibly simulated data, as it would not fit to the new parameters.
Thomas Stabla [email protected],
Florian Camphausen [email protected],
Peter Ruckdeschel [email protected],
Matthias Kohl [email protected]
Dataclass-class
Contsimulation-class
plot-methods
print-methods
summary-methods
simulate-methods
getVersion-methods
N=Norm() # N is a standard normal distribution. S=Simulation(filename="xyz",runs=10,samplesize=3,seed=setRNG(),distribution=N) Data(S) # no data yet simulate(S) Data(S) # now there are random numbers Data(S) # the same data as before because the seed has not changed seed(S)=setRNG() simulate(S) Data(S) # different data savedata(S) # saves the object in the directory of R... load("xyz") # loads it again... Data(S) # ...without the data - use simulate to return it! unlink("xyz")
N=Norm() # N is a standard normal distribution. S=Simulation(filename="xyz",runs=10,samplesize=3,seed=setRNG(),distribution=N) Data(S) # no data yet simulate(S) Data(S) # now there are random numbers Data(S) # the same data as before because the seed has not changed seed(S)=setRNG() simulate(S) Data(S) # different data savedata(S) # saves the object in the directory of R... load("xyz") # loads it again... Data(S) # ...without the data - use simulate to return it! unlink("xyz")
Operators acting on SeqDataFrames
objects to extract
or replace parts.
## S4 method for signature 'SeqDataFrames' x[i, j, k, drop = FALSE] ## S4 replacement method for signature 'SeqDataFrames' x[i, j, k] <- value
## S4 method for signature 'SeqDataFrames' x[i, j, k, drop = FALSE] ## S4 replacement method for signature 'SeqDataFrames' x[i, j, k] <- value
x |
object of class |
i |
observation index; may be missing |
j |
observation dimension index; may be missing |
k |
run index; may be missing |
drop |
as in the general indexing functions |
value |
modification to be assigned to |
again an object of class SeqDataFrames
with the prescribed indices / values
signature(x = "SeqDataFrames")
:
access method for indices for objects of class SeqDataFrames
signature(x = "SeqDataFrames")
:
replacement method for indices for objects of class SeqDataFrames
s0 <- matrix(1:6,3,2) d0 <- data.frame(s0) d1 <- data.frame(s0 + 3) SF <- SeqDataFrames(d0, d1) SF[1,2,1]
s0 <- matrix(1:6,3,2) d0 <- data.frame(s0) d1 <- data.frame(s0 + 3) SF <- SeqDataFrames(d0, d1) SF[1,2,1]
summary-methods
signature(object = "Dataclass")
: returns the same information as print,
moreover a statistical summary for each run; optional arguments:
the indices of runs to be summarized; — of this vector runs0
maximally MaxNumberofSummarizedRuns
runs are summarized where MaxNumberofSummarizedRuns
is a global option, see distrSimoptions
the indices of observation dimensions to be summarized; — of this vector dims0
maximally MaxNumberofSummarizedObsDims
dimensions are summarized where MaxNumberofSummarizedObsDims
is a global option, see distrSimoptions
signature(object = "Simulation")
: returns name, filename,
seed, number of runs, the size of the sample and a
statistical summary for each run; optional arguments: as with signature(object = "Dataclass")
signature(object = "Contsimulation")
: returns name, filename,
seed, number of runs, the size of the sample, the
rate and a statistical summary for each run of the real data; optional arguments:
as with signature(object = "Dataclass")
auxiliary classes; may contain either a vector or NULL, [or a matrix, or an array, respectively], cf. J. Chambers, "green book".
these classes are all virtual: No objects may be created from it.
No methods defined with classs "vectororNULL", "MatrixorNULLorVector", and
"ArrayorNULLorVectororDataframeorSeqDataFrames" in the signature.
However, the generating function Dataclass
dispatches according to
"DataframeorSeqDataFrames" or "ArrayorNULLorVector".
Dataclass-class can save data either of type "NULL" (means no data) or "vector" or "array" or "data.frame"
Thomas Stabla [email protected],
Florian Camphausen [email protected],
Peter Ruckdeschel [email protected],
Matthias Kohl [email protected]
Version-Management-methods
## S4 method for signature 'Dataclass' getVersion(object) ## S4 method for signature 'Dataclass' conv2NewVersion(object)
## S4 method for signature 'Dataclass' getVersion(object) ## S4 method for signature 'Dataclass' conv2NewVersion(object)
object |
object of class |
From version 1.8 of this package on, we have changed the format how data / simulations are stored:
In order to be able to cope with multivariate distributions, regression distributions and (later)
time series distributions, we have switched to the common array format:
samplesize x obsDim x runs; for saved objects from earlier versions, we provide the functions
isOldVersion
(from package distr) and conv2NewVersion
to check whether the object was generated by an
older version of this package and to convert such an object to the new format, respectively.
signature(object = "Dataclass")
: returns slot version
of an object
of class "Dataclass"
.
signature(object = "Dataclass")
:
changes an object with format runs x samplesize (old format) to
samplesize x obsDim x runs (new format)