otsort: otsort

View source: R/otsort.R

otsortR Documentation

otsort

Description

Given a q-dimensional random vector \mathbf{X} = (\mathbf{X}_{1},...,\mathbf{X}_{k}) with \mathbf{X}_{i} a d_{i}-dimensional random vector, i.e., q = d_{1} + ... + d_{k}, this function sorts the columns (variables) of a sample of \mathbf{X} such that the dimensions are in ascending order.

Usage

otsort(sample, dim)

Arguments

sample

A sample from a q-dimensional random vector \mathbf{X} (n \times q matrix with observations in rows, variables in columns).

dim

The vector of dimensions (d_{1},...,d_{k}), in order as given in sample.

Details

The columns of sample are rearranged such that the data corresponding to the random vector \mathbf{X}_{i} having the smallest dimension d_{i} comes first, then the random vector with second smallest dimension, and so on.

Value

A list with elements "sample" containing the ordered sample, and "dim" containing the ordered dimensions.

Examples

q = 10
n = 50
dim = c(2,3,1,4)

# Sample from multivariate normal distribution
sample = mvtnorm::rmvnorm(n,rep(0,q),diag(q), method = "chol")

ordered = otsort(sample,dim)

VecDep documentation built on April 4, 2025, 5:14 a.m.