Description Usage Arguments Value Author(s) Examples
View source: R/rank_transform_distr_function.R
Rank transform a dataset, i.e., for each input value provide an output value from a given probability distribution, with the order of values (ranks) being preserved.
1 | rank_transform_distr(x, distr = "norm", ...)
|
x |
Input vector |
distr |
Character naming output distribution function (e.g. "norm", "lnorm", "unif", "exp", "gamma",...). Use "trunc" for truncated distributions as provided by the truncdist package. See examples below for parameter settings. |
... |
Distribution parameters (see examples below) |
Vector of transformed values
Nikolai Knapp, nikolai.knapp@ufz.de
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | # Transform values from 1 to 100 into a normal distribution
test.vec <- 1:100
norm.vec <- rank_transform_distr(x=test.vec, distr="norm", mean=55, sd=5)
hist(test.vec)
hist(norm.vec)
# Transform into a gamma distribution
gamma.vec <- rank_transform_distr(x=norm.vec, distr="gamma",
shape=0.5, rate=1)
hist(gamma.vec)
# Transform into a truncated lognormal distribution
require(truncdist)
trunc.lnorm.vec <- rank_transform_distr(x=gamma.vec, distr="trunc",
meanlog=3, sdlog=0.5,
spec="lnorm", a=10, b=40)
hist(trunc.lnorm.vec)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.