Learn R Programming

simFrame (version 0.1.2)

plot-methods: Plot simulation results

Description

Plot simulation results. A suitable plot function is selected automatically, depending on the structure of results.

Usage

## S3 method for class 'SimResults,missing':
plot(x, y , \dots)

Arguments

x
the simulation results.
y
not used.
...
further arguments to be passed to the selected plot function.

Details

The results of simulation experiments with at most one contamination level and at most one missing value rate are visualized by (conditional) box-and-whisker plots. For simulations involving different contamination levels or missing value rates, the average results are plotted against the contamination levels or missing value rates. Currently no plot function is implemented for simulations with more than one contamination level and more than one missing value rate.

Value

An object of class "trellis". The update method can be used to update components of the object and the print method (usually called by default) will plot it on an appropriate plotting device.

See Also

simBwplot, simDensityplot, simXyplot, SimResults

Examples

Run this code
## for reproducibility
set.seed(1234)

## function for generating data
grnorm <- function(n, means) {
    group <- sample(1:2, n, replace=TRUE)
    data.frame(group=group, value=rnorm(n) + means[group])
}

## control objects for data generation and contamination
means <- c(0, 0.5)
dc <- DataControl(size = 500, distribution = grnorm, 
    dots = list(means = means))
cc <- DCARContControl(target = "value", 
    epsilon = 0.1, dots = list(mean = 10))

## function for simulation runs
sim <- function(x) {
    c(mean = mean(x$value), 
        trimmed = mean(x$value, trim = 0.1), 
        median = median(x$value))
}

## run simulation
results <- runSimulation(dc, nrep = 50, 
    contControl = cc, design = "group", fun = sim)

## plot results
plot(results, true = means)

Run the code above in your browser using DataLab