create.samples: Create a Sample Membership Character Variable

Description Usage Arguments Details Value Author(s) See Also Examples

View source: R/BCA.R

Description

Provides a character vector with possible values of "Estimation", "Validation" and "Holdout" that can then be used to assign observations of a data frame to estimation, validation, or (optionally) holdsout samples using the subset option of a variety of functions.

Usage

1
create.samples(x, est=0.34, val=0.33, rand.seed=1)

Arguments

x

A data frame.

est

The percentage of the total sample to allocate to the estimation sample. The value of est should range from zero to one

val

The percentage of the total sample to allocate to the validation sample. The value of val should range from zero to one

rand.seed

A parameter passed to set.seed for to specify the seed of the random number generator.

Details

The values of est and val should sum to a value between zero and one. If greater than one, an error is returned. If less than one, the remaining percentage of the sample is allocated to the holdout sample.

Value

A character vector with possible values of "Estimation", "Validation" and (optionally) "Holdout". The length of the vector equals the number of rows in the original data frame.

Author(s)

Dan Putler

See Also

set.seed

Examples

1
2
3
4
5
  data(CCS)
  # Create a new set of samples with 40 percent in each of the estimation and
  # validation samples, and 20 percent in the holdout sample.
  CCS$Sample <- create.samples(CCS, est=0.4, val=0.4)
  

BCA documentation built on May 2, 2019, 1:26 p.m.

Related to create.samples in BCA...