# NOT RUN {
# Logistic Distribution: mean = 0, variance = 1
seed = 1234
# Find standardized cumulants
stcum <- calc_theory(Dist = "Logistic", params = c(0, 1))
# Simulate without the sixth cumulant correction
# (invalid power method pdf)
Logvar1 <- nonnormvar1(method = "Polynomial", means = 0, vars = 1,
skews = stcum[3], skurts = stcum[4],
fifths = stcum[5], sixths = stcum[6],
n = 10000, seed = seed)
# Plot pdfs of simulated variable (invalid) and theoretical distribution
plot_sim_pdf_theory(sim_y = Logvar1$continuous_variable,
title = "Invalid Logistic Simulated PDF",
overlay = TRUE, Dist = "Logistic", params = c(0, 1))
# Simulate with the sixth cumulant correction
# (valid power method pdf)
Logvar2 <- nonnormvar1(method = "Polynomial", means = 0, vars = 1,
skews = stcum[3], skurts = stcum[4],
fifths = stcum[5], sixths = stcum[6],
Six = seq(1.5, 2, 0.05), n = 10000, seed = seed)
# Plot pdfs of simulated variable (invalid) and theoretical distribution
plot_sim_pdf_theory(sim_y = Logvar2$continuous_variable,
title = "Valid Logistic Simulated PDF",
overlay = TRUE, Dist = "Logistic", params = c(0, 1))
# Simulate 2 Negative Binomial distributions and correlation 0.3
# using Method 1
NBvars <- rcorrvar(k_nb = 2, size = c(10, 15), prob = c(0.4, 0.3),
rho = matrix(c(1, 0.3, 0.3, 1), 2, 2), seed = seed)
# Plot pdfs of 1st simulated variable and theoretical distribution
plot_sim_pdf_theory(sim_y = NBvars$Neg_Bin_variable[, 1], overlay = TRUE,
cont_var = FALSE, Dist = "Negative_Binomial",
params = c(10, 0.4))
# }
# NOT RUN {
# }
Run the code above in your browser using DataLab