findB: Find best sub-matrix B in stratifiedcube

View source: R/findB.R

findBR Documentation

Find best sub-matrix B in stratifiedcube

Description

This function is computing a sub-matrix used in stratifiedcube.

Usage

findB(X, strata)

Arguments

X

A matrix of size (N x p) of auxiliary variables on which the sample must be balanced.

strata

A vector of integers that specifies the stratification.

Details

The function finds the smallest matrix B such that it contains only one more row than the number of columns. It consecutively adds the right number of rows depending on the number of categories that is added.

Value

A list of two components. The sub-matrix of X and the corresponding disjunctive matrix. If we use the function cbind to combine the two matrices, the resulting matrix has only one more row than the number of columns.

Author(s)

Raphaël Jauslin raphael.jauslin@unine.ch

Examples

N <- 1000
strata <-  sample(x = 1:6, size = N, replace = TRUE)

p <- 3
X <- matrix(rnorm(N*p),ncol = 3)
findB(X,strata)


StratifiedSampling documentation built on Oct. 26, 2022, 5:09 p.m.