#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)" )
Run the code above in your browser using DataLab