Description Usage Arguments Objects from the Class Slots Details Extends Accessor methods Methods UML class diagram Author(s) See Also

Class for controlling the setup of samples using a two-stage procedure.

1 2 3 4 |

`...` |
the slots for the new object (see below). |

`fun1` |
the function to be used for sampling in the first stage (the
first list component of slot |

`fun2` |
the function to be used for sampling in the second stage (the
second list component of slot |

`size1` |
the number of PSUs to sample in the first stage (the first list
component of slot |

`size2` |
the number of items to sample in the second stage (the second
list component of slot |

`prob1` |
the probability weights for the first stage (the first list
component of slot |

`prob2` |
the probability weights for the second stage (the second list
component of slot |

`dots1` |
additional arguments to be passed to the function for sampling
in the first stage (the first list component of slot |

`dots2` |
additional arguments to be passed to the function for sampling
in the second stage (the second list component of slot |

Objects can be created via the constructor `TwoStageSampleControl`

or by
calls of the form `SampleControl(..., sub = "TwoStage")`

.

`design`

:An optional character, integer or logical vector specifying variables (columns) to be used for stratified sampling in the first stage.

`grouping`

:An character, integer or logical vector specifying grouping variables (columns) to be used for sampling primary sampling units (PSUs) and, optionally, secondary sampling units (SSUs).

`fun`

:A list of length two containing the functions to be used for sampling in the first and second stage, respectively (defaults to

`srs`

for both stages). The functions should return a vector containing the indices of the sampled items.`size`

:A list of length two, in which each component contains an optional non-negative integer giving the number of items to sample in the first and second stage, respectively. In case of stratified sampling in the first stage, a vector of non-negative integers, each giving the number of PSUs to sample from the corresponding stratum, may be supplied. For the second stage, a vector of non-negative integers giving the number of items to sample from each PSU may be used.

`prob`

:A list of length two, with components optionally specifying variables (columns) that contain probability weights for the first and second stage, respectively.

`dots`

:A list of length two, in which each component is again a list containing additional arguments to be passed to the corresponding function for sampling in

`fun`

.`k`

:A positive integer giving the number of samples to be set up.

`seed`

:An optional integer to be used as initial seed of the random number generator.

There are some restrictions on the argument names of the functions for
sampling in `fun`

. If the sampling method needs population data as
input, the corresponding argument should be called `x`

and should expect
a data frame. If it only needs the population size as input, the argument
should be called `N`

. Note that the function is not expected to have
both `x`

and `N`

as arguments, and that the latter is typically
much faster. Furthermore, if the function has arguments for sample size and
probability weights, they should be called `size`

and `prob`

,
respectively. Note that a function with `prob`

as its only argument is
perfectly valid (for probability proportional to size sampling). Further
arguments may be supplied as a list via the slot `dots`

.

Class `"SampleControl"`

, directly.
Class `"VirtualSampleControl"`

, distance 2.
Class `"OptSampleControl"`

, distance 3.

The following accessor methods are available in addition to the inherited ones:

`getCollect`

`signature(x = "TwoStageControl")`

: get slot`collect`

.`getFun`

`signature(x = "TwoStageControl")`

: get slot`fun`

.`getSize`

`signature(x = "TwoStageControl")`

: get slot`size`

.`getProb`

`signature(x = "TwoStageControl")`

: get slot`prob`

.`getDots`

`signature(x = "TwoStageControl")`

: get slot`dots`

.

The following methods are available in addition to the inherited ones:

`setup`

`signature(x = "data.frame", control = "TwoStageSampleControl")`

: set up multiple samples.`show`

`signature(object = "TwoStageSampleControl")`

: print the object on the**R**console.

A slightly simplified UML class diagram of the framework can be found in
Figure 1 of the package vignette *An Object-Oriented Framework for
Statistical Simulation: The R Package simFrame*. Use

`vignette("simFrame-intro")`

to view this vignette.
Andreas Alfons

`"BasicSampleControl"`

,
`"SampleSetup"`

,
`setup`

, `draw`

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.