Contsimulation-class {distr}R Documentation

Class "Contsimulation"

Description

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 is contaminated.

Objects from the Class

Objects can be created by calls of the form Contsimulation(filename, runs, samplesize, seed, distribution.id, distribution.c, rate). 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.

Slots

ind:
Object of class "vectororNULL": 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 "vectororNULL": – the ideal data
Data.c:
Object of class "vectororNULL": – 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
filename:
Object of class "character": the filename the Contsimulation shall be saved
Data:
Object of class "vectororNULL": the simulated data
runs:
Object of class "numeric": the number of runs of the data
samplesize:
Object of class "numeric": the size of the sample, so the dimension of the data

Extends

Class "Dataclass", directly.

Methods

Data.c
signature(object = "Contsimulation"): returns the contaminated data
Data.id
signature(object = "Contsimulation"): returns the ideal data
Data<-
signature(object = "Contsimulation"): ERROR: A modification of simulated data is not allowed.
distribution.c
signature(object = "Contsimulation"): returns the distribution of the contaminated data
distribution.c<-
signature(object = "Contsimulation"): changes the distribution of the contaminated data
distribution.id
signature(object = "Contsimulation"): returns the distribution of the ideal data
distribution.id<-
signature(object = "Contsimulation"): changes the distribution of the ideal data
seed
signature(object = "Contsimulation"): returns the seed
seed<-
signature(object = "Contsimulation"): changes the seed
ind
signature(object = "Contsimulation"): returns the indicator which saves which data is contaminated
initialize
signature(.Object = "Contsimulation"): initialize method
rate
signature(object = "Contsimulation"): returns the contamination rate
rate<-
signature(object = "Contsimulation"): changes the contamination rate
runs<-
signature(object = "Contsimulation"): changes the number of runs
samplesize<-
signature(object = "Contsimulation"): changes the size of the sample
savedata
signature(object = "Contsimulation"): saves the simulation in the directory of R
simulate
signature(x = "Contsimulation"): generates the random numbers for the simulation
plot
signature(x = "Contsimulation"): produces a plot of the real data matrix
print
signature(x = "Contsimulation"): returns filename, seed, number of runs, the size of the sample, the rate and the distributions
summary
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

Note

Changing distributions, seed, runs, samplesize or rate deletes possibly simulated data, as it would not fit to the new parameters.

Author(s)

Thomas Stabla Thomas.Stabla@uni-bayreuth.de,
Florian Camphausen Florian.Camphausen@uni-bayreuth.de,
Peter Ruckdeschel Peter.Ruckdeschel@uni-bayreuth.de,
Matthias Kohl Matthias.Kohl@uni-bayreuth.de

See Also

Dataclass-class Simulation-class savedata-methods plot-methods simulate-methods summary-methods

Examples

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
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!

[Package distr version 1.5 Index]