quanttrans: Quantile Transformations

qfactorR Documentation

Quantile Transformations

Description

A collection of functions that transform the margins of a Latin hypercube sample in multiple ways

Usage

qfactor(p, fact)

qinteger(p, a, b)

qdirichlet(X, alpha)

Arguments

p

a vector of LHS samples on (0,1)

fact

a factor or categorical variable. Ordered and un-ordered variables are allowed.

a

a minimum integer

b

a maximum integer

X

multiple columns of an LHS sample on (0,1)

alpha

Dirichlet distribution parameters. All alpha >= 1 The marginal mean probability of the Dirichlet distribution is given by alpha[i] / sum(alpha)

Details

qdirichlet is not an exact quantile function since the quantile of a multivariate distribution is not unique. qdirichlet is also not the independent quantiles of the marginal distributions since those quantiles do not sum to one. qdirichlet is the quantile of the underlying gamma functions, normalized. This is the same procedure that is used to generate random deviates from the Dirichlet distribution therefore it will produce transformed Latin hypercube samples with the intended distribution.

q_factor divides the [0,1] interval into nlevel(fact) equal sections and assigns values in those sections to the factor level.

Value

the transformed column or columns

Examples

X <- randomLHS(20, 7)
Y <- as.data.frame(X)
Y[,1] <- qnorm(X[,1], 2, 0.5)
Y[,2] <- qfactor(X[,2], factor(LETTERS[c(1,3,5,7,8)]))
Y[,3] <- qinteger(X[,3], 5, 17)
Y[,4:6] <- qdirichlet(X[,4:6], c(2,3,4))
Y[,7] <- qfactor(X[,7], ordered(LETTERS[c(1,3,5,7,8)]))

lhs documentation built on July 1, 2024, 1:06 a.m.