set_blocks_from_df: Prepare blocks of items from a data frame

View source: R/data-helpers.R

set_blocks_from_dfR Documentation

Prepare blocks of items from a data frame

Description

Prepare blocks of items and incorporate information about which item belongs to which trait from a pre-existing dataframe. This is a wrapper function for set_block, eliminating the need to manually set each item, trait, name and sign (loading) info per block.

Usage

set_blocks_from_df(
  data,
  blocks = "block",
  items = "item",
  traits = "trait",
  names = items,
  signs = "sign"
)

Arguments

data

A data.frame containing all the required columns (see the arguments below) to specify the item blocks.

blocks

Name of column vector denoting the block each item corresponds to. Each block must have an equal number of items.

items

Name of column vector denoting items to be combined into one block. Should correspond to variables in the data.

traits

Names of column vector denoting the traits to which each item belongs.

names

Optional column vector of item names in the output. Can be used to equate parameters of items across blocks, if the same item was used in different blocks.

signs

Name of column vector with expected signs of the item loadings (1 or -1).

Details

A block of items is a set of two or more items presented and answered together by fully ranking them or selecting the most and/or least favorite in a forced choice format. A whole test usually contains several blocks and items may reappear in different blocks.

See Also

set_block

Examples

block_info <- data.frame(
  block = rep(1:4, each = 3),
  items = c("i1", "i2", "i3", "i4", "i5", "i6",
            "i7", "i8", "i9", "i10", "i11", "i12"),
  traits = rep(c("t1", "t2", "t3"), times = 4),
  signs = c(1, 1, 1, -1, 1, 1, 1, 1, -1, 1, -1, 1)
)

blocks <- set_blocks_from_df(
  data = block_info,
  blocks = "block",
  items = "items",
  traits = "traits",
  signs = "signs"
)


thurstonianIRT documentation built on Aug. 22, 2023, 5:08 p.m.