# This is the canonical test of lmrdiscord().
library(lmomRFA) # Import lmomRFA, needs lmom package too
data(Cascades) # Extract Hosking's data use in his examples
data <- as.regdata(Cascades) # A "regional" data structure
Dhosking <- sort(regtst(data)$D, decreasing=TRUE) # Discordancy
Dlmomco <- lmrdiscord(site=data$name,
t2=data$t, t3=data$t_3, t4=data$t_4)
Dasquith <- Dlmomco$D
# Now show the site id, and the two discordancy computations
print(data.frame(NAME=data$name, Dhosking=Dhosking,
Dasquith=Dasquith))
# The Dhosking and Dasquith columns had better match!
set.seed(3) # This seed produces a "*" and "**", but users
# are strongly encouraged to repeat the folowing code block
# over and over with an unspecified seed and look at the table.
n <- 30 # simulation sample size
par1 <- lmom2par(vec2lmom(c(1, .23, .2, .1)), type="kap")
par2 <- lmom2par(vec2lmom(c(1, .5, -.1)), type="gev")
name <- t2 <- t3 <- t4 <- vector(mode="numeric")
for(i in 1:20) {
X <- rlmomco(n, par1); lmr <- lmoms(X)
t2[i] <- lmr$ratios[2]
t3[i] <- lmr$ratios[3]
t4[i] <- lmr$ratios[4]
name[i] <- "kappa"
}
j <- length(t2)
for(i in 1:3) {
X <- rlmomco(n, par2); lmr <- lmoms(X)
t2[j + i] <- lmr$ratios[2]
t3[j + i] <- lmr$ratios[3]
t4[j + i] <- lmr$ratios[4]
name[j + i] <- "gev"
}
D <- lmrdiscord(site=name, t2=t2, t3=t3, t4=t4)
print(D)
plotlmrdia(lmrdia(), xlim=c(-.2,.6), ylim=c(-.1, .4),
autolegend=TRUE, xleg=0.1, yleg=.4)
points(D$t3,D$t4)
text(D$t3,D$t4,D$site, cex=0.75, pos=3)
text(D$t3,D$t4,D$D, cex=0.75, pos=1)
Run the code above in your browser using DataLab