R Under development (unstable) (2023-12-04 r85659 ucrt) -- "Unsuffered Consequences"
Copyright (C) 2023 The R Foundation for Statistical Computing
Platform: x86_64-w64-mingw32/x64
R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.
R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.
Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.
> ## Copyright (C) 2012 Marius Hofert, Ivan Kojadinovic, Martin Maechler, and Jun Yan
> ##
> ## This program is free software; you can redistribute it and/or modify it under
> ## the terms of the GNU General Public License as published by the Free Software
> ## Foundation; either version 3 of the License, or (at your option) any later
> ## version.
> ##
> ## This program is distributed in the hope that it will be useful, but WITHOUT
> ## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
> ## FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
> ## details.
> ##
> ## You should have received a copy of the GNU General Public License along with
> ## this program; if not, see .
>
>
> ### (Nested) Archimedean Copulas -----------------------------------------------
>
> require(copula)
Loading required package: copula
>
> if(!dev.interactive(orNone=TRUE)) pdf("copula-play.pdf")
>
>
> ### testing psi
>
> myCop <- setTheta(copAMH, value = 0.5) # is maybe more natural
>
> ## Care: copula *does* define psi() already!
> setGeneric("psi.", function(cop) standardGeneric("psi."))
[1] "psi."
> setMethod(psi., "acopula",
+ function(cop) { function(t) cop@psi(t, theta = cop@theta) })
> psi.(myCop) # is a function
function (t)
cop@psi(t, theta = cop@theta)
> psi.(myCop)(0:4)
[1] 1.00000000 0.22539967 0.07257888 0.02552904 0.00924246
> curve(psi.(myCop)(x), 0, 4)
> ##' but this can also be done directly [ => same curve "on top" :]
> curve(myCop@psi(x, theta = myCop@theta), 0, 4, col = 2, add = TRUE)
>
>
> ### testing Kendall's tau
>
> p.Tau <- function(cop, n = 201, xlim = pmin(paraI, 50), ...) {
+ stopifnot(is(cop, "acopula"))
+ paraI <- cop@paraInterval
+ theta <- seq(xlim[1], xlim[2], length.out = n)
+ tit <- substitute(tau[NAME](theta), list(NAME = cop@name))
+ plot(theta, cop@tau(theta), type = "l", main = tit, ...)
+ abline(h = c(0,1), lty = 3, col = "gray20")
+ }
>
> p.Tau(copAMH)
> p.Tau(copClayton)
> p.Tau(copFrank, xlim = c(0, 80), ylim= 0:1) # fast via debye_1()
> p.Tau(copGumbel)
> p.Tau(copJoe, ylim = 0:1, yaxs="i")
>
>
> ### test function ##############################################################
>
> ##' @title stopifnot() plus output
> ##' @param expr
> ##' @param prefix
> ##' @param true
> ##' @return
> ##' @author Martin Maechler
> checkifnot <- function(expr, prefix = "check if", true = "[Ok]")
+ {
+ c0 <- function(...) cat(..., sep = "")
+ ## match.call(): not "calling" expr too early:
+ c0(prefix, deparse(match.call()[[2]])[1],": ")
+ stopifnot(expr)
+ c0(true,"\n")
+ }
>
>
> ##' @title Perform a set of checks on a Archimedean copula object (with theta set)
> ##' @param cop acopula
> ##' @param theta1 parameter theta1
> ##' @param thetavec vector of parameters
> ##' @param i10 values where psi is evaluated
> ##' @param nRnd number of generated V0's and V01's
> ##' @param u01 values where psiinv is evaluated
> ##' @param lambdaLvec vector of lower tail-dependence coefficients
> ##' @param lambdaUvec vector of upper tail-dependence coefficients
> ##' @return list of measurements
> ##' @author Marius Hofert, Martin Maechler
> tstCop <- function(cop, theta1 = cop@theta, thetavec = cop@theta, i10 = 1:10,
+ nRnd = 50, u01 = (1:63)/64, # exact binary fractions
+ lambdaLvec = NA_real_, lambdaUvec = NA_real_)
+ {
+ stopifnot(is(cop, "acopula"))
+ cat0 <- function(...) cat(..., "\n", sep = "")
+ theta0 <- cop@theta
+ CT <- list()
+
+ ### (1) cop name
+
+ cat0(sprintf("(1) copula family: %10s, theta0 = %g",
+ cop@name, theta0))
+
+ ### (2) generator
+
+ ### (2.1) psi and iPsi
+
+ cat("\n(2) values of psi at i10:\n")
+ CT <- c(CT, list(psi = system.time(
+ p.i <- cop@psi(i10,theta = theta0))))
+ print(p.i)
+ checkifnot(identical(numeric(0), cop@iPsi(numeric(0), theta = theta0)))
+ checkifnot(cop@iPsi(0, theta = theta0) == Inf)
+ cat0("\nvalues of iPsi at u01:")
+ CT <- c(CT, list(psiI = system.time(
+ pi.t <- cop@iPsi(u01, theta = theta0))))
+ print(pi.t)
+ CT[["psiI"]] <- CT[["psiI"]] +
+ system.time(pi.pi <- cop@iPsi(p.i,theta = theta0))
+ CT[["psi" ]] <- CT[["psi" ]] +
+ system.time(p.pit <- cop@psi(pi.t, theta = theta0))
+ cat0("check if iPsi(psi(i10))==i10: ", all.equal(pi.pi, i10))
+ cat0("check if psi(iPsi(u01))==u01: ", all.equal(p.pit, u01))
+
+ ### (2.2) absdPsi
+
+ ## absdPsi with degree = 10
+ cat0("\nvalues of absdPsi with degree=10 at i10:")
+ CT <- c(CT, list(absdPsi = system.time(
+ p.D <- cop@absdPsi(i10,theta = theta0, degree = 10))))
+ print(p.D)
+ cat0("check if all values are nonnegative")
+ stopifnot(is.vector(p.D), all(p.D >= 0))
+ cat("check absdPsi(Inf,theta,degree=10) = 0 and the class of absdPsi(0,theta,degree=10): ")
+ at.0 <- cop@absdPsi(0, theta = theta0, degree = 10)
+ stopifnot(cop@absdPsi(Inf, theta = theta0, degree = 10) == 0,
+ is.numeric(at.0), !is.nan(at.0))
+ cat0("[Ok]")
+ ## absdPsi with degree = 10 and MC
+ cat("\nvalues of absdPsi with degree=10 and MC at i10:\n")
+ CT <- c(CT, list(absdPsi = system.time(
+ p.D <- cop@absdPsi(i10,theta = theta0, degree = 10, n.MC = 1000))))
+ print(p.D)
+ cat0("check if all values are nonnegative")
+ stopifnot(all(p.D >= 0))
+ cat("check absdPsi(Inf,theta,degree=10,n.MC=1000) = 0 and the class of absdPsi(0,theta,degree=10,n.MC=1000): ")
+ at.0 <- cop@absdPsi(0, theta = theta0, degree = 10, n.MC = 1000)
+ stopifnot(cop@absdPsi(Inf, theta = theta0, degree = 10, n.MC = 1000)==0,
+ is.numeric(at.0), !is.nan(at.0))
+ cat0("[Ok]")
+
+ ### (2.3) absdiPsi
+
+ cat0("\nvalues of absdiPsi at u01:")
+ CT <- c(CT, list(absdiPsi. = system.time(
+ absdiPsi. <- cop@absdiPsi(u01, theta = theta0))))
+ print(absdiPsi.)
+ stopifnot(all(absdiPsi. >= 0, is.numeric(absdiPsi.), !is.nan(absdiPsi.)))
+ cat("check the class of absdiPsi(0,theta): ")
+ at.0 <- cop@absdiPsi(0, theta = theta0)
+ stopifnot(is.numeric(at.0),!is.nan(at.0))
+ cat0("[Ok]")
+
+ ### (3) parameter interval
+
+ cat("\n(3) parameter interval:\n")
+ print(cop@paraInterval)
+ cat0("theta1=",theta1)
+ cat0("nesting condition for theta0 and theta1 fulfilled: ",
+ cop@nestConstr(theta0,theta1))
+
+ ### (4) V0, dV0, V01, dV01
+
+ ## V0
+ CT <- c(CT, list(V0 = system.time(V0 <- cop@V0(nRnd,theta0))))
+ cat0("\n(4) ",nRnd," generated V0's:")
+ print(summary(V0))
+ ## dV0
+ cat("\nvalues of dV0 at i10:\n")
+ CT <- c(CT, list(dV0 = system.time(dV0.i <- cop@dV0(i10,theta0))))
+ print(dV0.i)
+ ## V01
+ CT <- c(CT, list(V01 = system.time(V01 <- cop@V01(V0,theta0,theta1))))
+ cat0("\n",nRnd," generated V01's:")
+ print(summary(V01))
+ nt <- length(thetavec)
+ ## dV01
+ cat("\nvalues of dV01 at i10:\n")
+ CT <- c(CT, list(dV01 = system.time(
+ dV01.i <- cop@dV01(i10,V0=1,theta0=theta0, theta1=theta1))))
+ print(dV01.i)
+
+ ### (5) cCopula {was "cacopula"}
+ cat("\n(5) values of cCopula(cbind(v,rev(v)), copula = cop) for v=u01:\n")
+ cop. <- onacopulaL(cop@name, list(theta0, 1:2))
+ CT <- c(CT, list(cCopula. = system.time(
+ cac <- cCopula(cbind(u01, rev(u01)), copula = cop., indices = 2))))
+ stopifnot(identical(dim(cac), c(length(u01),1L)), 0 <= cac, cac <= 1)
+ print(c(cac))
+
+ ### (6) dCopula (log = TRUE) {was dnacopula()}
+
+ u <- matrix(runif(400),ncol=20)
+ ocop.2d <- onacopulaL(cop@name,list(theta0,1:2))
+ ocop.20d <- onacopulaL(cop@name,list(theta0,1:20))
+
+ ## d = 2
+ cat("\n(6) check dCopula(*, log = TRUE) for u being a random (20x2)-matrix:\n")
+ CT <- c(CT, list(dCopula. =
+ system.time(lD <- dCopula(u[,1:2], ocop.2d, log = TRUE))))
+ print(lD); stopifnot(is.numeric(lD), is.finite(lD)); cat0("[Ok]")
+ cat("check at (0,0.5) and (1,0.5):\n")
+ stopifnot(dCopula(cbind(0:1,0.5), ocop.2d, log = FALSE) == 0,
+ dCopula(cbind(0:1,0.5), ocop.2d, log = TRUE ) == -Inf)
+ cat0("[Ok]")
+
+ ## d = 20, n.MC = 0
+ cat("\n check dCopula(*, log = TRUE) for u being a random (20x20)-matrix:\n")
+ CT <- c(CT, list(dCopula. =
+ system.time(lD. <- dCopula(u, ocop.20d, log = TRUE))))
+ print(lD.); stopifnot(is.numeric(lD.), is.finite(lD.)); cat0("[Ok]")
+
+ ## d = 20, n.MC > 0
+ cat("\n check dCopula(*, log = TRUE) and MC for u being a random (20x20)-matrix:\n")
+ CT <- c(CT, list(dCopula. =
+ system.time(lD.. <- dCopula(u, ocop.20d, n.MC = 1000, log = TRUE))))
+ print(lD..); stopifnot(is.numeric(lD..), is.finite(lD..)); cat0("[Ok]")
+
+ ## d = 20, check if n.MC > 0 is close to n.MC = 0
+ stopifnot(all.equal(lD., lD.., tolerance=0.5))
+
+ ### (7) K
+
+ check.K.u01 <- function(K){
+ d.K <- diff(K)
+ if(any(neg <- d.K < 0)){ # happens for AMH, Clayton, and Frank (near 1)
+ if(any(Neg <- abs(d.K[neg]) > 1e-15* abs(K[-1][neg]))) {
+ warning("K(.) is 'substantially' non-monotone for K() / diff(K) =",
+ immediate.=TRUE)
+ print(cbind(K = K[-1][Neg], diff.K = d.K[Neg]))
+ }
+ }
+ stopifnot(is.numeric(K), length(K) == length(u01), 0 <= K, K <= 1)
+ }
+
+ ## K for d = 2
+ cat("\n(7) values of K for d = 2 at u01:\n")
+ CT <- c(CT, list(K = system.time(K. <- pK(u01, cop, d = 2))))
+ check.K.u01( print(K.) )
+ cat("check if K(0) = 0 and K(1) = 1: ")
+ stopifnot(pK(0, cop, d = 2)==0,
+ pK(1, cop, d = 2)==1)
+ cat0("[Ok]")
+ ## K for d = 10
+ cat("\nvalues of K for d = 10 at u01:\n")
+ CT <- c(CT, list(K = system.time(K. <- pK(u01, cop, d = 10))))
+ check.K.u01( print(K.) )
+ cat("check if K(0) = 0 and K(1) = 1: ")
+ stopifnot(pK(0, cop, d = 10)==0,
+ pK(1, cop, d = 10)==1)
+ cat0("[Ok]")
+ ## K for d = 10 and MC
+ cat("\nvalues of K for d = 10 and MC at u01:\n")
+ CT <- c(CT, list(K = system.time(K. <- pK(u01, cop, d = 10, n.MC = 1000))))
+ check.K.u01( print(K.) )
+ cat("check if K(0)=0 and K(1)=1: ")
+ stopifnot(pK(0, cop, d = 10, n.MC = 1000)==0,
+ pK(1, cop, d = 10, n.MC = 1000)==1)
+ cat0("[Ok]")
+
+ ### (8) tau, iTau
+
+ cat("\n(8) tau at thetavec:\n")
+ CT <- c(CT, list(tau = system.time(ta <- cop@tau(thetavec))))
+ print(ta)
+ CT <- c(CT, list(tauI = system.time(ta.I <- cop@iTau(ta))))
+ cat0("check if iTau(tau(thetavec))==thetavec: ",
+ all.equal(ta.I, thetavec))
+ lambdaLvec <- rep(as.double(lambdaLvec), length.out= nt)
+ lambdaUvec <- rep(as.double(lambdaUvec), length.out= nt)
+
+ ### (9) lambdaL, lambdaLInv
+
+ cat("\n(9) lambdaL at thetavec:\n")
+ CT <- c(CT, list(lambdaL = system.time(lT <- cop@lambdaL(thetavec))))
+ CT <- c(CT, list(lT.I = system.time(lT.I <- cop@lambdaLInv(lT))))
+ print(lT)
+ cat0("check if lambdaLInv(lambdaL(thetavec))==lambdaLvec: ",
+ all.equal(lT.I, lambdaLvec))
+
+ ### (10) lambdaU, lambdaUInv
+
+ cat("\n(10) lambdaU at thetavec:\n")
+ CT <- c(CT, list(lambdaU = system.time(uT <- cop@lambdaU(thetavec))))
+ CT <- c(CT, list(uT.I = system.time(uT.I <- cop@lambdaUInv(uT))))
+ print(uT)
+ cat0("check if lambdaUInv(lambdaU(thetavec))==lambdaUvec: ",
+ all.equal(uT.I, lambdaUvec))
+
+ ### (11) dDiag
+
+ cat("\n(11) dDiag at u01 for d=10:\n")
+ CT <- c(CT, list(dDiag = system.time(
+ dDiag. <- cop@dDiag(u01, theta=theta0, d=10))))
+ print(dDiag.)
+ stopifnot(is.numeric(dDiag.), all(dDiag. > 0))
+ cat0("[Ok]")
+
+ class(CT) <- "proc_time_list"
+ CT
+ }
>
> ##' print() method for the tstCop() results
> print.proc_time_list <- function (x, ...) {
+ stopifnot(is.list(x), !is.null(nx <- names(x)))
+ cat("proc.time()s: user system elapsed\n")
+ ## 2 4 6 8 0 2 4 6 8 0 2 4 6 89|1 3 |1 3 56|1 3 5 7
+ ## 1 2 2
+ for(nm in nx)
+ if(!all(x[[nm]] == 0, na.rm=TRUE)) {
+ ## use 'Time ..' as that works with 'R CMD Rdiff'
+ m <- 1000*x[[nm]]
+ cat(sprintf("Time [ms] for %13s :%5.0f %6.0f %7.0f\n",
+ ## 2 4 6 8 0 2 4 6 8 0| (20 + (13-4)) = 29
+ nm, m[1], m[2], m[3]))
+ ## cat(nm,":\n"); print(x[[nm]], ...)
+ }
+ invisible(x)
+ }
>
>
> ### copAMH #####################################################################
>
> myAMH <- setTheta(copAMH, 0.7135001)
> thetavec <- c(0.1,0.3,0.5,0.7,0.9)
> set.seed(1)
> tstCop(myAMH, 0.9429679, thetavec = thetavec)
(1) copula family: AMH, theta0 = 0.7135
(2) values of psi at i10:
[1] 1.429083e-01 4.291776e-02 1.478935e-02 5.316911e-03 1.939747e-03
[6] 7.114205e-04 2.614242e-04 9.613302e-05 3.536001e-05 1.300750e-05
check ifidentical(numeric(0), cop@iPsi(numeric(0), theta = theta0)): [Ok]
check ifcop@iPsi(0, theta = theta0) == Inf: [Ok]
values of iPsi at u01:
[1] 2.947040524 2.290664008 1.920665301 1.667234728 1.477208260 1.326942110
[7] 1.203851124 1.100443711 1.011903674 0.934955245 0.867272157 0.807145091
[13] 0.753282810 0.704687301 0.660572166 0.620307473 0.583381398 0.549372886
[19] 0.517931752 0.488763912 0.461620244 0.436288065 0.412584514 0.390351357
[25] 0.369450874 0.349762544 0.331180384 0.313610761 0.296970606 0.281185933
[31] 0.266190600 0.251925275 0.238336566 0.225376280 0.213000792 0.201170507
[37] 0.189849397 0.179004601 0.168606080 0.158626312 0.149040034 0.139824007
[43] 0.130956818 0.122418699 0.114191371 0.106257904 0.098602593 0.091210850
[49] 0.084069100 0.077164698 0.070485850 0.064021539 0.057761462 0.051695973
[55] 0.045816033 0.040113158 0.034579380 0.029207207 0.023989588 0.018919878
[61] 0.013991815 0.009199487 0.004537308
check if iPsi(psi(i10))==i10: TRUE
check if psi(iPsi(u01))==u01: TRUE
values of absdPsi with degree=10 at i10:
[1] 5.942950e+04 1.279625e+02 2.546370e+00 1.422874e-01 1.430355e-02
[6] 2.131647e-03 4.419191e-04 1.199928e-04 3.856111e-05 1.343933e-05
check if all values are nonnegative
check absdPsi(Inf,theta,degree=10) = 0 and the class of absdPsi(0,theta,degree=10): [Ok]
values of absdPsi with degree=10 and MC at i10:
[1] 6.107456e+04 1.286964e+02 2.489571e+00 1.335637e-01 1.341249e-02
[6] 2.058640e-03 4.442627e-04 1.244966e-04 4.069444e-05 1.428779e-05
check if all values are nonnegative
check absdPsi(Inf,theta,degree=10,n.MC=1000) = 0 and the class of absdPsi(0,theta,degree=10,n.MC=1000): [Ok]
values of absdiPsi at u01:
[1] 61.6028756 29.6894186 19.1032637 13.8450203 10.7152182 8.6476536
[7] 7.1855902 6.1008145 5.2666593 4.6072154 4.0742487 3.6356601
[13] 3.2692727 2.9592833 2.6941332 2.4651783 2.2658297 2.0909796
[19] 1.9366107 1.7995212 1.6771299 1.5673340 1.4684040 1.3789055
[25] 1.2976391 1.2235953 1.1559181 1.0938781 1.0368495 0.9842930
[31] 0.9357416 0.8907887 0.8490794 0.8103020 0.7741823 0.7404780
[37] 0.7089742 0.6794798 0.6518243 0.6258553 0.6014360 0.5784436
[43] 0.5567673 0.5363068 0.5169716 0.4986795 0.4813557 0.4649322
[49] 0.4493467 0.4345425 0.4204675 0.4070742 0.3943185 0.3821604
[55] 0.3705624 0.3594905 0.3489129 0.3388004 0.3291257 0.3198638
[61] 0.3109913 0.3024863 0.2943288
check the class of absdiPsi(0,theta): [Ok]
(3) parameter interval:
'interval' object [0, 1)
theta1=0.9429679
nesting condition for theta0 and theta1 fulfilled: TRUE
(4) 50 generated V0's:
Min. 1st Qu. Median Mean 3rd Qu. Max.
1.0 1.0 2.0 3.4 4.0 14.0
values of dV0 at i10:
[1] 0.28649990 0.20441771 0.14585205 0.10406546 0.07425071 0.05297789
[7] 0.03779973 0.02697011 0.01924318 0.01373001
50 generated V01's:
Min. 1st Qu. Median Mean 3rd Qu. Max.
1.00 5.00 9.50 16.26 20.75 73.00
values of dV01 at i10:
[1] 0.19906499 0.15943812 0.12769957 0.10227906 0.08191888 0.06561170
[7] 0.05255071 0.04208970 0.03371111 0.02700041
(5) values of cCopula(cbind(v,rev(v)), copula = cop) for v=u01:
[1] 0.995122341 0.989431924 0.982914460 0.975557885 0.967352559 0.958291451
[7] 0.948370325 0.937587909 0.925946056 0.913449888 0.900107924 0.885932181
[13] 0.870938263 0.855145415 0.838576553 0.821258266 0.803220785 0.784497918
[19] 0.765126956 0.745148542 0.724606507 0.703547671 0.682021619 0.660080438
[25] 0.637778430 0.615171797 0.592318309 0.569276945 0.546107527 0.522870336
[31] 0.499625725 0.476433731 0.453353687 0.430443846 0.407761010 0.385360182
[37] 0.363294234 0.341613600 0.320365998 0.299596180 0.279345715 0.259652803
[43] 0.240552131 0.222074759 0.204248040 0.187095583 0.170637243 0.154889147
[49] 0.139863752 0.125569926 0.112013064 0.099195219 0.087115261 0.075769049
[55] 0.065149616 0.055247372 0.046050313 0.037544233 0.029712940 0.022538477
[61] 0.016001339 0.010080684 0.004754538
(6) check dCopula(*, log = TRUE) for u being a random (20x2)-matrix:
[1] 0.03038572 0.20391573 0.12841464 0.25762246 0.07144850 0.29830461
[7] 0.25562991 0.08999060 0.07813416 -0.75171888 -0.65834707 -0.22094383
[13] -1.00608840 -0.48467057 0.06398123 0.33082940 -0.13552003 0.14568420
[19] -0.51679955 0.38841866
[Ok]
check at (0,0.5) and (1,0.5):
[Ok]
check dCopula(*, log = TRUE) for u being a random (20x20)-matrix:
[1] -0.3937896 -1.7995210 -2.6422088 -2.2856701 -2.3881681 -0.7382701
[7] -0.4996946 -1.4017471 1.7123374 -4.0103811 -0.3942112 -1.7087205
[13] -1.8523596 -4.1428367 -1.2726721 -2.3322272 -3.1792504 -0.8809057
[19] -3.6297145 -1.6238927
[Ok]
check dCopula(*, log = TRUE) and MC for u being a random (20x20)-matrix:
[1] -0.3939636 -1.8072152 -2.5858715 -2.2593170 -2.3370978 -0.6851950
[7] -0.4663319 -1.3551600 1.7444306 -3.9537262 -0.3980784 -1.6611112
[13] -1.7957436 -4.0900819 -1.2456400 -2.2798143 -3.1226760 -0.8307721
[19] -3.6240823 -1.5672891
[Ok]
(7) values of K for d = 2 at u01:
[1] 0.06346433 0.10840422 0.14741621 0.18292126 0.21598577 0.24719534
[7] 0.27691185 0.30537652 0.33275888 0.35918283 0.38474177 0.40950785
[13] 0.43353796 0.45687769 0.47956413 0.50162783 0.52309422 0.54398469
[19] 0.56431737 0.58410776 0.60336918 0.62211317 0.64034979 0.65808783
[25] 0.67533503 0.69209824 0.70838351 0.72419625 0.73954130 0.75442299
[31] 0.76884521 0.78281148 0.79632499 0.80938862 0.82200500 0.83417654
[37] 0.84590540 0.85719361 0.86804300 0.87845527 0.88843196 0.89797451
[43] 0.90708426 0.91576244 0.92401018 0.93182854 0.93921850 0.94618099
[49] 0.95271685 0.95882689 0.96451185 0.96977242 0.97460927 0.97902299
[55] 0.98301417 0.98658335 0.98973104 0.99245771 0.99476382 0.99664979
[61] 0.99811602 0.99916290 0.99979078
check if K(0) = 0 and K(1) = 1: [Ok]
values of K for d = 10 at u01:
[1] 0.5978364 0.6991605 0.7643957 0.8118068 0.8481068 0.8766878 0.8995684
[8] 0.9180775 0.9331499 0.9454747 0.9555772 0.9638678 0.9706727 0.9762553
[15] 0.9808297 0.9845716 0.9876260 0.9901130 0.9921320 0.9937657 0.9950831
[22] 0.9961411 0.9969872 0.9976608 0.9981945 0.9986151 0.9989448 0.9992016
[29] 0.9994004 0.9995532 0.9996699 0.9997583 0.9998247 0.9998742 0.9999107
[36] 0.9999373 0.9999566 0.9999703 0.9999800 0.9999867 0.9999914 0.9999945
[43] 0.9999965 0.9999979 0.9999987 0.9999993 0.9999996 0.9999998 0.9999999
[50] 0.9999999 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000
[57] 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000
check if K(0) = 0 and K(1) = 1: [Ok]
values of K for d = 10 and MC at u01:
[1] 0.5936630 0.6955237 0.7609943 0.8086501 0.8453336 0.8744513 0.8979750
[8] 0.9171648 0.9328909 0.9457944 0.9563718 0.9650222 0.9720738 0.9778003
[15] 0.9824316 0.9861610 0.9891508 0.9915366 0.9934316 0.9949295 0.9961077
[22] 0.9970295 0.9977470 0.9983022 0.9987294 0.9990558 0.9993037 0.9994906
[29] 0.9996305 0.9997344 0.9998108 0.9998666 0.9999069 0.9999358 0.9999562
[36] 0.9999705 0.9999804 0.9999872 0.9999917 0.9999948 0.9999967 0.9999980
[43] 0.9999988 0.9999993 0.9999996 0.9999998 0.9999999 0.9999999 1.0000000
[50] 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000
[57] 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000
check if K(0)=0 and K(1)=1: [Ok]
(8) tau at thetavec:
[1] 0.02280118 0.07237572 0.12876479 0.19504429 0.27821058
check if iTau(tau(thetavec))==thetavec: Mean relative difference: 2.453949e-05
(9) lambdaL at thetavec:
[1] 0 0 0 0 0
check if lambdaLInv(lambdaL(thetavec))==lambdaLvec: TRUE
(10) lambdaU at thetavec:
[1] 0 0 0 0 0
check if lambdaUInv(lambdaU(thetavec))==lambdaUvec: TRUE
(11) dDiag at u01 for d=10:
[1] 2.804730e-11 9.582940e-09 2.493955e-07 2.278818e-06 1.179483e-05
[6] 4.277475e-05 1.217115e-04 2.906406e-04 6.081950e-04 1.148571e-03
[11] 1.998771e-03 3.254728e-03 5.016972e-03 7.386392e-03 1.046053e-02
[16] 1.433067e-02 1.907982e-02 2.478167e-02 3.150033e-02 3.929087e-02
[21] 4.820045e-02 5.826981e-02 6.953526e-02 8.203064e-02 9.578961e-02
[26] 1.108479e-01 1.272454e-01 1.450287e-01 1.642533e-01 1.849856e-01
[31] 2.073057e-01 2.313096e-01 2.571121e-01 2.848498e-01 3.146845e-01
[36] 3.468068e-01 3.814415e-01 4.188524e-01 4.593494e-01 5.032964e-01
[41] 5.511214e-01 6.033287e-01 6.605143e-01 7.233848e-01 7.927819e-01
[46] 8.697129e-01 9.553903e-01 1.051283e+00 1.159181e+00 1.281288e+00
[51] 1.420334e+00 1.579737e+00 1.763818e+00 1.978109e+00 2.229774e+00
[56] 2.528231e+00 2.886054e+00 3.320337e+00 3.854786e+00 4.523051e+00
[61] 5.374185e+00 6.481942e+00 7.961369e+00
[Ok]
proc.time()s: user system elapsed
>
> ### copClayton #################################################################
>
> myClayton <- setTheta(copClayton, 0.5)
> thetavec <- c(0.5,1,2,5,10)
> tstCop(myClayton, 2, thetavec, lambdaL = thetavec, lambdaU = NA)
(1) copula family: Clayton, theta0 = 0.5
(2) values of psi at i10:
[1] 0.250000000 0.111111111 0.062500000 0.040000000 0.027777778 0.020408163
[7] 0.015625000 0.012345679 0.010000000 0.008264463
check ifidentical(numeric(0), cop@iPsi(numeric(0), theta = theta0)): [Ok]
check ifcop@iPsi(0, theta = theta0) == Inf: [Ok]
values of iPsi at u01:
[1] 7.000000000 4.656854249 3.618802154 3.000000000 2.577708764 2.265986324
[7] 2.023715784 1.828427125 1.666666667 1.529822128 1.412090757 1.309401077
[13] 1.218800785 1.138089935 1.065591118 1.000000000 0.940285000 0.885618083
[19] 0.835325871 0.788854382 0.745743122 0.705605731 0.668115312 0.632993162
[25] 0.600000000 0.568929081 0.539600718 0.511857892 0.485562705 0.460593487
[31] 0.436842416 0.414213562 0.392621248 0.371988681 0.352246808 0.333333333
[37] 0.315191898 0.297771369 0.281025230 0.264911064 0.249390095 0.234426800
[43] 0.219988563 0.206045378 0.192569588 0.179535649 0.166919932 0.154700538
[49] 0.142857143 0.131370850 0.120224067 0.109400392 0.098884512 0.088662108
[55] 0.078719780 0.069044968 0.059625886 0.050451463 0.041511288 0.032795559
[61] 0.024295039 0.016001016 0.007905261
check if iPsi(psi(i10))==i10: TRUE
check if psi(iPsi(u01))==u01: TRUE
values of absdPsi with degree=10 at i10:
[1] 9.745313e+03 7.511050e+01 2.379227e+00 1.634992e-01 1.833752e-02
[6] 2.883894e-03 5.808659e-04 1.413337e-04 3.991680e-05 1.271872e-05
check if all values are nonnegative
check absdPsi(Inf,theta,degree=10) = 0 and the class of absdPsi(0,theta,degree=10): [Ok]
values of absdPsi with degree=10 and MC at i10:
[1] 1.051825e+04 7.981181e+01 2.298990e+00 1.558326e-01 1.787532e-02
[6] 2.861651e-03 5.821532e-04 1.426985e-04 4.060799e-05 1.303494e-05
check if all values are nonnegative
check absdPsi(Inf,theta,degree=10,n.MC=1000) = 0 and the class of absdPsi(0,theta,degree=10,n.MC=1000): [Ok]
values of absdiPsi at u01:
[1] 256.0000000 90.5096680 49.2672230 32.0000000 22.8973361 17.4185937
[7] 13.8227007 11.3137085 9.4814815 8.0954308 7.0169913 6.1584029
[13] 5.4616635 4.8870627 4.4065944 4.0000000 3.6523012 3.3522099
[19] 3.0910752 2.8621670 2.6601800 2.4808811 2.3208561 2.1773242
[25] 2.0480000 1.9309896 1.8247120 1.7278376 1.6392416 1.5579664
[31] 1.4831922 1.4142136 1.3504206 1.2912835 1.2363399 1.1851852
[37] 1.1374633 1.0928601 1.0510976 1.0119289 0.9751337 0.9405157
[43] 0.9078985 0.8771239 0.8480495 0.8205465 0.7944987 0.7698004
[49] 0.7463557 0.7240773 0.7028857 0.6827079 0.6634774 0.6451331
[55] 0.6276188 0.6108828 0.5948777 0.5795594 0.5648875 0.5508243
[61] 0.5373351 0.5243876 0.5119519
check the class of absdiPsi(0,theta): [Ok]
(3) parameter interval:
'interval' object [0, Inf)
theta1=2
nesting condition for theta0 and theta1 fulfilled: TRUE
(4) 50 generated V0's:
Min. 1st Qu. Median Mean 3rd Qu. Max.
0.0993 0.8203 1.6241 1.7191 2.3650 4.6344
values of dV0 at i10:
[1] 0 0 0 0 0 0 0 0 0 0
50 generated V01's:
Min. 1st Qu. Median Mean 3rd Qu. Max.
0.0000033 0.0603499 0.1467602 0.3020533 0.4160962 1.4994491
values of dV01 at i10:
[1] 9.583385e-02 1.685089e-02 3.982071e-03 1.065638e-03 3.056074e-04
[6] 9.160650e-05 2.831708e-05 8.953843e-06 2.880868e-06 9.397679e-07
(5) values of cCopula(cbind(v,rev(v)), copula = cop) for v=u01:
[1] 0.997041376 0.991561961 0.984384473 0.975801217 0.965984118 0.955053106
[7] 0.943100433 0.930201843 0.916422494 0.901820431 0.886448741 0.870356988
[13] 0.853592172 0.836199414 0.818222438 0.799703923 0.780685758 0.761209226
[19] 0.741315143 0.721043943 0.700435752 0.679530420 0.658367547 0.636986488
[25] 0.615426348 0.593725966 0.571923892 0.550058363 0.528167262 0.506288089
[31] 0.484457915 0.462713347 0.441090482 0.419624867 0.398351456 0.377304572
[37] 0.356517867 0.336024288 0.315856041 0.296044567 0.276620514 0.257613720
[43] 0.239053201 0.220967149 0.203382931 0.186327112 0.169825480 0.153903092
[49] 0.138584339 0.123893039 0.109852562 0.096485994 0.083816371 0.071866986
[55] 0.060661825 0.050226178 0.040587539 0.031776964 0.023831258 0.016796719
[61] 0.010736232 0.005744832 0.001993895
(6) check dCopula(*, log = TRUE) for u being a random (20x2)-matrix:
[1] -0.221993817 0.091521495 0.125973284 -0.069815215 -0.938510519
[6] 0.057924687 0.002781505 0.066420195 -2.055443296 0.111301607
[11] 0.118009781 0.160206373 -0.115376400 0.078450564 0.700159365
[16] -1.604443435 -1.265676006 -0.181653544 0.247045457 -0.016495066
[Ok]
check at (0,0.5) and (1,0.5):
[Ok]
check dCopula(*, log = TRUE) for u being a random (20x20)-matrix:
[1] -5.8407284 -2.1173982 -2.0215446 -2.7721571 -6.9877643 -4.7009265
[7] -10.1773510 -2.3025394 -7.3817959 -0.5297042 -11.0390291 -1.7227784
[13] -8.8785194 -1.1650577 -5.9897118 -5.6023382 -4.1475643 -3.4495922
[19] -6.7021981 -1.0095965
[Ok]
check dCopula(*, log = TRUE) and MC for u being a random (20x20)-matrix:
[1] -5.7667048 -2.0790169 -1.9758656 -2.7012082 -6.9389532 -4.6489002
[7] -10.0969901 -2.2839388 -7.3018985 -0.4767526 -10.9765927 -1.7077826
[13] -8.8293223 -1.1163474 -5.9369720 -5.5525773 -4.0700862 -3.3949792
[19] -6.6534020 -1.0205795
[Ok]
(7) values of K for d = 2 at u01:
[1] 0.04296875 0.08270146 0.12032753 0.15625000 0.19070180 0.22384008
[7] 0.25578024 0.28661165 0.31640625 0.34522353 0.37311378 0.40012024
[13] 0.42628060 0.45162811 0.47619238 0.50000000 0.52307502 0.54543933
[19] 0.56711297 0.58811438 0.60846059 0.62816740 0.64724951 0.66572067
[25] 0.68359375 0.70088083 0.71759330 0.73374190 0.74933680 0.76438763
[31] 0.77890353 0.79289322 0.80636497 0.81932670 0.83178597 0.84375000
[37] 0.85522573 0.86621980 0.87673859 0.88678823 0.89637463 0.90550348
[43] 0.91418025 0.92241023 0.93019853 0.93755008 0.94446966 0.95096189
[49] 0.95703125 0.96268207 0.96791856 0.97274479 0.97716475 0.98118227
[55] 0.98480111 0.98802489 0.99085718 0.99330141 0.99536094 0.99703906
[61] 0.99833894 0.99926372 0.99981641
check if K(0) = 0 and K(1) = 1: [Ok]
values of K for d = 10 at u01:
[1] 0.4080800 0.6043546 0.7241092 0.8029027 0.8569427 0.8950084 0.9223253
[8] 0.9421964 0.9567990 0.9676135 0.9756701 0.9816992 0.9862262 0.9896335
[15] 0.9922023 0.9941406 0.9956037 0.9967077 0.9975402 0.9981672 0.9986386
[22] 0.9989923 0.9992569 0.9994544 0.9996013 0.9997101 0.9997904 0.9998493
[29] 0.9998924 0.9999237 0.9999463 0.9999625 0.9999740 0.9999822 0.9999879
[36] 0.9999919 0.9999946 0.9999965 0.9999977 0.9999986 0.9999991 0.9999994
[43] 0.9999997 0.9999998 0.9999999 0.9999999 1.0000000 1.0000000 1.0000000
[50] 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000
[57] 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000
check if K(0) = 0 and K(1) = 1: [Ok]
values of K for d = 10 and MC at u01:
[1] 0.3993642 0.5931657 0.7145432 0.7955400 0.8511650 0.8903082 0.9184221
[8] 0.9389392 0.9540893 0.9653693 0.9738161 0.9801668 0.9849556 0.9885753
[15] 0.9913169 0.9933974 0.9949790 0.9961831 0.9971011 0.9978015 0.9983362
[22] 0.9987442 0.9990553 0.9992922 0.9994721 0.9996083 0.9997111 0.9997883
[29] 0.9998459 0.9998887 0.9999203 0.9999435 0.9999603 0.9999724 0.9999810
[36] 0.9999871 0.9999913 0.9999943 0.9999963 0.9999976 0.9999985 0.9999991
[43] 0.9999994 0.9999997 0.9999998 0.9999999 0.9999999 1.0000000 1.0000000
[50] 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000
[57] 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000
check if K(0)=0 and K(1)=1: [Ok]
(8) tau at thetavec:
[1] 0.2000000 0.3333333 0.5000000 0.7142857 0.8333333
check if iTau(tau(thetavec))==thetavec: TRUE
(9) lambdaL at thetavec:
[1] 0.2500000 0.5000000 0.7071068 0.8705506 0.9330330
check if lambdaLInv(lambdaL(thetavec))==lambdaLvec: TRUE
(10) lambdaU at thetavec:
[1] 0 0 0 0 0
check if lambdaUInv(lambdaU(thetavec))==lambdaUvec: TRUE
(11) dDiag at u01 for d=10:
[1] 0.01430523 0.01681765 0.01915927 0.02148300 0.02385201 0.02630307
[7] 0.02886248 0.03155188 0.03439081 0.03739808 0.04059265 0.04399409
[13] 0.04762306 0.05150167 0.05565374 0.06010518 0.06488429 0.07002211
[19] 0.07555283 0.08151417 0.08794792 0.09490046 0.10242334 0.11057408
[25] 0.11941691 0.12902376 0.13947536 0.15086247 0.16328742 0.17686583
[31] 0.19172862 0.20802446 0.22592258 0.24561610 0.26732610 0.29130633
[37] 0.31784894 0.34729138 0.38002472 0.41650372 0.45725915 0.50291294
[43] 0.55419667 0.61197470 0.67727282 0.75131422 0.83556484 0.93179101
[49] 1.04213312 1.16920060 1.31619537 1.48707363 1.68675990 1.92143313
[55] 2.19891309 2.52918840 2.92514715 3.40360165 3.98674716 4.70427207
[61] 5.59646534 6.71888252 8.14950581
[Ok]
proc.time()s: user system elapsed
Time [ms] for dV01 : 10 0 10
Time [ms] for dCopula. : 20 0 10
Time [ms] for dCopula. : 20 0 10
Time [ms] for dCopula. : 20 0 10
>
> ### copFrank ###################################################################
>
> myFrank <- setTheta(copFrank, 1.860884)
> thetavec <- c(0.5,1,2,5,10)
> set.seed(11)
> tstCop(myFrank, 5.736283, thetavec)
(1) copula family: Frank, theta0 = 1.86088
(2) values of psi at i10:
[1] 1.999171e-01 6.521689e-02 2.308195e-02 8.376543e-03 3.066397e-03
[6] 1.126031e-03 4.139694e-04 1.522537e-04 5.600601e-05 2.060278e-05
check ifidentical(numeric(0), cop@iPsi(numeric(0), theta = theta0)): [Ok]
check ifcop@iPsi(0, theta = theta0) == Inf: [Ok]
values of iPsi at u01:
[1] 3.383282291 2.704567591 2.313464524 2.040074067 1.831151726 1.662981003
[7] 1.522910811 1.403389600 1.299546483 1.208055676 1.126545048 1.053263131
[13] 0.986879857 0.926361367 0.870888105 0.819799407 0.772554911 0.728707024
[19] 0.687880832 0.649759177 0.614071375 0.580584563 0.549096971 0.519432623
[25] 0.491437125 0.464974279 0.439923335 0.416176741 0.393638295 0.372221600
[31] 0.351848783 0.332449410 0.313959573 0.296321108 0.279480930 0.263390463
[37] 0.248005145 0.233283999 0.219189262 0.205686060 0.192742122 0.180327529
[43] 0.168414497 0.156977174 0.145991473 0.135434913 0.125286483 0.115526518
[49] 0.106136587 0.097099398 0.088398700 0.080019209 0.071946534 0.064167107
[55] 0.056668124 0.049437492 0.042463777 0.035736159 0.029244387 0.022978749
[61] 0.016930027 0.011089469 0.005448762
check if iPsi(psi(i10))==i10: TRUE
check if psi(iPsi(u01))==u01: TRUE
values of absdPsi with degree=10 at i10:
[1] 4.089829e+04 8.459713e+01 1.908810e+00 1.223381e-01 1.406804e-02
[6] 2.430145e-03 5.818411e-04 1.745537e-04 5.900330e-05 2.100739e-05
check if all values are nonnegative
check absdPsi(Inf,theta,degree=10) = 0 and the class of absdPsi(0,theta,degree=10): [Ok]
values of absdPsi with degree=10 and MC at i10:
[1] 4.096787e+04 8.846886e+01 1.901369e+00 1.215378e-01 1.425319e-02
[6] 2.458691e-03 5.800795e-04 1.718735e-04 5.772325e-05 2.049573e-05
check if all values are nonnegative
check absdPsi(Inf,theta,degree=10,n.MC=1000) = 0 and the class of absdPsi(0,theta,degree=10,n.MC=1000): [Ok]
values of absdiPsi at u01:
[1] 63.0740669 31.0785754 20.4164165 15.0875898 11.8920949 9.7632648
[7] 8.2439562 7.1055973 6.2212036 5.5145843 4.9372541 4.4568895
[13] 4.0511124 3.7039385 3.4036458 3.1414426 2.9106060 2.7059069
[19] 2.5232169 2.3592332 2.2112822 2.0771763 1.9551081 1.8435717
[25] 1.7413019 1.6472280 1.5604381 1.4801504 1.4056909 1.3364755
[31] 1.2719954 1.2118052 1.1555137 1.1027755 1.0532849 1.0067697
[37] 0.9629876 0.9217215 0.8827765 0.8459773 0.8111657 0.7781983
[43] 0.7469454 0.7172887 0.6891207 0.6623430 0.6368657 0.6126063
[49] 0.5894891 0.5674444 0.5464079 0.5263203 0.5071268 0.4887765
[55] 0.4712223 0.4544205 0.4383304 0.4229141 0.4081362 0.3939638
[61] 0.3803660 0.3673140 0.3547808
check the class of absdiPsi(0,theta): [Ok]
(3) parameter interval:
'interval' object [0, Inf)
theta1=5.736283
nesting condition for theta0 and theta1 fulfilled: TRUE
(4) 50 generated V0's:
Min. 1st Qu. Median Mean 3rd Qu. Max.
1.00 1.00 2.00 2.58 3.00 11.00
values of dV0 at i10:
[1] 0.453797724 0.191608130 0.107870897 0.068319891 0.046155001 0.032480233
[7] 0.023510072 0.017371752 0.013039854 0.009910529
50 generated V01's:
Min. 1st Qu. Median Mean 3rd Qu. Max.
1.00 4.00 16.50 45.40 43.25 476.00
values of dV01 at i10:
[1] 0.38291599 0.12893052 0.07177938 0.04785819 0.03506794 0.02723906
[7] 0.02201414 0.01831041 0.01556553 0.01346045
(5) values of cCopula(cbind(v,rev(v)), copula = cop) for v=u01:
[1] 0.994406634 0.988319173 0.981710344 0.974552697 0.966818818 0.958481577
[7] 0.949514405 0.939891609 0.929588717 0.918582862 0.906853183 0.894381268
[13] 0.881151608 0.867152064 0.852374352 0.836814508 0.820473356 0.803356931
[19] 0.785476876 0.766850771 0.747502396 0.727461916 0.706765951 0.685457557
[25] 0.663586072 0.641206842 0.618380828 0.595174078 0.571657087 0.547904049
[31] 0.523992020 0.500000000 0.476007980 0.452095951 0.428342913 0.404825922
[37] 0.381619172 0.358793158 0.336413928 0.314542443 0.293234049 0.272538084
[43] 0.252497604 0.233149229 0.214523124 0.196643069 0.179526644 0.163185492
[49] 0.147625648 0.132847936 0.118848392 0.105618732 0.093146817 0.081417138
[55] 0.070411283 0.060108391 0.050485595 0.041518423 0.033181182 0.025447303
[61] 0.018289656 0.011680827 0.005593366
(6) check dCopula(*, log = TRUE) for u being a random (20x2)-matrix:
[1] -0.538936036 -0.475301547 -0.082206821 0.596036095 -0.037471754
[6] 0.143330128 0.304659890 -0.961359630 -0.787618341 0.108746537
[11] -0.459370890 0.463156321 -0.781749517 0.078369130 0.067182425
[16] 0.092765840 0.097202596 0.341420400 -0.249323137 0.009196747
[Ok]
check at (0,0.5) and (1,0.5):
[Ok]
check dCopula(*, log = TRUE) for u being a random (20x20)-matrix:
[1] -4.2407200 -2.9344910 -1.9395971 -0.4669049 -1.2785012 -0.3609959
[7] 0.9641867 -2.0480190 -1.5578123 -1.4896688 -2.2451201 -1.9362259
[13] -1.4826958 -1.2616251 0.4319785 -0.2365624 -4.6739144 -0.8164454
[19] -0.3861239 -2.1949340
[Ok]
check dCopula(*, log = TRUE) and MC for u being a random (20x20)-matrix:
[1] -4.2146039 -2.8879549 -1.9084830 -0.4423409 -1.2538849 -0.3110631
[7] 0.9997603 -1.9960931 -1.5059672 -1.4645637 -2.1900648 -1.8855918
[13] -1.4276537 -1.2083030 0.4618976 -0.2119836 -4.6458299 -0.7708395
[19] -0.3547772 -2.1640291
[Ok]
(7) values of K for d = 2 at u01:
[1] 0.06926483 0.11827354 0.16018894 0.19771537 0.23210558 0.26408042
[7] 0.29410558 0.32250480 0.34951488 0.37531559 0.40004738 0.42382247
[13] 0.44673213 0.46885171 0.49024420 0.51096272 0.53105251 0.55055233
[19] 0.56949558 0.58791117 0.60582423 0.62325664 0.64022748 0.65675341
[25] 0.67284897 0.68852682 0.70379796 0.71867193 0.73315689 0.74725985
[31] 0.76098669 0.77434229 0.78733063 0.79995483 0.81221721 0.82411937
[37] 0.83566220 0.84684597 0.85767030 0.86813425 0.87823629 0.88797439
[43] 0.89734597 0.90634796 0.91497682 0.92322852 0.93109855 0.93858199
[49] 0.94567342 0.95236702 0.95865652 0.96453520 0.96999591 0.97503109
[55] 0.97963273 0.98379239 0.98750119 0.99074981 0.99352850 0.99582706
[61] 0.99763483 0.99894071 0.99973311
check if K(0) = 0 and K(1) = 1: [Ok]
values of K for d = 10 at u01:
[1] 0.6740342 0.7438465 0.7874874 0.8194291 0.8445310 0.8650654 0.8822947
[8] 0.8969999 0.9097019 0.9207681 0.9304691 0.9390109 0.9465555 0.9532327
[15] 0.9591491 0.9643939 0.9690424 0.9731594 0.9768014 0.9800177 0.9828523
[22] 0.9853443 0.9875288 0.9894375 0.9910993 0.9925401 0.9937840 0.9948526
[29] 0.9957658 0.9965418 0.9971971 0.9977469 0.9982046 0.9985829 0.9988928
[36] 0.9991444 0.9993466 0.9995074 0.9996338 0.9997318 0.9998068 0.9998634
[43] 0.9999052 0.9999357 0.9999574 0.9999726 0.9999828 0.9999896 0.9999940
[50] 0.9999966 0.9999982 0.9999991 0.9999996 0.9999998 0.9999999 1.0000000
[57] 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000
check if K(0) = 0 and K(1) = 1: [Ok]
values of K for d = 10 and MC at u01:
[1] 0.6551419 0.7246741 0.7682354 0.8007155 0.8268387 0.8486300 0.8671426
[8] 0.8830252 0.8967372 0.9086370 0.9190185 0.9281277 0.9361701 0.9433161
[15] 0.9497041 0.9554449 0.9606253 0.9653122 0.9695568 0.9733981 0.9768669
[22] 0.9799877 0.9827824 0.9852708 0.9874730 0.9894091 0.9911002 0.9925676
[29] 0.9938330 0.9949177 0.9958421 0.9966253 0.9972849 0.9978370 0.9982956
[36] 0.9986733 0.9989815 0.9992299 0.9994276 0.9995824 0.9997015 0.9997914
[43] 0.9998578 0.9999056 0.9999392 0.9999621 0.9999772 0.9999868 0.9999927
[50] 0.9999962 0.9999981 0.9999991 0.9999996 0.9999998 0.9999999 1.0000000
[57] 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000
check if K(0)=0 and K(1)=1: [Ok]
(8) tau at thetavec:
[1] 0.05541725 0.11001854 0.21389457 0.45670096 0.66577739
check if iTau(tau(thetavec))==thetavec: Mean relative difference: 4.060136e-07
(9) lambdaL at thetavec:
[1] 0 0 0 0 0
check if lambdaLInv(lambdaL(thetavec))==lambdaLvec: TRUE
(10) lambdaU at thetavec:
[1] 0 0 0 0 0
check if lambdaUInv(lambdaU(thetavec))==lambdaUvec: TRUE
(11) dDiag at u01 for d=10:
[1] 5.798356e-13 2.532419e-10 8.309848e-09 4.520187e-06 1.425760e-05
[6] 3.663656e-05 8.169497e-05 1.641525e-04 3.045146e-04 5.302230e-04
[11] 8.768162e-04 1.389057e-03 2.121977e-03 3.141776e-03 4.526521e-03
[16] 6.366590e-03 8.764790e-03 1.183613e-02 1.570720e-02 2.051516e-02
[21] 2.640640e-02 3.353480e-02 4.205980e-02 5.214431e-02 6.395260e-02
[26] 7.764821e-02 9.339223e-02 1.113418e-01 1.316490e-01 1.544610e-01
[31] 1.799194e-01 2.081620e-01 2.393241e-01 2.735409e-01 3.109509e-01
[36] 3.516994e-01 3.959436e-01 4.438583e-01 4.956418e-01 5.515240e-01
[41] 6.117750e-01 6.767159e-01 7.467311e-01 8.222836e-01 9.039344e-01
[46] 9.923656e-01 1.088411e+00 1.193097e+00 1.307691e+00 1.433774e+00
[51] 1.573335e+00 1.728902e+00 1.903728e+00 2.102065e+00 2.329560e+00
[56] 2.593877e+00 2.905664e+00 3.280149e+00 3.739885e+00 4.319735e+00
[61] 5.076580e+00 6.109924e+00 7.610991e+00
[Ok]
proc.time()s: user system elapsed
>
> ## with a slightly more extensive test:
> tau.th <- c(0.055417, 0.11002, 0.21389, 0.4567, 0.66578)
> tau.F <- myFrank@tau(thetavec)
> stopifnot(all.equal(tau.th, tau.F, tolerance = 0.0001),
+ all.equal(.9999, copFrank@tau(copFrank@iTau(0.9999))),
+ all.equal(myFrank@iTau(tau.F, tol = 1e-14), thetavec, tolerance=1e-11))
>
>
> ### copGumbel ##################################################################
>
> myGumbel <- setTheta(copGumbel, 1.25)
> thetavec <- c(1,2,4,6,10)
> (tG <- tstCop(myGumbel,2, thetavec, lambdaL = NA, lambdaU = thetavec))
(1) copula family: Gumbel, theta0 = 1.25
(2) values of psi at i10:
[1] 0.367879441 0.175327237 0.089974887 0.048246445 0.026678472 0.015101477
[7] 0.008710062 0.005102464 0.003028929 0.001818809
check ifidentical(numeric(0), cop@iPsi(numeric(0), theta = theta0)): [Ok]
check ifcop@iPsi(0, theta = theta0) == Inf: [Ok]
values of iPsi at u01:
[1] 5.939103439 4.728727978 4.047620829 3.577723845 3.221492284 2.936136030
[7] 2.699107164 2.497085396 2.321556498 2.166754056 2.028595404 1.904086503
[13] 1.790967995 1.687494046 1.592288423 1.504247578 1.422473481 1.346225883
[19] 1.274887648 1.207939086 1.144938628 1.085508058 1.029321064 0.976094268
[25] 0.925580100 0.877561099 0.831845299 0.788262473 0.746661039 0.706905507
[31] 0.668874345 0.632458198 0.597558383 0.564085614 0.531958920 0.501104719
[37] 0.471456029 0.442951781 0.415536240 0.389158494 0.363772026 0.339334337
[43] 0.315806627 0.293153528 0.271342880 0.250345545 0.230135269 0.210688581
[49] 0.191984743 0.174005741 0.156736338 0.140164204 0.124280128 0.109078372
[55] 0.094557191 0.080719641 0.067574809 0.055139765 0.043442804 0.032529228
[61] 0.022472728 0.013401623 0.005578842
check if iPsi(psi(i10))==i10: TRUE
check if psi(iPsi(u01))==u01: TRUE
values of absdPsi with degree=10 at i10:
[1] 1.364542e+04 2.768005e+01 7.763631e-01 6.317232e-02 9.121022e-03
[6] 1.875223e-03 4.881834e-04 1.501261e-04 5.218287e-05 1.990823e-05
check if all values are nonnegative
check absdPsi(Inf,theta,degree=10) = 0 and the class of absdPsi(0,theta,degree=10): [Ok]
values of absdPsi with degree=10 and MC at i10:
[1] 1.236487e+04 2.521803e+01 7.170005e-01 6.084796e-02 9.145834e-03
[6] 1.942173e-03 5.150928e-04 1.590554e-04 5.492712e-05 2.069756e-05
check if all values are nonnegative
check absdPsi(Inf,theta,degree=10,n.MC=1000) = 0 and the class of absdPsi(0,theta,degree=10,n.MC=1000): [Ok]
values of absdiPsi at u01:
[1] 114.2442011 54.5768992 35.2702629 25.8078222 20.2176839 16.5384183
[7] 13.9391398 12.0084424 10.5196994 9.3379579 8.3779235 7.5830876
[13] 6.9145544 6.3446899 5.8533309 5.4254263 5.0495177 4.7167306
[19] 4.4200865 4.1540240 3.9140569 3.6965273 3.4984230 3.3172416
[25] 3.1508866 2.9975892 2.8558457 2.7243702 2.6020563 2.4879463
[31] 2.3812073 2.2811108 2.1870168 2.0983604 2.0146405 1.9354109
[37] 1.8602722 1.7888655 1.7208664 1.6559808 1.5939401 1.5344978
[43] 1.4774261 1.4225133 1.3695603 1.3183786 1.2687871 1.2206101
[49] 1.1736734 1.1278016 1.0828137 1.0385181 0.9947054 0.9511389
[55] 0.9075409 0.8635705 0.8187892 0.7726005 0.7241383 0.6720375
[61] 0.6138911 0.5446654 0.4498402
check the class of absdiPsi(0,theta): [Ok]
(3) parameter interval:
'interval' object [1, Inf)
theta1=2
nesting condition for theta0 and theta1 fulfilled: TRUE
(4) 50 generated V0's:
Min. 1st Qu. Median Mean 3rd Qu. Max.
0.4025 0.5302 0.7869 1.2455 1.3972 5.6404
values of dV0 at i10:
[1] 0.545626959 0.102581867 0.040690238 0.021777131 0.013612490 0.009349937
[7] 0.006840431 0.005235462 0.004144970 0.003369051
50 generated V01's:
Min. 1st Qu. Median Mean 3rd Qu. Max.
0.0767 0.4092 1.3226 14.9676 3.0021 343.2702
values of dV01 at i10:
[1] 0.311002762 0.103284834 0.052469485 0.032315792 0.022176855 0.016306568
[7] 0.012577171 0.010046481 0.008242578 0.006906730
(5) values of cCopula(cbind(v,rev(v)), copula = cop) for v=u01:
[1] 0.996692708 0.991613815 0.985414890 0.978280348 0.970303683 0.961541145
[7] 0.952029897 0.941796129 0.930859326 0.919234785 0.906935235 0.893971954
[13] 0.880355591 0.866096805 0.851206772 0.835697613 0.819582762 0.802877271
[19] 0.785598087 0.767764279 0.749397229 0.730520788 0.711161380 0.691348076
[25] 0.671112611 0.650489363 0.629515271 0.608229719 0.586674360 0.564892903
[31] 0.542930850 0.520835205 0.498654146 0.476436678 0.454232268 0.432090477
[37] 0.410060593 0.388191273 0.366530214 0.345123839 0.324017026 0.303252870
[43] 0.282872500 0.262914924 0.243416945 0.224413109 0.205935718 0.188014889
[49] 0.170678668 0.153953205 0.137862985 0.122431137 0.107679825 0.093630749
[55] 0.080305804 0.067727965 0.055922517 0.044918876 0.034753442 0.025474488
[61] 0.017151485 0.009896087 0.003924509
(6) check dCopula(*, log = TRUE) for u being a random (20x2)-matrix:
[1] 0.12966771 -0.30020220 0.39444173 -0.56600621 -0.55684529 -0.87655183
[7] 0.10016574 0.19176874 0.09482334 0.03083255 -0.80204555 0.78095380
[13] -0.11612799 0.01745674 -0.17272548 0.08605285 -0.45649030 0.10743528
[19] 0.04853347 -0.59329405
[Ok]
check at (0,0.5) and (1,0.5):
[Ok]
check dCopula(*, log = TRUE) for u being a random (20x20)-matrix:
[1] -4.43686305 -0.02046617 -1.31439525 -1.86937921 -3.70900666 -1.35308273
[7] -2.45301791 -1.18264674 -0.51463598 -1.23159242 -1.33240012 -2.68631770
[13] 1.48465081 -1.71148065 -0.96981010 -1.60140910 -0.32785972 -0.95392353
[19] 0.54715746 -3.20416695
[Ok]
check dCopula(*, log = TRUE) and MC for u being a random (20x20)-matrix:
[1] -4.47249741 -0.03837289 -1.34987845 -1.89353568 -3.71069785 -1.38882593
[7] -2.47535871 -1.20326332 -0.54824864 -1.25728198 -1.36114063 -2.68381674
[13] 1.47165537 -1.72083503 -0.97814539 -1.59693467 -0.35892309 -0.95623433
[19] 0.51599828 -3.17029452
[Ok]
(7) values of K for d = 2 at u01:
[1] 0.06761104 0.11789340 0.16163515 0.20112944 0.23746532 0.27128427
[7] 0.30301013 0.33294415 0.36131158 0.38828725 0.41401082 0.43859647
[13] 0.46213923 0.48471951 0.50640617 0.52725887 0.54732982 0.56666505
[19] 0.58530547 0.60328770 0.62064467 0.63740617 0.65359930 0.66924878
[25] 0.68437727 0.69900563 0.71315310 0.72683750 0.74007538 0.75288214
[31] 0.76527215 0.77725887 0.78885490 0.80007209 0.81092157 0.82141387
[37] 0.83155889 0.84136604 0.85084420 0.86000181 0.86884690 0.87738707
[43] 0.88562960 0.89358140 0.90124908 0.90863897 0.91575710 0.92260924
[49] 0.92920096 0.93553755 0.94162412 0.94746559 0.95306665 0.95843185
[55] 0.96356555 0.96847197 0.97315517 0.97761905 0.98186741 0.98590389
[61] 0.98973203 0.99335524 0.99677683
check if K(0) = 0 and K(1) = 1: [Ok]
values of K for d = 10 at u01:
[1] 0.7407778 0.8014447 0.8334601 0.8545899 0.8700855 0.8821793 0.8920160
[8] 0.9002562 0.9073133 0.9134618 0.9188932 0.9237453 0.9281210 0.9320984
[15] 0.9357387 0.9390902 0.9421917 0.9450752 0.9477668 0.9502884 0.9526587
[22] 0.9548931 0.9570053 0.9590068 0.9609076 0.9627167 0.9644417 0.9660895
[29] 0.9676661 0.9691768 0.9706266 0.9720198 0.9733602 0.9746513 0.9758964
[36] 0.9770983 0.9782597 0.9793830 0.9804704 0.9815239 0.9825455 0.9835368
[43] 0.9844994 0.9854348 0.9863443 0.9872293 0.9880909 0.9889303 0.9897483
[50] 0.9905461 0.9913244 0.9920842 0.9928262 0.9935512 0.9942598 0.9949528
[57] 0.9956307 0.9962942 0.9969437 0.9975799 0.9982031 0.9988139 0.9994127
check if K(0) = 0 and K(1) = 1: [Ok]
values of K for d = 10 and MC at u01:
[1] 0.7323618 0.7955103 0.8285063 0.8500232 0.8656485 0.8777444 0.8875098
[8] 0.8956313 0.9025372 0.9085121 0.9137546 0.9184084 0.9225816 0.9263572
[15] 0.9298011 0.9329664 0.9358969 0.9386290 0.9411933 0.9436158 0.9459186
[22] 0.9481203 0.9502371 0.9522822 0.9542667 0.9561992 0.9580858 0.9599301
[29] 0.9617338 0.9634962 0.9652150 0.9668869 0.9685080 0.9700748 0.9715848
[36] 0.9730371 0.9744326 0.9757742 0.9770667 0.9783156 0.9795271 0.9807070
[43] 0.9818602 0.9829911 0.9841040 0.9852038 0.9862958 0.9873855 0.9884761
[50] 0.9895663 0.9906479 0.9917061 0.9927225 0.9936818 0.9945825 0.9954464
[57] 0.9963114 0.9971934 0.9980307 0.9986592 0.9989456 0.9989982 0.9992243
check if K(0)=0 and K(1)=1: [Ok]
(8) tau at thetavec:
[1] 0.0000000 0.5000000 0.7500000 0.8333333 0.9000000
check if iTau(tau(thetavec))==thetavec: TRUE
(9) lambdaL at thetavec:
[1] 0 0 0 0 0
check if lambdaLInv(lambdaL(thetavec))==lambdaLvec: TRUE
(10) lambdaU at thetavec:
[1] 0.0000000 0.5857864 0.8107929 0.8775380 0.9282265
check if lambdaUInv(lambdaU(thetavec))==lambdaUvec: TRUE
(11) dDiag at u01 for d=10:
[1] 1.621641e-09 6.431254e-08 5.536880e-07 2.550566e-06 8.340409e-06
[6] 2.195867e-05 4.978115e-05 1.011527e-04 1.890495e-04 3.307716e-04
[11] 5.486631e-04 8.708570e-04 1.332045e-03 1.974266e-03 2.847723e-03
[16] 4.011606e-03 5.534950e-03 7.497498e-03 9.990585e-03 1.311804e-02
[21] 1.699712e-02 2.175938e-02 2.755172e-02 3.453725e-02 4.289631e-02
[26] 5.282745e-02 6.454845e-02 7.829727e-02 9.433315e-02 1.129376e-01
[31] 1.344155e-01 1.590960e-01 1.873338e-01 2.195101e-01 2.560339e-01
[36] 2.973426e-01 3.439038e-01 3.962158e-01 4.548091e-01 5.202475e-01
[41] 5.931289e-01 6.740872e-01 7.637927e-01 8.629536e-01 9.723173e-01
[46] 1.092671e+00 1.224845e+00 1.369710e+00 1.528182e+00 1.701221e+00
[51] 1.889836e+00 2.095080e+00 2.318057e+00 2.559922e+00 2.821878e+00
[56] 3.105185e+00 3.411154e+00 3.741151e+00 4.096600e+00 4.478983e+00
[61] 4.889840e+00 5.330772e+00 5.803441e+00
[Ok]
proc.time()s: user system elapsed
Time [ms] for dV0 : 10 0 20
Time [ms] for dV01 : 20 0 20
Warning message:
In .integrate2(g1, lower = a, upper = b, subdivisions = subdivisions, :
roundoff error is detected in the extrapolation table
> u <- seq(0,1, length=32 + 1)[-c(1,32+1)]
> u <- as.matrix(expand.grid(u,u))
> myGumbel@dacopula(u, theta=1.25)
[1] 1.9359759 1.7558596 1.6352755 1.5413828 1.4630181 1.3949197 1.3341502
[8] 1.2788863 1.2279092 1.1803574 1.1355948 1.0931343 1.0525908 1.0136506
[15] 0.9760511 0.9395659 0.9039941 0.8691511 0.8348618 0.8009528 0.7672449
[22] 0.7335443 0.6996304 0.6652389 0.6300342 0.5935647 0.5551778 0.5138487
[29] 0.4677753 0.4131956 0.3392743 1.7558596 1.6340359 1.5480078 1.4784069
[36] 1.4184956 1.3650462 1.3162336 1.2709110 1.2283033 1.1878562 1.1491552
[43] 1.1118783 1.0757665 1.0406046 1.0062078 0.9724124 0.9390679 0.9060305
[50] 0.8731580 0.8403029 0.8073061 0.7739877 0.7401350 0.7054848 0.6696944
[57] 0.6322928 0.5925905 0.5494944 0.5010715 0.4432754 0.3644418 1.6352755
[64] 1.5480078 1.4836083 1.4298391 1.3823658 1.3390866 1.2988004 1.2607459
[71] 1.2244035 1.1893975 1.1554437 1.1223177 1.0898359 1.0578423 1.0261992
[78] 0.9947806 0.9634669 0.9321391 0.9006746 0.8689416 0.8367924 0.8040545
[85] 0.7705186 0.7359197 0.6999068 0.6619919 0.6214542 0.5771448 0.5270253
[92] 0.4668225 0.3842144 1.5413828 1.4784069 1.4298391 1.3880188 1.3501784
[99] 1.3149572 1.2815690 1.2495100 1.2184320 1.1880800 1.1582576 1.1288068
[106] 1.0995948 1.0705056 1.0414335 1.0122779 0.9829395 0.9533156 0.9232964
[113] 0.8927596 0.8615640 0.8295406 0.7964799 0.7621129 0.7260788 0.6878722
[120] 0.6467422 0.6014879 0.5499746 0.4877236 0.4018221 1.4630181 1.4184956
[127] 1.3823658 1.3501784 1.3202752 1.2918245 1.2643369 1.2374931 1.2110682
[134] 1.1848934 1.1588352 1.1327828 1.1066394 1.0803172 1.0537321 1.0268010
[141] 0.9994381 0.9715512 0.9430380 0.9137814 0.8836429 0.8524536 0.8200013
[148] 0.7860099 0.7501075 0.7117695 0.6702144 0.6241897 0.5714672 0.5073711
[155] 0.4184258 1.3949197 1.3650462 1.3390866 1.3149572 1.2918245 1.2692508
[162] 1.2469684 1.2247956 1.2025988 1.1802732 1.1577314 1.1348965 1.1116977
[169] 1.0880663 1.0639334 1.0392272 1.0138699 0.9877753 0.9608446 0.9329623
[176] 0.9039889 0.8737528 0.8420360 0.8085533 0.7729188 0.7345867 0.6927431
[183] 0.6460824 0.5922822 0.5264710 0.4346182 1.3341502 1.3162336 1.2988004
[190] 1.2815690 1.2643369 1.2469684 1.2293655 1.2114515 1.1931622 1.1744408
[197] 1.1552337 1.1354889 1.1151534 1.0941719 1.0724850 1.0500270 1.0267246
[204] 1.0024931 0.9772340 0.9508298 0.9231373 0.8939787 0.8631275 0.8302866
[211] 0.7950532 0.7568577 0.7148508 0.6676711 0.6128986 0.5454621 0.4507715
[218] 1.2788863 1.2709110 1.2607459 1.2495100 1.2374931 1.2247956 1.2114515
[225] 1.1974656 1.1828270 1.1675149 1.1515010 1.1347508 1.1172238 1.0988727
[232] 1.0796432 1.0594725 1.0382873 1.0160020 0.9925146 0.9677026 0.9414161
[239] 0.9134682 0.8836207 0.8515613 0.8168672 0.7789415 0.7368958 0.6893083
[246] 0.6336564 0.5646616 0.4671586 1.2279092 1.2283033 1.2244035 1.2184320
[253] 1.2110682 1.2025988 1.1931622 1.1828270 1.1716233 1.1595578 1.1466208
[260] 1.1327900 1.1180327 1.1023061 1.0855575 1.0677236 1.0487287 1.0284826
[267] 1.0068773 0.9837824 0.9590381 0.9324454 0.9037510 0.8726241 0.8386180
[274] 0.8011044 0.7591508 0.7112697 0.6548280 0.5843286 0.4840066 1.1803574
[281] 1.1878562 1.1893975 1.1880800 1.1848934 1.1802732 1.1744408 1.1675149
[288] 1.1595578 1.1505971 1.1406366 1.1296625 1.1176463 1.1045468 1.0903105
[295] 1.0748708 1.0581470 1.0400421 1.0204394 0.9991976 0.9761443 0.9510651
[302] 0.9236881 0.8936600 0.8605059 0.8235610 0.7818431 0.7337916 0.6766533
[309] 0.6046970 0.5015246 1.1355948 1.1491552 1.1554437 1.1582576 1.1588352
[316] 1.1577314 1.1552337 1.1515010 1.1466208 1.1406366 1.1335623 1.1253892
[323] 1.1160913 1.1056268 1.0939390 1.0809563 1.0665911 1.0507374 1.0332674
[330] 1.0140268 0.9928271 0.9694355 0.9435579 0.9148140 0.8826960 0.8464966
[337] 0.8051767 0.7570935 0.6993616 0.6259959 0.5199214 1.0931343 1.1118783
[344] 1.1223177 1.1288068 1.1327828 1.1348965 1.1354889 1.1347508 1.1327900
[351] 1.1296625 1.1253892 1.1199655 1.1133656 1.1055457 1.0964452 1.0859860
[358] 1.0740721 1.0605868 1.0453894 1.0283101 1.0091421 0.9876305 0.9634553
[365] 0.9362046 0.9053318 0.8700804 0.8293458 0.7813921 0.7231862 0.6484641
[372] 0.5394192 1.0525908 1.0757665 1.0898359 1.0995948 1.1066394 1.1116977
[379] 1.1151534 1.1172238 1.1180327 1.1176463 1.1160913 1.1133656 1.1094431
[386] 1.1042777 1.0978037 1.0899362 1.0805699 1.0695765 1.0568011 1.0420563
[393] 1.0251146 1.0056962 0.9834508 0.9579302 0.9285425 0.8944743 0.8545451
[400] 0.8069124 0.7483760 0.6723624 0.5602651 1.0136506 1.0406046 1.0578423
[407] 1.0705056 1.0803172 1.0880663 1.0941719 1.0988727 1.1023061 1.1045468
[414] 1.1056268 1.1055457 1.1042777 1.1017738 1.0979640 1.0927565 1.0860366
[421] 1.0776641 1.0674689 1.0552451 1.0407424 1.0236532 1.0035933 0.9800728
[428] 0.9524478 0.9198384 0.8809766 0.8338965 0.7752073 0.6979871 0.5827449
[435] 0.9760511 1.0062078 1.0261992 1.0414335 1.0537321 1.0639334 1.0724850
[442] 1.0796432 1.0855575 1.0903105 1.0939390 1.0964452 1.0978037 1.0979640
[449] 1.0968524 1.0943712 1.0903971 1.0847783 1.0773299 1.0678270 1.0559952
[456] 1.0414969 1.0239105 1.0026992 0.9771596 0.9463352 0.9088561 0.8626128
[463] 0.8039948 0.7256833 0.6071975 0.9395659 0.9724124 0.9947806 1.0122779
[470] 1.0268010 1.0392272 1.0500270 1.0594725 1.0677236 1.0748708 1.0809563
[477] 1.0859860 1.0899362 1.0927565 1.0943712 1.0946784 1.0935480 1.0908183
[484] 1.0862905 1.0797215 1.0708126 1.0591950 1.0444070 1.0258597 1.0027829
[491] 0.9741320 0.9384184 0.8933655 0.8351060 0.7558635 0.6340352 0.9039941
[498] 0.9390679 0.9634669 0.9829395 0.9994381 1.0138699 1.0267246 1.0382873
[505] 1.0487287 1.0581470 1.0665911 1.0740721 1.0805699 1.0860366 1.0903971
[512] 1.0935480 1.0953552 1.0956499 1.0942221 1.0908123 1.0850991 1.0766825
[519] 1.0650591 1.0495843 1.0294134 1.0034017 0.9699232 0.9265047 0.8689771
[526] 0.7890294 0.6637696 0.8691511 0.9060305 0.9321391 0.9533156 0.9715512
[533] 0.9877753 1.0024931 1.0160020 1.0284826 1.0400421 1.0507374 1.0605868
[540] 1.0695765 1.0776641 1.0847783 1.0908183 1.0956499 1.0991014 1.1009558
[547] 1.1009412 1.0987168 1.0938540 1.0858079 1.0738761 1.0571333 1.0343225
[554] 1.0036590 0.9624389 0.9061350 0.8258031 0.6970482 0.8348618 0.8731580
[561] 0.9006746 0.9232964 0.9430380 0.9608446 0.9772340 0.9925146 1.0068773
[568] 1.0204394 1.0332674 1.0453894 1.0568011 1.0674689 1.0773299 1.0862905
[575] 1.0942221 1.1009558 1.1062738 1.1098983 1.1114752 1.1105523 1.1065473
[582] 1.0987009 1.0860032 1.0670739 1.0399476 1.0016494 0.9472243 0.8669687
[589] 0.7347066 0.8009528 0.8403029 0.8689416 0.8927596 0.9137814 0.9329623
[596] 0.9508298 0.9677026 0.9837824 0.9991976 1.0140268 1.0283101 1.0420563
[603] 1.0552451 1.0678270 1.0797215 1.0908123 1.1009412 1.1098983 1.1174090
[610] 1.1231157 1.1265522 1.1271072 1.1239700 1.1160475 1.1018285 1.0791452
[617] 1.0447067 0.9930441 0.9135320 0.7778456 0.7672449 0.8073061 0.8367924
[624] 0.8615640 0.8836429 0.9039889 0.9231373 0.9414161 0.9590381 0.9761443
[631] 0.9928271 1.0091421 1.0251146 1.0407424 1.0559952 1.0708126 1.0850991
[638] 1.0987168 1.1114752 1.1231157 1.1332914 1.1415372 1.1472281 1.1495155
[645] 1.1472324 1.1387365 1.1216403 1.0922891 1.0445975 0.9668057 0.8279475
[652] 0.7335443 0.7739877 0.8040545 0.8295406 0.8524536 0.8737528 0.8939787
[659] 0.9134682 0.9324454 0.9510651 0.9694355 0.9876305 1.0056962 1.0236532
[666] 1.0414969 1.0591950 1.0766825 1.0938540 1.1105523 1.1265522 1.1415372
[673] 1.1550662 1.1665246 1.1750516 1.1794283 1.1778957 1.1678412 1.1452019
[680] 1.1031566 1.0285367 0.8870595 0.6996304 0.7401350 0.7705186 0.7964799
[687] 0.8200013 0.8420360 0.8631275 0.8836207 0.9037510 0.9236881 0.9435579
[694] 0.9634553 0.9834508 1.0035933 1.0239105 1.0444070 1.0650591 1.0858079
[701] 1.1065473 1.1271072 1.1472281 1.1665246 1.1844304 1.2001145 1.2123498
[708] 1.2192993 1.2181454 1.2043912 1.1703511 1.1010968 0.9580888 0.6652389
[715] 0.7054848 0.7359197 0.7621129 0.7860099 0.8085533 0.8302866 0.8515613
[722] 0.8726241 0.8936600 0.9148140 0.9362046 0.9579302 0.9800728 1.0026992
[729] 1.0258597 1.0495843 1.0738761 1.0987009 1.1239700 1.1495155 1.1750516
[736] 1.2001145 1.2239687 1.2454556 1.2627410 1.2728719 1.2709385 1.2482816
[743] 1.1877791 1.0453040 0.6300342 0.6696944 0.6999068 0.7260788 0.7501075
[750] 0.7729188 0.7950532 0.8168672 0.8386180 0.8605059 0.8826960 0.9053318
[757] 0.9285425 0.9524478 0.9771596 1.0027829 1.0294134 1.0571333 1.0860032
[764] 1.1160475 1.1472324 1.1794283 1.2123498 1.2454556 1.2777803 1.3076424
[771] 1.3321153 1.3460047 1.3396548 1.2932646 1.1552216 0.5935647 0.6322928
[778] 0.6619919 0.6878722 0.7117695 0.7345867 0.7568577 0.7789415 0.8011044
[785] 0.8235610 0.8464966 0.8700804 0.8944743 0.9198384 0.9463352 0.9741320
[792] 1.0034017 1.0343225 1.0670739 1.1018285 1.1387365 1.1778957 1.2192993
[799] 1.2627410 1.3076424 1.3527340 1.3954407 1.4306384 1.4479044 1.4243713
[806] 1.2982711 0.5551778 0.5925905 0.6214542 0.6467422 0.6702144 0.6927431
[813] 0.7148508 0.7368958 0.7591508 0.7818431 0.8051767 0.8293458 0.8545451
[820] 0.8809766 0.9088561 0.9384184 0.9699232 1.0036590 1.0399476 1.0791452
[827] 1.1216403 1.1678412 1.2181454 1.2728719 1.3321153 1.3954407 1.4612309
[834] 1.5252395 1.5771493 1.5912441 1.4921389 0.5138487 0.5494944 0.5771448
[841] 0.6014879 0.6241897 0.6460824 0.6676711 0.6893083 0.7112697 0.7337916
[848] 0.7570935 0.7813921 0.8069124 0.8338965 0.8626128 0.8933655 0.9265047
[855] 0.9624389 1.0016494 1.0447067 1.0922891 1.1452019 1.2043912 1.2709385
[862] 1.3460047 1.4306384 1.5252395 1.6281128 1.7314522 1.8091008 1.7690582
[869] 0.4677753 0.5010715 0.5270253 0.5499746 0.5714672 0.5922822 0.6128986
[876] 0.6336564 0.6548280 0.6766533 0.6993616 0.7231862 0.7483760 0.7752073
[883] 0.8039948 0.8351060 0.8689771 0.9061350 0.9472243 0.9930441 1.0445975
[890] 1.1031566 1.1703511 1.2482816 1.3396548 1.4479044 1.5771493 1.7314522
[897] 1.9113886 2.0997511 2.1932656 0.4131956 0.4432754 0.4668225 0.4877236
[904] 0.5073711 0.5264710 0.5454621 0.5646616 0.5843286 0.6046970 0.6259959
[911] 0.6484641 0.6723624 0.6979871 0.7256833 0.7558635 0.7890294 0.8258031
[918] 0.8669687 0.9135320 0.9668057 1.0285367 1.1010968 1.1877791 1.2932646
[925] 1.4243713 1.5912441 1.8091008 2.0997511 2.4851439 2.9063793 0.3392743
[932] 0.3644418 0.3842144 0.4018221 0.4184258 0.4346182 0.4507715 0.4671586
[939] 0.4840066 0.5015246 0.5199214 0.5394192 0.5602651 0.5827449 0.6071975
[946] 0.6340352 0.6637696 0.6970482 0.7347066 0.7778456 0.8279475 0.8870595
[953] 0.9580888 1.0453040 1.1552216 1.2982711 1.4921389 1.7690582 2.1932656
[960] 2.9063793 4.2199074
>
>
> ### copJoe #####################################################################
>
> myJoe <- setTheta(copJoe, 1.25)
> thetavec <- c(1.1,2,4,6,10)
> set.seed(111)
> tstCop(myJoe, 2, thetavec, lambdaL = NA, lambdaU = thetavec)
(1) copula family: Joe, theta0 = 1.25
(2) values of psi at i10:
[1] 3.071489e-01 1.098193e-01 4.003202e-02 1.467955e-02 5.393999e-03
[6] 1.983494e-03 7.295721e-04 2.683791e-04 9.872906e-05 3.632011e-05
check ifidentical(numeric(0), cop@iPsi(numeric(0), theta = theta0)): [Ok]
check ifcop@iPsi(0, theta = theta0) == Inf: [Ok]
values of iPsi at u01:
[1] 3.937702264 3.246537315 2.843074378 2.557414872 2.336314758 2.156057999
[7] 2.003993989 1.872571668 1.756920658 1.653715696 1.560585195 1.475778245
[13] 1.397965362 1.326113288 1.259403098 1.197174778 1.138888651 1.084097834
[19] 1.032428160 0.983563250 0.937233241 0.893206131 0.851281053 0.811282989
[25] 0.773058551 0.736472609 0.701405540 0.667750990 0.635414029 0.604309615
[31] 0.574361317 0.545500246 0.517664142 0.490796610 0.464846469 0.439767189
[37] 0.415516417 0.392055567 0.369349467 0.347366062 0.326076154 0.305453188
[43] 0.285473067 0.266114007 0.247356415 0.229182802 0.211577731 0.194527785
[49] 0.178021590 0.162049863 0.146605528 0.131683887 0.117282891 0.103403528
[55] 0.090050398 0.077232558 0.064964805 0.053269683 0.042180797 0.031748698
[61] 0.022052429 0.013226087 0.005539587
check if iPsi(psi(i10))==i10: TRUE
check if psi(iPsi(u01))==u01: TRUE
values of absdPsi with degree=10 at i10:
[1] 1.187561e+04 2.260993e+01 6.318471e-01 5.606628e-02 9.727155e-03
[6] 2.515821e-03 7.990700e-04 2.776606e-04 9.997904e-05 3.648897e-05
check if all values are nonnegative
check absdPsi(Inf,theta,degree=10) = 0 and the class of absdPsi(0,theta,degree=10): [Ok]
values of absdPsi with degree=10 and MC at i10:
[1] 1.050962e+04 2.212563e+01 5.865500e-01 5.296547e-02 9.634431e-03
[6] 2.540844e-03 8.113478e-04 2.823326e-04 1.017056e-04 3.712451e-05
check if all values are nonnegative
check absdPsi(Inf,theta,degree=10,n.MC=1000) = 0 and the class of absdPsi(0,theta,degree=10,n.MC=1000): [Ok]
values of absdiPsi at u01:
[1] 63.8737658 31.8725039 21.2045467 15.8698930 12.6685418 10.5338253
[7] 9.0085992 7.8642909 6.9739148 6.2612791 5.6778972 5.1914444
[13] 4.7795412 4.4262017 4.1197025 3.8512502 3.6141198 3.4030802
[19] 3.2140009 3.0435769 2.8891318 2.7484753 2.6197970 2.5015878
[25] 2.3925787 2.2916955 2.1980219 2.1107715 2.0292653 1.9529138
[31] 1.8812021 1.8136783 1.7499439 1.6896455 1.6324684 1.5781308
[37] 1.5263792 1.4769845 1.4297380 1.3844491 1.3409422 1.2990544
[43] 1.2586333 1.2195353 1.1816230 1.1447640 1.1088283 1.0736862
[49] 1.0392060 1.0052507 0.9716746 0.9383177 0.9049998 0.8715105
[55] 0.8375949 0.8029328 0.7671025 0.7295206 0.6893288 0.6451613
[61] 0.5945968 0.5325575 0.4443967
check the class of absdiPsi(0,theta): [Ok]
(3) parameter interval:
'interval' object [1, Inf)
theta1=2
nesting condition for theta0 and theta1 fulfilled: TRUE
(4) 50 generated V0's:
Min. 1st Qu. Median Mean 3rd Qu. Max.
1.00 1.00 1.00 1.78 1.00 14.00
values of dV0 at i10:
[1] 0.800000000 0.080000000 0.032000000 0.017600000 0.011264000 0.007884800
[7] 0.005857280 0.004539392 0.003631514 0.002977841
50 generated V01's:
Min. 1st Qu. Median Mean 3rd Qu. Max.
1.00 1.00 1.00 71.18 3.50 3326.00
values of dV01 at i10:
[1] 0.625000000 0.117187500 0.053710938 0.031890869 0.021526337 0.015696287
[7] 0.012052506 0.009604341 0.007870224 0.006591312
(5) values of cCopula(cbind(v,rev(v)), copula = cop) for v=u01:
[1] 0.994453886 0.986756041 0.977925249 0.968242106 0.957851039 0.946841451
[7] 0.935274536 0.923195019 0.910637199 0.897628409 0.884191159 0.870344553
[13] 0.856105266 0.841488249 0.826507259 0.811175264 0.795504762 0.779508036
[19] 0.763197368 0.746585204 0.729684296 0.712507822 0.695069468 0.677383508
[25] 0.659464854 0.641329089 0.622992490 0.604472030 0.585785369 0.566950830
[31] 0.547987365 0.528914507 0.509752322 0.490521343 0.471242508 0.451937091
[37] 0.432626634 0.413332881 0.394077716 0.374883107 0.355771059 0.336763585
[43] 0.317882678 0.299150313 0.280588462 0.262219138 0.244064455 0.226146739
[49] 0.208488664 0.191113445 0.174045096 0.157308768 0.140931199 0.124941331
[55] 0.109371152 0.094256883 0.079640730 0.065573553 0.052119201 0.039362101
[61] 0.027422008 0.016487703 0.006918835
(6) check dCopula(*, log = TRUE) for u being a random (20x2)-matrix:
[1] 0.11027608 0.01760616 0.11306512 -0.24932047 -0.13162467 0.07570668
[7] 0.13483813 -0.03439151 -0.15779828 0.04550976 0.18066712 -0.11801498
[13] 0.16785299 0.09950962 0.12430572 -0.86325088 -0.17599031 0.06124031
[19] 0.01900160 -0.18000374
[Ok]
check at (0,0.5) and (1,0.5):
[Ok]
check dCopula(*, log = TRUE) for u being a random (20x20)-matrix:
[1] -0.69305005 -2.43349943 1.77534291 -0.75363959 -2.01723547 0.39271143
[7] -0.01043950 0.55194376 -2.03317973 -0.28660358 0.96741445 0.17212766
[13] -0.25870717 -0.60657722 -1.17838543 -1.43675516 -0.92937813 0.15361164
[19] 0.02254346 0.49819960
[Ok]
check dCopula(*, log = TRUE) and MC for u being a random (20x20)-matrix:
[1] -0.679106414 -2.426192986 1.791461752 -0.738758981 -2.004818066
[6] 0.408620284 0.005666683 0.567704013 -2.019749559 -0.347143637
[11] 0.983533779 0.188236444 -0.242590152 -0.590486607 -1.185937962
[16] -1.420677736 -0.914538489 0.094237112 0.038135742 0.514294275
[Ok]
(7) values of K for d = 2 at u01:
[1] 0.07727319 0.13311013 0.18095353 0.22364884 0.26254360 0.29842949
[7] 0.33182845 0.36311068 0.39255246 0.42036787 0.44672767 0.47177122
[13] 0.49561445 0.51835525 0.54007744 0.56085355 0.58074700 0.59981370
[19] 0.61810333 0.63566031 0.65252461 0.66873241 0.68431660 0.69930723
[25] 0.71373184 0.72761582 0.74098263 0.75385400 0.76625016 0.77818998
[31] 0.78969112 0.80077012 0.81144257 0.82172313 0.83162567 0.84116334
[37] 0.85034858 0.85919326 0.86770867 0.87590562 0.88379444 0.89138503
[43] 0.89868694 0.90570936 0.91246115 0.91895091 0.92518699 0.93117751
[49] 0.93693040 0.94245343 0.94775425 0.95284040 0.95771938 0.96239864
[55] 0.96688568 0.97118807 0.97531356 0.97927012 0.98306612 0.98671048
[61] 0.99021304 0.99358504 0.99684041
check if K(0) = 0 and K(1) = 1: [Ok]
values of K for d = 10 at u01:
[1] 0.8619089 0.8878125 0.9017248 0.9112200 0.9184248 0.9242306 0.9290941
[8] 0.9332805 0.9369568 0.9402354 0.9431952 0.9458939 0.9483748 0.9506713
[15] 0.9528097 0.9548112 0.9566928 0.9584686 0.9601506 0.9617485 0.9632709
[22] 0.9647250 0.9661171 0.9674525 0.9687362 0.9699722 0.9711642 0.9723157
[29] 0.9734296 0.9745084 0.9755546 0.9765704 0.9775577 0.9785182 0.9794537
[36] 0.9803656 0.9812552 0.9821239 0.9829728 0.9838029 0.9846153 0.9854109
[43] 0.9861906 0.9869552 0.9877053 0.9884419 0.9891654 0.9898766 0.9905760
[50] 0.9912643 0.9919418 0.9926093 0.9932671 0.9939158 0.9945558 0.9951876
[57] 0.9958115 0.9964281 0.9970378 0.9976410 0.9982382 0.9988300 0.9994170
check if K(0) = 0 and K(1) = 1: [Ok]
values of K for d = 10 and MC at u01:
[1] 0.8684994 0.8927085 0.9054731 0.9143082 0.9211899 0.9268889 0.9317757
[8] 0.9360567 0.9398597 0.9432719 0.9463564 0.9491620 0.9517274 0.9540848
[15] 0.9562613 0.9582803 0.9601621 0.9619249 0.9635842 0.9651540 0.9666461
[22] 0.9680704 0.9694349 0.9707458 0.9720072 0.9732219 0.9743908 0.9755139
[29] 0.9765905 0.9776196 0.9786004 0.9795327 0.9804173 0.9812564 0.9820532
[36] 0.9828126 0.9835401 0.9842421 0.9849253 0.9855963 0.9862613 0.9869265
[43] 0.9875974 0.9882801 0.9889811 0.9897081 0.9904704 0.9912774 0.9921364
[50] 0.9930470 0.9939945 0.9949435 0.9958389 0.9966155 0.9972183 0.9976251
[57] 0.9978582 0.9979901 0.9981624 0.9985931 0.9993572 0.9999231 0.9999998
check if K(0)=0 and K(1)=1: [Ok]
(8) tau at thetavec:
[1] 0.05439832 0.35506593 0.61370564 0.72259094 0.82204394
check if iTau(tau(thetavec))==thetavec: Mean relative difference: 9.475501e-07
(9) lambdaL at thetavec:
[1] 0 0 0 0 0
check if lambdaLInv(lambdaL(thetavec))==lambdaLvec: TRUE
(10) lambdaU at thetavec:
[1] 0.1221382 0.5857864 0.8107929 0.8775380 0.9282265
check if lambdaUInv(lambdaU(thetavec))==lambdaUvec: TRUE
(11) dDiag at u01 for d=10:
[1] 4.047519e-15 2.027560e-12 7.624368e-11 9.930070e-10 7.233201e-09
[6] 3.647835e-08 1.427289e-07 4.637395e-07 1.307246e-06 3.294254e-06
[11] 7.581273e-06 1.618657e-05 3.244814e-05 6.164311e-05 1.117990e-04
[16] 1.947279e-04 3.273128e-04 5.330731e-04 8.440347e-04 1.302921e-03
[21] 1.965678e-03 2.904346e-03 4.210255e-03 5.997559e-03 8.407052e-03
[26] 1.161026e-02 1.581374e-02 2.126351e-02 2.824958e-02 3.711045e-02
[31] 4.823748e-02 6.207902e-02 7.914422e-02 1.000062e-01 1.253049e-01
[36] 1.557485e-01 1.921147e-01 2.352502e-01 2.860691e-01 3.455500e-01
[41] 4.147312e-01 4.947042e-01 5.866050e-01 6.916033e-01 8.108892e-01
[46] 9.456570e-01 1.097086e+00 1.266317e+00 1.454427e+00 1.662395e+00
[51] 1.891068e+00 2.141113e+00 2.412967e+00 2.706771e+00 3.022290e+00
[56] 3.358814e+00 3.715018e+00 4.088786e+00 4.476932e+00 4.874769e+00
[61] 5.275336e+00 5.667751e+00 6.032564e+00
[Ok]
proc.time()s: user system elapsed
Time [ms] for tauI : 20 0 20
>
>
> ### Regression tests ------------------------------------
>
> chkPsi <- function(copula, t = c(0, 2^c(-1000,-500, -200,-10*(10:0)), 2:3, 2^(2:40),Inf)) {
+ stopifnot(is(copula, "Copula"))
+ if(is.unsorted(t)) t <- sort(t)
+ psf <- psi(copula, t)
+ ## and also an equidistant t --> to check convexity
+ ps.eq <- psi(copula, t. <- seq(0, 20, length=1+2^7))
+ stopifnot(is.finite(psf), 0 <= psf, psf <= 1,
+ psf[1] == 1, diff(psf) <= 0,
+ is.na (pN <- psi(copula, c(NA, NaN))),
+ is.nan(pN[2]),
+ 0 <= ps.eq, ps.eq <= 1, diff(ps.eq) <= 0,
+ ## convexity (in light of finite accuracy arithmetic):
+ diff(ps.eq, diff=2) >= - 4*.Machine$double.eps *ps.eq[-(1:2)]
+ )
+
+ ## for plotting:
+ it <- sort.list(tt <- c(t,t.))
+ invisible(list(x=tt[it], y= c(psf, ps.eq)[it]))
+ }
>
> ### Negative tau (and dim = 2):
>
> taus <- c(-1,0,1); names(taus) <- paste0("tau=",taus)
> taus
tau=-1 tau=0 tau=1
-1 0 1
>
> ## Frank: --------------------------------------------------------
> vapply(taus, function(tau) iTau(frankCopula(), tau), 1.)
tau=-1 tau=0 tau=1
-1.81e+16 0.00e+00 7.21e+16
> ## tau=-1 tau=0 tau=1
> ## -1.81e+16 0.00e+00 7.21e+16
> ## ~= - Inf 0 + Inf
>
> r <- chkPsi(frankCopula(-2))
> plot(r, type="o")
> plot(r, type="o", log="xy")
Warning messages:
1: In xy.coords(x, y, xlabel, ylabel, log) :
2 x values <= 0 omitted from logarithmic plot
2: In xy.coords(x, y, xlabel, ylabel, log) :
32 y values <= 0 omitted from logarithmic plot
> chkPsi(frankCopula( -800))# failed before 2014-06
> chkPsi(frankCopula(-2000))# (ditto)
> chkPsi(frankCopula(-1e10))# (ditto)
>
>
> ## Clayton: ------------------------------------------------------
>
> vapply(taus, function(tau) iTau(claytonCopula(), tau), 1.)
tau=-1 tau=0 tau=1
-1 0 Inf
> ## tau=-1 tau=0 tau=1
> ## -1 0 Inf
>
> stopifnot(all.equal(-2/3, iTau(claytonCopula(), -1/2)))
>
> tools::assertError(chkPsi(claytonCopula(-1.1))) # par. out of bound
> chkPsi(claytonCopula(-1)) ## all failed before 2014-05
> chkPsi(claytonCopula(-.5))
> chkPsi(claytonCopula(-1/8))
> chkPsi(claytonCopula(-2^-10))
>
> ## AMH:
> tAMH <- c((5 - 8*log(2))/ 3, -1/8, 0, 1/8, 1/3)
> (th.t <- vapply(tAMH, function(tau) iTau(amhCopula(), tau), 1.))
[1] -1.000000e+00 -6.463595e-01 1.368215e-13 4.875224e-01 1.000000e+00
> stopifnot(-1 <= th.t, th.t <= 1,
+ all.equal(th.t[c(1,3,5)], c(-1,0,1)))
> ## rho: --> ../vignettes/rhoAMH-dilog.Rnw
>
> ## cCopula() for all three "negative" tau families:
> ## -------- --------------
> cCneg <- function(tau, u1 = (1:8)/8) {
+ stopifnot(length(tau) == 1, is.finite(tau), -1 <= tau, tau <= 1)
+ u <- cbind(u1, .5)
+ rbind(A = cCopula(u, amhCopula(iTau( amhCopula(), tau)))[,2],
+ C = cCopula(u, claytonCopula(iTau(claytonCopula(), tau)))[,2],
+ F = cCopula(u, frankCopula(iTau( frankCopula(), tau)))[,2])
+ }
>
> ## AMH and Frank "failed" because cop(AMH|Frank) @ absdPsi(*, log=TRUE) gave NaN
> (cACF <- cCneg(tau = -0.18))
[,1] [,2] [,3] [,4] [,5] [,6] [,7]
A 0.3640882 0.3976526 0.4360816 0.4803628 0.5317478 0.5918415 0.6627290
C 0.3625358 0.4569607 0.5081785 0.5424644 0.5678378 0.5877676 0.6040540
F 0.3488709 0.3974733 0.4481862 0.5000000 0.5518138 0.6025267 0.6511291
[,8]
A 0.7471590
C 0.6177456
F 0.6967794
> stopifnot(is.finite(cACF), !apply(cACF, 1, is.unsorted),
+ 0.348 <= cACF, cACF <= 0.748,
+ ## *are* somewhat similar as they have same tau:
+ all.equal(cACF["A",], cACF["F",], tol = 0.035)
+ ,
+ all.equal(cACF["C",], cACF["F",], tol = 0.079)
+ )
>
> ## FIXME: u1 = 0 still gives NaN, and for Clayton even others
> u1. <- c(0, 1e-100, 1e-20, 1e-10, 1e-5, 1e-4, 1e-3, .01)
> cCneg(-0.18, u1 = u1.)
[,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8]
A NaN 0.3346008 0.3346008 0.3346008 0.3346030 0.3346229 0.3348223 0.33682553
C NaN NaN NaN NaN NaN NaN NaN 0.03284787
F NaN 0.3032206 0.3032206 0.3032206 0.3032241 0.3032558 0.3035723 0.30674776
Warning message:
In log1p(-t) : NaNs produced
>
> ###---- Large Tau Random Numbers -------------------------------------
>
> taus <- c(.80, .85, .90, .95, .98, .99, .993, .995, .996, .997, .998, .999)
> namT <- paste0("tau=", formatC(taus))
> archCops <- list(C = claytonCopula,
+ F = frankCopula,
+ G = gumbelCopula,
+ ## A = amhCopula, ## max tau = 1/3 = 0.33333
+ J = joeCopula)
> thC <- lapply(archCops, function(Cop) setNames(iTau(Cop(), taus), namT))
> simplify2array(thC)
C F G J
tau=0.8 8.00000 18.19154 5.000000 8.767707
tau=0.85 11.33333 24.90541 6.666667 12.086468
tau=0.9 18.00000 38.28121 10.000000 18.738669
tau=0.95 38.00000 78.31978 20.000000 38.724328
tau=0.98 98.00000 198.34131 50.000000 98.715792
tau=0.99 198.00000 398.34825 100.000000 198.712959
tau=0.993 283.71429 569.77887 142.857143 284.426396
tau=0.995 398.00000 798.35167 200.000000 398.711545
tau=0.996 498.00000 998.35235 250.000000 498.711262
tau=0.997 664.66667 1331.68636 333.333333 665.377646
tau=0.998 998.00000 1998.35371 500.000000 998.710697
tau=0.999 1998.00000 3998.35439 1000.000000 1998.710414
>
> Cops <- lapply(names(thC), function(nm) lapply(thC[[nm]], function(th) archCops[[nm]](th, dim=3)))
> uC <- lapply(setNames(,names(thC)), function(nm)
+ lapply(thC[[nm]], function(th) rCopula(n = 100, archCops[[nm]](th, dim=3))))
>
> (aU <- simplify2array(uC))
C F G J
tau=0.8 numeric,300 numeric,300 numeric,300 numeric,300
tau=0.85 numeric,300 numeric,300 numeric,300 numeric,300
tau=0.9 numeric,300 numeric,300 numeric,300 numeric,300
tau=0.95 numeric,300 numeric,300 numeric,300 numeric,300
tau=0.98 numeric,300 numeric,300 numeric,300 numeric,300
tau=0.99 numeric,300 numeric,300 numeric,300 numeric,300
tau=0.993 numeric,300 numeric,300 numeric,300 numeric,300
tau=0.995 numeric,300 numeric,300 numeric,300 numeric,300
tau=0.996 numeric,300 numeric,300 numeric,300 numeric,300
tau=0.997 numeric,300 numeric,300 numeric,300 numeric,300
tau=0.998 numeric,300 numeric,300 numeric,300 numeric,300
tau=0.999 numeric,300 numeric,300 numeric,300 numeric,300
> mima <- t(sapply(aU, range))
> stopifnot(!vapply(aU, anyNA, NA), # no NA's
+ 0 <= mima[,1], mima[,1] <= mima[,2], mima[,2] <= 1)
>
> proc.time()
user system elapsed
13.62 0.12 13.71