[spcopula-commits] r130 - in pkg: R man

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Tue Mar 18 10:32:19 CET 2014


Author: ben_graeler
Date: 2014-03-18 10:32:19 +0100 (Tue, 18 Mar 2014)
New Revision: 130

Modified:
   pkg/R/partialDerivatives.R
   pkg/R/spCopula.R
   pkg/man/dependencePlot.Rd
   pkg/man/invdduCopula-methods.Rd
   pkg/man/invddvCopula-methods.Rd
Log:
- add invddu and inddv methods for bivariate spatial copulas

Modified: pkg/R/partialDerivatives.R
===================================================================
--- pkg/R/partialDerivatives.R	2014-03-17 13:57:05 UTC (rev 129)
+++ pkg/R/partialDerivatives.R	2014-03-18 09:32:19 UTC (rev 130)
@@ -6,7 +6,7 @@
 
 ## inverse partial derivatives 
 # numerical standard function
-invdduCopula <- function(u, copula, y, tol=.Machine$double.eps^0.5) {
+invdduCopula <- function(u, copula, y, ..., tol=.Machine$double.eps^0.5) {
     if (length(u) != length(y)) 
         stop("Length of u and y differ!")
     message("Numerical evaluation of invddu takes place.")
@@ -21,7 +21,7 @@
 
 setGeneric("invdduCopula")
 
-invddvCopula <- function(v, copula, y, tol=.Machine$double.eps^0.5) {
+invddvCopula <- function(v, copula, y, ..., tol=.Machine$double.eps^0.5) {
     if (length(v) != length(y)) 
         stop("Length of v and y differ!")
   message("Numerical evaluation of invddv takes place.")

Modified: pkg/R/spCopula.R
===================================================================
--- pkg/R/spCopula.R	2014-03-17 13:57:05 UTC (rev 129)
+++ pkg/R/spCopula.R	2014-03-18 09:32:19 UTC (rev 130)
@@ -358,10 +358,34 @@
 setMethod("dduCopula", signature("numeric","spCopula"), 
           function(u, copula, ...) dduSpCopula(matrix(u,ncol=copula at dimension),copula, ...) )
 
+invdduSpCopula <- function(u, copula, y, h, tol=.Machine$double.eps^0.5) {
+  message("invdduCopula is numerically evalauted.")
+  
+  nElem <- length(u)
+  stopifnot(nElem == length(y))
+  stopifnot(length(h) == 1 | length(h)==nElem)
+  
+  optFun <- function(u, v, y, h) abs(dduSpCopula(cbind(rep(u, length(v)), v), copula, h)-y)
+  
+  optMe <- function(aU, aY, aH) optimise(function(v) optFun(u=aU, v, y=aY, h=aH), c(0,1))$minimum
+  
+  if(length(h) == 1 & nElem > 1)
+    h <- rep(h, nElem)
+  
+  rV <- numeric(nElem)
+  for (i in 1:nElem) {
+    rV[i] <- optMe(u[i], y[i], h[i])
+  }
+  
+  return(rV)
+}
+
+setMethod("invdduCopula", signature("numeric", "spCopula"), invdduSpCopula)
+
 ## ddvSpCopula
 ###############
 
-ddvSpCopula <- function (u, copula, h, block=1) {
+ddvSpCopula <- function (u, copula, h) {
   if (missing(h)) 
     stop("Point pairs need to be provided with their separating distance h.")
   if(length(h)>1 && length(h)!=nrow(u))
@@ -389,7 +413,31 @@
 setMethod("ddvCopula", signature("numeric","spCopula"), 
           function(u, copula, ...) ddvSpCopula(matrix(u,ncol=copula at dimension),copula, ...) )
 
+invddvSpCopula <- function(v, copula, y, h, tol=.Machine$double.eps^0.5) {
+  message("invddvCopula is numerically evalauted.")
+  
+  nElem <- length(v)
+  stopifnot(nElem == length(y))
+  stopifnot(length(h) == 1 | length(h)==nElem)
+  
+  optFun <- function(u, v, y, h) abs(ddvSpCopula(cbind(u, rep(v, length(u))), copula, h)-y)
+  
+  optMe <- function(aV, aY, aH) optimise(function(u) optFun(u, v=aV, y=aY, h=aH), c(0,1))$minimum
+  
+  if(length(h) == 1 & nElem > 1)
+    h <- rep(h, nElem)
+  
+  rU <- numeric(nElem)
+  for (i in 1:nElem) {
+    rU[i] <- optMe(v[i], y[i], h[i])
+  }
+  
+  return(rU)
+}
 
+setMethod("invddvCopula", signature("numeric", "spCopula"), invddvSpCopula)
+
+
 #############
 ##         ##
 ## FITTING ##

Modified: pkg/man/dependencePlot.Rd
===================================================================
--- pkg/man/dependencePlot.Rd	2014-03-17 13:57:05 UTC (rev 129)
+++ pkg/man/dependencePlot.Rd	2014-03-18 09:32:19 UTC (rev 130)
@@ -7,7 +7,7 @@
 Plots a kernel smoothed scatter plot of the provided rank-transformed sample. The work is done by the function \code{\link{panel.smoothScatter}}.
 }
 \usage{
-dependencePlot(var = NULL, smpl, bandwidth = 0.075,  main="Stength of dependece",
+dependencePlot(var = NULL, smpl, bandwidth = 0.075,  main="Stength of dependence",
                transformation = function(x) x, ...)
 }
 %- maybe also 'usage' for other objects documented here.

Modified: pkg/man/invdduCopula-methods.Rd
===================================================================
--- pkg/man/invdduCopula-methods.Rd	2014-03-17 13:57:05 UTC (rev 129)
+++ pkg/man/invdduCopula-methods.Rd	2014-03-18 09:32:19 UTC (rev 130)
@@ -6,6 +6,8 @@
 \alias{invdduCopula,numeric,frankCopula,numeric-method}
 \alias{invdduCopula,numeric,indepCopula,numeric-method}
 \alias{invdduCopula,numeric,normalCopula,numeric-method}
+\alias{invdduCopula,numeric,spCopula,ANY-method}
+
 \title{Methods for Function \code{invdduCopula} in Package \pkg{spcopula}}
 \description{
 Methods for function \code{invdduCopula} in package \pkg{spcopula}

Modified: pkg/man/invddvCopula-methods.Rd
===================================================================
--- pkg/man/invddvCopula-methods.Rd	2014-03-17 13:57:05 UTC (rev 129)
+++ pkg/man/invddvCopula-methods.Rd	2014-03-18 09:32:19 UTC (rev 130)
@@ -6,6 +6,8 @@
 \alias{invddvCopula,numeric,frankCopula,numeric-method}
 \alias{invddvCopula,numeric,indepCopula,numeric-method}
 \alias{invddvCopula,numeric,normalCopula,numeric-method}
+\alias{invddvCopula,numeric,spCopula,ANY-method}
+
 \title{Methods for Function \code{invddvCopula} in Package \pkg{spcopula}}
 \description{
 Methods for function \code{invddvCopula} in package \pkg{spcopula}



More information about the spcopula-commits mailing list