form_blocks_from_continuous: Cut continuous covariate into similar-valued blocks

View source: R/gen_blocked_data.R

form_blocks_from_continuousR Documentation

Cut continuous covariate into similar-valued blocks

Description

Make blocks out of a continuous covariate by cutting it into pieces that are ideally relatively homogenous. This will create a bunch of blocks based on passed covariate and return a factor vector of those blocks.

Usage

form_blocks_from_continuous(
  X,
  method = c("small", "pair", "big", "none"),
  num.blocks
)

Arguments

X

covariate vector to block on

method

How to block. "small" "pair" makes matched pairs. "big" makes as many blocks of at least 4 as possible, trying to keep blocks small. "none" makes a single block.

num.blocks

If method is small, how many blocks to attempt to make

Value

Vector with one element per element of 'X'

Examples

table( form_blocks_from_continuous( 1:22, method="small" ) )
table( form_blocks_from_continuous( 1:22, method="big", num.blocks=3 ) )
table( form_blocks_from_continuous( 1:22, method="pair" ) )
table( form_blocks_from_continuous( 1:22, method="none" ) )
table( form_blocks_from_continuous( 1:22, method="big" ) )

lmiratrix/blkvar documentation built on Nov. 18, 2024, 1:27 p.m.