nsim <- 3000
para <- list(alpha=0.15, beta=0.65,
cop1=PLACKETTcop, cop2=PLACKETTcop, para1=.005, para2=1000)
set.seed(10)
uv <- simCOP(n=nsim, cop=composite2COP, para=para, pch=16, col=rgb(0,0,0,0.2))
uv.grid <- EMPIRgrid(para=uv, deluv=.1)
set.seed(1)
V1 <- EMPIRsimv(u=0.6, n=nsim, empgrid=uv.grid)
set.seed(1)
V2 <- EMPIRsimv(u=0.6, n=nsim, empgrid=uv.grid, kumaraswamy=TRUE)
invgrid1 <- EMPIRgridderinv(empgrid=uv.grid)
invgrid2 <- EMPIRgridderinv(empgrid=uv.grid, kumaraswamy=TRUE)
att <- attributes(invgrid2); kur <- att$kumaraswamy
# Now draw random variates from the Kumaraswamy distribution using
# rlmomco() and vec2par() provided by the lmomco package.
set.seed(1)
Vsim <- rlmomco(nsim, vec2par(c(kur$Alpha[7], kur$Beta[7]), type="kur"))
print(summary(V1)) # Kumaraswamy not core in QDF reconstruction
print(summary(V2)) # Kumaraswamy core in QDF reconstruction
print(summary(Vsim)) # Kumaraswamy use of the kumaraswamy
# Continuing with a conditional quantile 0.74 that will not
# land along one of the grid lines, a weighted interpolation will be done.
set.seed(1) # try not resetting the seed
nsim <- 5000
V <- EMPIRsimv(u=0.74, n=nsim, empgrid=uv.grid)
# It is important that the uv.grid used to make V is the same grid used
# in inversion with kumaraswamy=TRUE to guarantee that the correct
# Kumaraswamy parameters are available if a user is doing cut and paste
# and exploring these examples.
set.seed(1)
V1 <- rlmomco(nsim, vec2par(c(kur$Alpha[8], kur$Beta[8]), type="kur"))
set.seed(1)
V2 <- rlmomco(nsim, vec2par(c(kur$Alpha[9], kur$Beta[9]), type="kur"))
plot(pp(V), sort(V), type="l", lwd=4, col=8) # Grey is empirical from grid
lines(pp(V1), sort(V1), col=2, lwd=2) # Kumaraswamy at u=0.7
lines(pp(V2), sort(V2), col=3, lwd=2) # Kumaraswamy at u=0.8
W1 <- 0.74 - 0.7; W2 <- 0.8 - 0.74
Vblend <- (V1/W1 + V2/W2) / sum(1/W1 + 1/W2)
lines(pp(Vblend), sort(Vblend), col=4, lwd=2) # BLUE LINE
# Notice how the grey line and the blue diverge for about F < 0.1 and F > 0.9.
# These are the limits of the grid spacing and linear interpolation within the
# grid intervals is being used and not direct simulation from the Kumaraswamy.
Run the code above in your browser using DataLab