[Vinecopula-commits] r137 - in pkg: R man
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Do Sep 17 19:30:45 CEST 2015
Author: tnagler
Date: 2015-09-17 19:30:45 +0200 (Thu, 17 Sep 2015)
New Revision: 137
Modified:
pkg/R/BiCopCheck.R
pkg/R/BiCopTau2Par.r
pkg/man/BiCopTau2Par.Rd
Log:
* added BiCopCheckTaus function
* added check.taus option to BiCopTau2Par.Rd
* adjusted manual accordingly
Modified: pkg/R/BiCopCheck.R
===================================================================
--- pkg/R/BiCopCheck.R 2015-09-17 16:50:00 UTC (rev 136)
+++ pkg/R/BiCopCheck.R 2015-09-17 17:30:45 UTC (rev 137)
@@ -94,4 +94,28 @@
## return TRUE if all checks pass
TRUE
+}
+
+BiCopCheckTaus <- function(family, tau) {
+ ## check for family/tau consistency
+ checkTaus<- function(x) {
+ if (family %in% c(3, 13) && tau <= 0)
+ stop("Clayton copula cannot be used for tau<=0.")
+ if (family %in% c(4, 14) && tau < 0)
+ stop("Gumbel copula cannot be used for tau<0.")
+ if (family == 5 && tau == 0)
+ stop("Frank copula cannot be used for tau=0")
+ if (family %in% c(6, 16) && tau < 0)
+ stop("Joe copula cannot be used for tau<0.")
+ if (family %in% c(23, 33) && tau >= 0)
+ stop("Rotated Clayton copula cannot be used for tau>=0.")
+ if (family %in% c(24, 34) && tau > 0)
+ stop("Rotated Gumbel copula cannot be used for tau>0.")
+ if (family %in% c(26, 36) && tau > 0)
+ stop("Rotated Joe copula cannot be used for tau>0.")
+ }
+ apply(cbind(family, tau), 1, checkTaus)
+
+ ## return TRUE if all checks pass
+ TRUE
}
\ No newline at end of file
Modified: pkg/R/BiCopTau2Par.r
===================================================================
--- pkg/R/BiCopTau2Par.r 2015-09-17 16:50:00 UTC (rev 136)
+++ pkg/R/BiCopTau2Par.r 2015-09-17 17:30:45 UTC (rev 137)
@@ -1,4 +1,4 @@
-BiCopTau2Par <- function(family, tau) {
+BiCopTau2Par <- function(family, tau, check.taus = TRUE) {
## sanity check
if (any(abs(tau) > 0.99999))
stop("some tau is too close to -1 or 1")
@@ -12,6 +12,11 @@
if (!all(c(length(family), length(tau)) %in% c(1, n)))
stop("Input lenghts don't match")
+ ## check for family/tau consistency
+ if (check.taus)
+ BiCopCheckTaus(family, tau)
+
+
## calculate the parameter
if (length(tau) == 1) {
# call for single parameters
@@ -34,30 +39,18 @@
} else if (family %in% 1:2) {
par <- sin(pi * tau/2)
} else if (family %in% c(3, 13)) {
- if (tau < 0)
- stop("Clayton copula cannot be used for tau<0.")
par <- 2 * tau/(1 - tau)
} else if (family %in% c(4, 14)) {
- if (tau < 0)
- stop("Gumbel copula cannot be used for tau<0.")
par <- 1/(1 - tau)
} else if (family == 5) {
par <- if (tau == 0) 0 else Frank.itau.JJ(tau)
} else if (family %in% c(6, 16)) {
- if (tau < 0)
- stop("Joe copula cannot be used for tau<0.")
par <- Joe.itau.JJ(tau)
} else if (family %in% c(23, 33)) {
- if (tau > 0)
- stop("Rotated Clayton copula cannot be used for tau>0.")
par <- 2 * tau/(1 + tau)
} else if (family %in% c(24, 34)) {
- if (tau > 0)
- stop("Rotated Gumbel copula cannot be used for tau>0.")
par <- -(1/(1 + tau))
} else if (family %in% c(26, 36)) {
- if (tau > 0)
- stop("Rotated Joe copula cannot be used for tau>0.")
par <- -Joe.itau.JJ(-tau)
} else if (family %in% c(41, 51)) {
par <- ipsA.tau2cpar(tau)
Modified: pkg/man/BiCopTau2Par.Rd
===================================================================
--- pkg/man/BiCopTau2Par.Rd 2015-09-17 16:50:00 UTC (rev 136)
+++ pkg/man/BiCopTau2Par.Rd 2015-09-17 17:30:45 UTC (rev 137)
@@ -8,7 +8,7 @@
}
\usage{
-BiCopTau2Par(family, tau)
+BiCopTau2Par(family, tau, check.taus = TRUE)
}
\arguments{
@@ -31,6 +31,7 @@
\code{36} = rotated Joe copula (270 degrees)\cr
Note that (with exception of the t-copula) two parameter bivariate copula families cannot be used.}
\item{tau}{numeric; single number or vector of size \code{m}; Kendall's tau value (vector with elements in [-1,1]).}
+ \item{check.taus}{logical; default is \code{TRUE}; if \code{FALSE}, checks for family/tau-consistency are ommited (should only be used with care).}
}
\value{
Mehr Informationen über die Mailingliste Vinecopula-commits