Edit 3.
library(Johnson)
set.seed(1)
n <- 252
log_mydata1 <- runif(n, min=-0.06, max= 0.05)
# Applying SU Johnson transformation
jt_mydata1<-RE.Johnson(log_mydata1)
z1 <- jt_mydata1$transformed; shapiro.test(z1) # W = 0.99495, p-value = 0.5748
mean(z1); sd(z1) # -0.02276707, 1.002103
# fpar1 <- ArimaModelFit(z1)
# Coefficients:
# ar1 ar2 ar3 ma1 ma2 intercept
# 0.5520 0.4231 -0.1234 -0.5468 -0.4532 -0.0302
# s.e. 0.3582 0.3492 0.0666 0.3572 0.3570 0.0075
#ARMA Simulation
sim1 <- arima.sim(list(order = c(3,0,2),
ar = c(0.5520, 0.4231, -0.1234),
ma = c(-0.5468, -0.4532)), n = n)
mean(sim1);sd(sim1) # -0.0350542, 1.041598
shapiro.test(sim1) # W = 0.99285, p-value = 0.2675
# convert an normalized variable back to a marginal variable
gamma1 <- jt_mydata1$f.gamma
lambda1 <- jt_mydata1$f.lambda
epsilon1 <- jt_mydata1$f.epsilon
eta1 <- jt_mydata1$f.eta
# SU
# inv_jt_mydata1 <- lambda1 * sinh((sim1 - gamma1)/eta1) + epsilon1
mean(# SB
inv_jt_mydata1 <- ((lambda1 + epsilon1);sd* exp(inv_jt_mydata1(sim1 - gamma1)
#[1]/eta1) + epsilon1)/(1+exp((sim1 -0.09473195
#[1] 0.4666171gamma1)/eta1))
The p-value of Kolmogorov-Smirnov test is less 2.2e-16 and$0.97$
ks.test(log_mydata1, inv_jt_mydata1)
# D = 0.53571043651, p-value <= 20.2e-1697
# alternative hypothesis: two-sided