bicoploc | R Documentation |
HIGHLY EXPERIMENTAL AND SUBJECT TO OVERHAUL OR REMOVAL—Compute an analog to the line of organic correlation (reduced major axis) using the diagonal of a copula.
\mathrm{Pr}[U \le u, V \le v] = \mathbf{C}(u,v) = f\mbox{.}
The primary diagonal is defined as
\mathbf{\delta}_\mathbf{C}(t) = \mathbf{C}(t,t) = f\mbox{.}
Two diagnostic plots can be plotted by the arguments available for this function. The plot for (U,V)
coordinate nonexceedance probability domain along with the analyses involving the copula diagonal inversion comes first, which is followed by that for (X,Y)
coordinate domain along with the well-known line of organic correlation by the method of L-moments and such a “line” (could be a curve) by copula diagonal inversion.
This much infrastructure written for flexibility in how a copula would interact for the purpose of estimation with moment preservation. The simple u = v
might be sufficient but let us have some flexibility.
bicoploc(xp, yp=NULL, xout=NA, xpara=NULL, ypara=NULL, dtypex="nor", dtypey="nor",
ctype=c("weibull", "hazen", "bernstein", "checkerboard"), kumaraswamy=TRUE,
plotuv=TRUE, plotxy=TRUE, adduv=FALSE, addxy=FALSE, snv=FALSE, limout=TRUE,
autoleg=TRUE, xleg="topleft", yleg=NULL, rugxy=TRUE, ruglwd=0.5,
xlim=NULL, ylim=NULL, titleuv="", titlexy="", titlecex=1,
a=0, ff=pnorm(seq(-5, +5, by=0.1)), locdigits=6,
paracop=TRUE, verbose=TRUE, x=NULL, y=NULL, ...)
xp |
Numeric vector giving paired data points of |
yp |
Optional numeric vector giving paired data points of |
xout |
An optional set of numeric values specifying where interpolation through the diagonal inversion is to take place; |
xpara |
An lmomco package parameter object for the |
ypara |
An lmomco package parameter object for the |
dtypex |
The lmomco package distribution abbreviations (see |
dtypey |
The lmomco package distribution abbreviations (see |
ctype |
Argument of the same name for the empirical copula for dispatch to |
kumaraswamy |
A logical to trigger Kumaraswamy distribution smoothing of the copula diagonal inversion from the empricial copula. The Kumaraswamy distribution is a distribution having support |
plotuv |
A logical to trigger plotting of the analyses in the |
plotxy |
A logical to trigger plotting of the analyses in the |
adduv |
A logical when set true will not call the |
addxy |
A logical when set true will not call the |
snv |
A logical when set true will plot the |
limout |
A logical when set true will plot the |
autoleg |
A logical when set will draw a legend for the plots if the plots are requested; |
xleg |
The value to become the argument |
yleg |
The value to become the argument |
rugxy |
Call |
ruglwd |
The line wide passed into |
xlim |
A numeric vector that if precisely of length 2 and no missing values therein, will override the horizontal limits of the |
ylim |
A numeric vector that if precisely of length 2 and no missing values therein, will override the vertical limits of the |
titleuv |
An optional title for the |
titlexy |
An optional title for the |
titlecex |
The character expansion factor for the titles; |
a |
Value for the plotting-position formula for |
ff |
The nonexceedance joint probability of of the copula diagonal from which inversion computes the marginal nonexceedance probability values for |
locdigits |
Number of digits for rounding exclusive to the |
paracop |
A logical trigging the use of the parametric asymmetric copula fit by numerical optimization to the |
verbose |
Show messages of incremental progress with a incremental counter on the message; |
x |
Numeric vector of |
y |
Numeric vector of |
... |
Additional arguments to pass. |
ON THE USE OF AN PARAMETRIC ASYMMETRIC COPULA—
Lists, vectors, and data frames for the computations and predictions are returned.
organic |
A list containing a data frame of the predictions for |
locsols |
A list of solutions to the LOC based (1) ( |
xpara |
The parameters of the marginal distribution in |
ypara |
The parameters of the marginal distribution in |
faqs |
A named vector containing some numerical facts about the operations and principally the requisite sample sizes involved are reported here; |
faqscop |
A named vector containing some numerical facts about the operations involving the fitting of the parametric asymmetric copula (Plackett by default) to the |
diag |
A data frame containing information on the copula diagonal including the joint probability column |
The use of a copula diagonal inversion for purposes of a line of organic correlation analog within the text-book literature and elsewhere is unknown to the developers (December 2023).
Though bicoploc
has extensive logic for working through the copula diagonal, if we know the parent distribution and we just have the marginal probabilities equal to each other (the diagonal), then we recover the moments of Y
simply with u = v
:
library(lmomco) ff <- c(0.0001, seq(0.001, 0.999, by=0.001), 0.9999) xpara <- lmomco::vec2par(c(3, 0.6, -0.4), type="pe3") ypara <- lmomco::vec2par(c(3, 0.4, +0.6), type="pe3") xx <- rlmomco(100000, xpara) yy <- approx(qlmomco(ff, xpara), qlmomco(ff, ypara), xout=xx)$y lmr2par(yy, type="aep4")$para # mu sigma gamma # 2.9972742 0.3993914 0.5980866
W.H. Asquith
Kruskal, W.H., 1953, On the uniqueness of the line of organic correlation: Biometrics, vol. 9, no. 1, pp. 47–58, \Sexpr[results=rd]{tools:::Rd_expr_doi("10.2307/3001632")}.
diagCOPatf
# paracop set to FALSE in these examples for speed
set.seed(4); nsim <- 50
X <- rnorm(nsim, mean=3, sd=0.6)
Y <- rnorm(nsim, mean=0, sd=0.2)
zz <- bicoploc(X,Y, xout=c(2.5, 3.5, 4), dtypex="nor", dtypey="nor", paracop=FALSE)
# cor(X,Y, method="spearman") # +0.0785114 POSITIVE
set.seed(1); nsim <- 50
X <- rnorm(nsim, mean=3, sd=0.6)
Y <- rnorm(nsim, mean=0, sd=0.2)
zz <- bicoploc(X,Y, xout=c(2.5, 3.5, 4), dtypex="nor", dtypey="nor", paracop=FALSE)
# cor(X,Y, method="spearman") # -0.1351741 NEGATIVE
set.seed(1); nsim <- 50
X <- rnorm(nsim, mean=3, sd=0.6)
Y <- 0.843*X + rnorm(nsim, mean=0, sd=0.2)
zz <- bicoploc(X,Y, xout=c(2.5, 3.5, 4), dtypex="nor", dtypey="nor", paracop=FALSE)
# cor(X,Y, method="spearman") # for nsim=1E6 RHO=0.92367
set.seed(1); nsim <- 50
X <- lmomco::rlmomco(nsim, lmomco::vec2par(c(3, 0.6, +0.5), type="pe3"))
Y <- 0.3*X^2 + lmomco::rlmomco(nsim, lmomco::vec2par(c(0, 0.4, 0), type="pe3"))
zz <- bicoploc(X,Y, xout=c(2.5, 3.5, 4.5), dtypex="nor", dtypey="nor", paracop=FALSE)
# cor(X,Y, method="spearman") # for nsim=1E6 RHO=0.92366
set.seed(1); nsim <- 50
X <- lmomco::rlmomco(nsim, lmomco::vec2par(c(3, 0.6, +0.5), type="pe3"))
Y <- 0.3*X^2 + lmomco::rlmomco(nsim, lmomco::vec2par(c(0, 0.4, 0), type="pe3"))
zz <- bicoploc(X,Y, xout=c(2.5, 3.5, 4.5), dtypex="gev", dtypey="gev", paracop=FALSE)
## Not run:
########################################################################################
# Image 800 samples in X and Y and though created as pairs, let us assume only
# 50 are actually paired for purposes of demonstration of specified parameters
# and (or) alternative x and y vectors providing the larger sample.
set.seed(1); nsim <- 800; npair <- 50
X <- lmomco::rlmomco(nsim, lmomco::vec2par(c(3, 0.6, +0.5), type="pe3"))
Y <- 0.3*X^2 + rnorm(nsim, mean=0, sd=0.3)
ix <- sample(seq_len(nsim), npair, replace=FALSE)
Xp <- X[ix]; Yp <- Y[ix]; dtypex <- "gev"; dtypey <- "gev"
xpara <- lmomco::lmr2par(X, type=dtypex); ypara <- lmomco::lmr2par(Y, type=dtypey)
# The next two bicoploc() calls produce identical results except for the density
# of data points along the axes for the rug plots. Ultimately, the same parameter
# estimates for the margins exists for both calls. The plotuv is disabled so that
# the user can tab between the two plotxy plots and see that they are the same.
zz <- bicoploc(Xp,Yp, xout=c(2.5, 3.5, 4.5), ruglwd=0.9, plotuv=FALSE,
xpara=xpara, ypara=ypara, dtypex=NULL, dtypey=NULL)
mtext("Example of specific xpara and ypara from larger sample", line=0.5)
zz <- bicoploc(Xp,Yp, xout=c(2.5, 3.5, 4.5), ruglwd=0.9, plotuv=FALSE,
xpara=xpara, ypara=ypara, dtypex=NULL, dtypey=NULL, x=X, y=Y)
mtext("Example of specific xpara and ypara from larger sample", line=0.5) #
## End(Not run)
## Not run:
########################################################################################
set.seed(1); nsim <- 50
UV <- rCOP(nsim, cop=breveCOP, para=list(cop=W, alpha=0, beta=0))
X <- qnorm(UV[,1], mean=3, sd=0.6)
Y <- qnorm(UV[,2], mean=2, sd=0.2)
zz <- bicoploc(X,Y, xout=c(1.5, 2.5, 3.5, 4), dtypex="nor", dtypey="nor")
set.seed(1); nsim <- 50
UV <- rCOP(nsim, cop=breveCOP, para=list(cop=W, alpha=0, beta=0.5))
X <- qnorm(UV[,1], mean=3, sd=0.6)
Y <- qnorm(UV[,2], mean=2, sd=0.2)
zz <- bicoploc(X,Y, xout=c(1.5, 2.5, 3.5, 4), dtypex="nor", dtypey="nor")
set.seed(1); nsim <- 50
UV <- rCOP(nsim, cop=breveCOP, para=list(cop=M_N5p12b, para=3, alpha=0, beta=0.5))
X <- qnorm(UV[,1], mean=3, sd=0.6)^2
Y <- qnorm(UV[,2], mean=2, sd=0.2)
zz <- bicoploc(X,Y, xout=c(1.5, 2.5, 3.5, 4), ylim=c(1,2.5),
xleg="bottomleft", dtypex="aep4", dtypey="nor")
# A TRUE COUNTER EXAMPLE? Are the 1-v operations not sufficient depending on
# rotation? Is the secondary diagonal of a copula useful? Is there something wrong
# with the reflection operations as implemented at the end of November 2023?
# Should negatives be turned into positives by reversing Y within the internal logic?
# The solution current at end of November 2023 seems proper.
set.seed(1); nsim <- 500
para <- list(cop1=W, para1=4, cop2=GHcop, para2=c(30,.6, .9), alpha=0, beta=0.1)
UV <- rCOP(nsim, cop=composite2COP, para=para)
X <- -qexp(UV[,1], rate=10)+0.1 # Or the problem is a reflected exponential but the
Y <- qnorm(UV[,2], mean=2, sd=0.2) # exp version in lmomco can not handle
zz <- bicoploc(X,Y, xout=c(-0.05, 0, 0.2), dtypex="exp", dtypey="nor")
# Possibly, try another distribution.
zz <- bicoploc(X,Y, xout=c(-0.3, -0.2, 0), ylim=c(1,4), dtypex="aep4", dtypey="nor") #
## End(Not run)
## Not run:
########################################################################################
set.seed(1); nsim <- 200; npair <- 30
para <- list(cop=PLcop, para=80, alpha=0.3, beta=0.05)
UV <- rCOP(nsim, cop=composite1COP, para=para, resamv01=TRUE)
X <- lmomco::qlmomco(UV[,1], lmomco::vec2par(c(3, 0.6, +0.4), type="pe3"))
Y <- lmomco::qlmomco(UV[,2], lmomco::vec2par(c(3, 0.4, +0.0), type="pe3"))
ix <- sample(seq_len(nsim), npair, replace=FALSE)
Xp <- X[ix]; Yp <- Y[ix]; dtypex <- "pe3"; dtypey <- "pe3"
xpara <- lmomco::lmr2par(X, type=dtypex); ypara <- lmomco::lmr2par(Y, type=dtypey)
plot(10^X, 10^Y, log="xy", las=1, pch=21, lwd=0.8, col="black", bg="white",
xlab="SOME RISK PHENOMENON IN X-DIRECTION",
ylab="SOME RISK PHENOMENON IN Y-DIRECTION")
xout <- c(1.5, 2.5, 3.5, 4)
xlim <- c(1.5, 4.5); ylim <- c(1.8, 5.0)
zz <- bicoploc(Xp,Yp, xout=xout,xpara=xpara,ypara=ypara, xlim=xlim,ylim=ylim)
zz <- bicoploc(Xp,Yp, xout=xout,xpara=xpara,ypara=ypara, xlim=xlim,ylim=ylim,x=X,y=Y)
zz <- bicoploc(Xp,Yp, xout=xout,dtypex="pe3",dtypey="pe3",xlim=xlim,ylim=ylim,x=X,y=Y)
zz <- bicoploc(X, Y, xout=xout,dtypex="pe3",dtypey="pe3",xlim=xlim,ylim=ylim)#
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.