Learn R Programming

StratifiedSampling (version 0.4.1)

findB: Find best sub-matrix B in stratifiedcube

Description

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

Usage

findB(X, strata)

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.

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.

Author

Raphaël Jauslin raphael.jauslin@unine.ch

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.

Examples

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

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

Run the code above in your browser using DataLab