Learn R Programming

hbamr (version 2.3.2)

prep_data_cv: Prepare data for a K-fold cross-validation of an HBAM model

Description

This function turns data prepared for hbam() into a list of K versions, where each version includes a different vector identifying holdout-data.

Usage

prep_data_cv(data, K = 10, seed = 1)

Value

A list of K data objects where each version includes a different vector identifying holdout-data.

Arguments

data

A list of data produced by prep_data().

K

An integer above 2, specifying the number of folds to use in the analysis. Defaults to 10.

seed

An integer passed on to set.seed before creating the folds to increase reproducibility. Defaults to 1.

Examples

Run this code
# Loading and re-coding ANES 1980 data:
data(LC1980)
LC1980[LC1980 == 0 | LC1980 == 8 | LC1980 == 9] <- NA
self <- LC1980[, 1]
stimuli <- LC1980[, -1]
dat <- prep_data(self, stimuli)

# Prepare data for cross-validation:
dat_cv <- prep_data_cv(dat, K = 10)

Run the code above in your browser using DataLab