rand_var: Permute each column of a matrix by sampling from empirical...

Description Usage Arguments Value Author(s) Examples

View source: R/rand_var.R

Description

This function uses permutations or sampling with replacement to disrupt relationships between variables but keep the distribution of each variable constant. Variables should be in columns of a matrix.

Usage

1
rand_var(x, MARGIN = 2, replace = FALSE, prob = NULL)

Arguments

x

matrix to be permuted

MARGIN

which dimension of a matrix to permute? Passed to apply.

replace

should sampling be with replacement? Passed to sample.int.

prob

a vector of probability weights for obtaining the elements of the vector being sampled. Passed to sample.int.

Value

Matrix of the same dimention as the original matrix but with values in each column permuted.

Author(s)

Vitalii Kleshchevnikov

Examples

1
2
3
4
set.seed(4354)
N = 100
x = matrix(rnorm(N * 10 * N), N * 10, N)
x_rand = rand_var(x, MARGIN = 2, replace = FALSE, prob = NULL)

vitkl/ParetoTI documentation built on Feb. 11, 2020, 1:36 a.m.