R: Standard normal (Z) to Johnson variable (Y) transformation
yJohnsonDistribution
R Documentation
Standard normal (Z) to Johnson variable (Y) transformation
Description
A normal variable with mean zero and variance one is transformed to a Johnson distribution variate
specified by the Johnson distribution parameters.
This is useful in simulating random variables from a specified Johnson distribution
and in computing the quantiles for a Johnson distribution.
Our function provides an interface to the Fortran algorithm AS 100 (Hill, 1976).
Value
Corresponding vector of Johnson distribution variables.
Note
The input parameters ITYPE, GAMMA, DELTA, XLAM, XI must all be scalars.
An error is given if they are not.
Author(s)
A. I. McLeod and Leanna King
References
I. D. Hill,
Algorithm AS 100.
Normal-Johnson and Johnson-normal transformations,
Appl. Statist.,25, No. 2, 190-192 (1976).
See Also
zJohnsonDistribution,
FitJohnsonDistribution
Examples
#Example 1.
#fit SL with mean 1, variance 1, skewness 2 then find corresponding variate to Z=2
ans <- FitJohnsonDistribution(1, 1, 2, -1)
GAMMA <- ans["GAMMA"]
DELTA <- ans["DELTA"]
XLAM <- ans["XLAM"]
XI <- ans["XI"]
ITYPE <- 1
z <- 2
yJohnsonDistribution(z, ITYPE, GAMMA, DELTA, XLAM, XI)
#Example 2: find quantiles of SL distribution
#The 0.01, 0.05, 0.1, 0.25, 0.5, 0.75, 0.9, 0.95, 0.99
#quantiles for an SL distribution are found and a qq plot is produced.
#SL distribution parameters is determined
# with mean 1, standard deviation 1, skewness 3
ans <- FitJohnsonDistribution(1, 1, 3, -1)
GAMMA <- ans["GAMMA"]
DELTA <- ans["DELTA"]
XLAM <- ans["XLAM"]
XI <- ans["XI"]
ITYPE <- 1
p<-c(0.01, 0.05, 0.1, 0.25, 0.5, 0.75, 0.9, 0.95, 0.99)
z <- qnorm(p)
y<-yJohnsonDistribution(z, ITYPE, GAMMA, DELTA, XLAM, XI)
plot(z,y,xlab="normal quantiles", ylab="SL quantiles")
#
#Example 3: simulate SL distribution
#with mean 1, sd 1 and skewness 3
#plot estimated pdf
ans <- FitJohnsonDistribution(1, 1, 3, -1)
GAMMA <- ans["GAMMA"]
DELTA <- ans["DELTA"]
XLAM <- ans["XLAM"]
XI <- ans["XI"]
ITYPE <- 1
z <- rnorm(1000)
y <- yJohnsonDistribution(z, ITYPE, GAMMA, DELTA, XLAM, XI)
pdf <- density(y, bw = "sj")
plot(pdf, main="Estimated pdf of SL with mean 1, sd 1, g1 3", xlab="x", ylab="est.pdf(x)" )
Results
R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)
R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.
R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.
Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.
> library(JohnsonDistribution)
> png(filename="/home/ddbj/snapshot/RGM3/R_CC/result/JohnsonDistribution/yJohnsonDistribution.Rd_%03d_medium.png", width=480, height=480)
> ### Name: yJohnsonDistribution
> ### Title: Standard normal (Z) to Johnson variable (Y) transformation
> ### Aliases: yJohnsonDistribution
> ### Keywords: distribution
>
> ### ** Examples
>
> #Example 1.
> #fit SL with mean 1, variance 1, skewness 2 then find corresponding variate to Z=2
> ans <- FitJohnsonDistribution(1, 1, 2, -1)
> GAMMA <- ans["GAMMA"]
> DELTA <- ans["DELTA"]
> XLAM <- ans["XLAM"]
> XI <- ans["XI"]
> ITYPE <- 1
> z <- 2
> yJohnsonDistribution(z, ITYPE, GAMMA, DELTA, XLAM, XI)
[1] 3.663545
> #Example 2: find quantiles of SL distribution
> #The 0.01, 0.05, 0.1, 0.25, 0.5, 0.75, 0.9, 0.95, 0.99
> #quantiles for an SL distribution are found and a qq plot is produced.
> #SL distribution parameters is determined
> # with mean 1, standard deviation 1, skewness 3
> ans <- FitJohnsonDistribution(1, 1, 3, -1)
> GAMMA <- ans["GAMMA"]
> DELTA <- ans["DELTA"]
> XLAM <- ans["XLAM"]
> XI <- ans["XI"]
> ITYPE <- 1
> p<-c(0.01, 0.05, 0.1, 0.25, 0.5, 0.75, 0.9, 0.95, 0.99)
> z <- qnorm(p)
> y<-yJohnsonDistribution(z, ITYPE, GAMMA, DELTA, XLAM, XI)
> plot(z,y,xlab="normal quantiles", ylab="SL quantiles")
> #
> #Example 3: simulate SL distribution
> #with mean 1, sd 1 and skewness 3
> #plot estimated pdf
> ans <- FitJohnsonDistribution(1, 1, 3, -1)
> GAMMA <- ans["GAMMA"]
> DELTA <- ans["DELTA"]
> XLAM <- ans["XLAM"]
> XI <- ans["XI"]
> ITYPE <- 1
> z <- rnorm(1000)
> y <- yJohnsonDistribution(z, ITYPE, GAMMA, DELTA, XLAM, XI)
> pdf <- density(y, bw = "sj")
> plot(pdf, main="Estimated pdf of SL with mean 1, sd 1, g1 3", xlab="x", ylab="est.pdf(x)" )
>
>
>
>
>
> dev.off()
null device
1
>