get_split_indexes_from_stratum {splithalfr}R Documentation

Generate indexes that can be used to split a stratum into two parts

Description

get_split_indexes_from_stratum returns a list with indexes for splitting its stratum argument in two parts. The splits differ at most by one in size. With default arguments, a random split-half is returned, which samples elements for each part from stratum without replacement. Via additional arguments to get_split_indexes_from_stratum a range of other splitting methods can be applied.

Usage

get_split_indexes_from_stratum(
  stratum,
  method = c("random", "odd_even", "first_second"),
  replace = FALSE,
  split_p = 0.5,
  subsample_p = 1,
  careful = TRUE
)

Arguments

stratum

(data frame, tibble, list, or vector) Object to split; dataframes and tibbles are counted and split by row. All other data types are counted and split by element

method

(character) Splitting method. Note that first_second and odd_even splitting method will only deliver a valid split with default settings for other arguments (subsample_p = 1, split_p = 1, replace = TRUE)

replace

(logical) If FALSE, splits are constructed by sampling from stratum without replacement. If TRUE, stratum is sampled with replacement.

split_p

(numeric) Desired joint size of both parts, expressed as a proportion of the size of the subsampled stratum. If split_p is larger than 1, and careful is FALSE, then parts are automatically sampled with replacement

subsample_p

(numeric) Subsample a proportion of stratum to be used in the split.

careful

(boolean) If TRUE, stop with an error when called with arguments that may yield unexpected splits

Details

The following rounding rules apply to subsample size and split size:

Value

(list) List with two elements that contain indexes that can be used to split the stratum in two parts two splits of stratum.

See Also

Other splitting functions: apply_split_indexes_to_strata(), apply_split_indexes_to_stratum(), check_strata(), get_split_indexes_from_strata(), split_df(), split_strata(), split_stratum(), stratify()

Examples

# Split-half. One of the splits gets 4 elements and the other 5
stratum = letters[1:9]
indexes = get_split_indexes_from_stratum(stratum)
apply_split_indexes_to_stratum(stratum, indexes[[1]], indexes[[2]])

[Package splithalfr version 2.2.2 Index]