[Distr-commits] r81 - in pkg: distrEx/R distrEx/man distrMod distrMod/inst distrMod/inst/scripts distrMod/man

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Wed Feb 20 13:31:25 CET 2008


Author: ruckdeschel
Date: 2008-02-20 13:31:25 +0100 (Wed, 20 Feb 2008)
New Revision: 81

Added:
   pkg/distrEx/R/CvMDist.R
   pkg/distrEx/man/CvMDist.Rd
   pkg/distrMod/inst/
   pkg/distrMod/inst/scripts/
   pkg/distrMod/inst/scripts/example_CvMMDE.R
Removed:
   pkg/distrEx/R/vonMisesDist.R
   pkg/distrEx/man/vonMisesDist.Rd
Modified:
   pkg/distrEx/R/AllGeneric.R
   pkg/distrMod/man/MDEstimator.Rd
Log:
renamed vonMises to CvM (Cramer von Mises) and added extra examples for MDE into /inst/scripts in distrMod

Modified: pkg/distrEx/R/AllGeneric.R
===================================================================
--- pkg/distrEx/R/AllGeneric.R	2008-02-20 05:04:29 UTC (rev 80)
+++ pkg/distrEx/R/AllGeneric.R	2008-02-20 12:31:25 UTC (rev 81)
@@ -127,9 +127,9 @@
    setGeneric("HellingerDist", 
                function(e1, e2, ...) standardGeneric("HellingerDist"))
 }
-if(!isGeneric("vonMisesDist")){
-   setGeneric("vonMisesDist", 
-               function(e1, e2, ...) standardGeneric("vonMisesDist"))
+if(!isGeneric("CvMDist")){
+   setGeneric("CvMDist", 
+               function(e1, e2, ...) standardGeneric("CvMDist"))
 }
 
 if(!isGeneric("ConvexContamination")){ 

Copied: pkg/distrEx/R/CvMDist.R (from rev 80, pkg/distrEx/R/vonMisesDist.R)
===================================================================
--- pkg/distrEx/R/CvMDist.R	                        (rev 0)
+++ pkg/distrEx/R/CvMDist.R	2008-02-20 12:31:25 UTC (rev 81)
@@ -0,0 +1,25 @@
+###############################################################################
+## Method: CvMDist
+## Cramer - von Mises distance of two distributions
+###############################################################################
+setMethod("CvMDist", signature(e1 = "UnivariateDistribution",
+                                    e2 = "UnivariateDistribution"),
+    function(e1, e2, mu = e2, useApply = FALSE, ... ){
+        owarn <- getOption("warn"); options(warn = -1)
+        res <- E(mu, fun = function(t) {(p(e1)(t)-p(e2)(t))^2}, useApply = useApply, ...)^.5
+        names(res) <- "CvM distance"
+        options(warn = owarn)
+        return(res)
+    })
+
+## CvM distance
+setMethod("CvMDist", signature(e1 = "numeric",
+                                    e2 = "UnivariateDistribution"),
+    function(e1, e2, mu = e2, ...)
+        {owarn <- getOption("warn"); options(warn = -1)
+          e10 <- DiscreteDistribution(e1)       
+          options(warn = owarn)
+          CvMDist(e1 = e10, e2 = e2, mu = mu, ...)
+         }
+    )
+

Deleted: pkg/distrEx/R/vonMisesDist.R
===================================================================
--- pkg/distrEx/R/vonMisesDist.R	2008-02-20 05:04:29 UTC (rev 80)
+++ pkg/distrEx/R/vonMisesDist.R	2008-02-20 12:31:25 UTC (rev 81)
@@ -1,25 +0,0 @@
-###############################################################################
-## Method: vonMisesDist
-## von Mises distance of two distributions
-###############################################################################
-setMethod("vonMisesDist", signature(e1 = "UnivariateDistribution",
-                                    e2 = "UnivariateDistribution"),
-    function(e1, e2, mu = e2, useApply = FALSE, ... ){
-        owarn <- getOption("warn"); options(warn = -1)
-        res <- E(mu, fun = function(t) {(p(e1)(t)-p(e2)(t))^2}, useApply = useApply, ...)^.5
-        names(res) <- "vonMises distance"
-        options(warn = owarn)
-        return(res)
-    })
-
-## vonMises distance
-setMethod("vonMisesDist", signature(e1 = "numeric",
-                                    e2 = "UnivariateDistribution"),
-    function(e1, e2, mu = e2, ...)
-        {owarn <- getOption("warn"); options(warn = -1)
-          e10 <- DiscreteDistribution(e1)       
-          options(warn = owarn)
-          vonMisesDist(e1 = e10, e2 = e2, mu = mu, ...)
-         }
-    )
-

Copied: pkg/distrEx/man/CvMDist.Rd (from rev 80, pkg/distrEx/man/vonMisesDist.Rd)
===================================================================
--- pkg/distrEx/man/CvMDist.Rd	                        (rev 0)
+++ pkg/distrEx/man/CvMDist.Rd	2008-02-20 12:31:25 UTC (rev 81)
@@ -0,0 +1,63 @@
+\name{CvMDist}
+\alias{CvMDist}
+\alias{CvMDist-methods}
+\alias{CvMDist,UnivariateDistribution,UnivariateDistribution-method}
+\alias{CvMDist,numeric,UnivariateDistribution-method}
+
+\title{Generic function for the computation of the Cramer - von Mises  distance of two distributions}
+\description{
+  Generic function for the computation of the Cramer - von Mises  distance \eqn{d_\mu}{d_{mu}}
+  of two distributions \eqn{P} and \eqn{Q} where the distributions are defined 
+  on a finite-dimensional Euclidean space \eqn{(\R^m,{\cal B}^m)}{(R^m, B^m)}
+  with \eqn{ {\cal B}^m }{B^m} the Borel-\eqn{\sigma}{sigma}-algebra on \eqn{R^m}.
+  The Cramer - von Mises  distance is defined as
+  \deqn{d_\mu(P,Q)^2=\int\,(P(\{y\in\R^m\,|\,y\le x\})-Q(\{y\in\R^m\,|\,y\le x\}))^2\,\mu(dx)}{
+  d_{mu}(P,Q)^2=\int (P(\{y in R^m | y <= x\})-Q(\{y in R^m | y <= x\}))^2 mu(dx)}
+  where \eqn{\le}{<=} is coordinatewise on \eqn{\R^m}{R^m}.
+}
+\usage{
+CvMDist(e1, e2, ...)
+\S4method{CvMDist}{UnivariateDistribution,UnivariateDistribution}(e1, e2, mu = e2, useApply = FALSE, ...)
+\S4method{CvMDist}{numeric,UnivariateDistribution}(e1, e2, mu = e2, ...)
+}
+\arguments{
+  \item{e1}{ object of class \code{"Distribution"} or class \code{"numeric"} }
+  \item{e2}{ object of class \code{"Distribution"} }
+  \item{\dots}{ further arguments to be used e.g. by \code{E()}}
+  \item{useApply}{ logical; to be passed to \code{\link{E}()}}
+  \item{mu}{ object of class \code{"Distribution"}; integration measure; defaulting to \code{e2} }
+}
+%\details{}
+\value{ Cramer - von Mises  distance of \code{e1} and \code{e2} }
+\section{Methods}{
+\describe{
+  \item{e1 = "UnivariateDistribution", e2 = "UnivariateDistribution":}{
+    Cramer - von Mises  distance of two univariate distributions.
+  }
+  \item{e1 = "numeric", e2 = "UnivariateDistribution":}{
+    Cramer - von Mises  distance between the empirical formed from a data set (e1) and a 
+    univariate distribution. 
+  }
+}}
+\references{
+    Rieder, H. (1994) \emph{Robust Asymptotic Statistics}. New York: Springer.
+}
+\author{Matthias Kohl \email{Matthias.Kohl at stamats.de},\cr
+        Peter Ruckdeschel \email{Peter.Ruckdeschel at uni-bayreuth.de}}
+%\note{ ~~further notes~~ }
+\seealso{\code{\link{ContaminationSize}}, \code{\link{TotalVarDist}}, 
+    \code{\link{HellingerDist}}, \code{\link{KolmogorovDist}},
+    \code{\link[distr]{Distribution-class}}}
+\examples{
+CvMDist(Norm(), Gumbel())
+CvMDist(Norm(), Gumbel(), mu = Norm())
+CvMDist(Norm(), Td(10))
+CvMDist(Norm(mean = 50, sd = sqrt(25)), Binom(size = 100))
+CvMDist(Pois(10), Binom(size = 20)) 
+CvMDist(rnorm(100),Norm())
+CvMDist((rbinom(50, size = 20, prob = 0.5)-10)/sqrt(5), Norm())
+CvMDist(rbinom(50, size = 20, prob = 0.5), Binom(size = 20, prob = 0.5))
+CvMDist(rbinom(50, size = 20, prob = 0.5), Binom(size = 20, prob = 0.5), mu = Pois())
+}
+\concept{distance}
+\keyword{distribution}

Deleted: pkg/distrEx/man/vonMisesDist.Rd
===================================================================
--- pkg/distrEx/man/vonMisesDist.Rd	2008-02-20 05:04:29 UTC (rev 80)
+++ pkg/distrEx/man/vonMisesDist.Rd	2008-02-20 12:31:25 UTC (rev 81)
@@ -1,63 +0,0 @@
-\name{vonMisesDist}
-\alias{vonMisesDist}
-\alias{vonMisesDist-methods}
-\alias{vonMisesDist,UnivariateDistribution,UnivariateDistribution-method}
-\alias{vonMisesDist,numeric,UnivariateDistribution-method}
-
-\title{Generic function for the computation of the von Mises distance of two distributions}
-\description{
-  Generic function for the computation of the von Mises distance \eqn{d_\mu}{d_{mu}}
-  of two distributions \eqn{P} and \eqn{Q} where the distributions are defined 
-  on a finite-dimensional Euclidean space \eqn{(\R^m,{\cal B}^m)}{(R^m, B^m)}
-  with \eqn{ {\cal B}^m }{B^m} the Borel-\eqn{\sigma}{sigma}-algebra on \eqn{R^m}.
-  The von Mises distance is defined as
-  \deqn{d_\mu(P,Q)^2=\int\,(P(\{y\in\R^m\,|\,y\le x\})-Q(\{y\in\R^m\,|\,y\le x\}))^2\,\mu(dx)}{
-  d_{mu}(P,Q)^2=\int (P(\{y in R^m | y <= x\})-Q(\{y in R^m | y <= x\}))^2 mu(dx)}
-  where \eqn{\le}{<=} is coordinatewise on \eqn{\R^m}{R^m}.
-}
-\usage{
-vonMisesDist(e1, e2, ...)
-\S4method{vonMisesDist}{UnivariateDistribution,UnivariateDistribution}(e1, e2, mu = e2, useApply = FALSE, ...)
-\S4method{vonMisesDist}{numeric,UnivariateDistribution}(e1, e2, mu = e2, ...)
-}
-\arguments{
-  \item{e1}{ object of class \code{"Distribution"} or class \code{"numeric"} }
-  \item{e2}{ object of class \code{"Distribution"} }
-  \item{\dots}{ further arguments to be used e.g. by \code{E()}}
-  \item{useApply}{ logical; to be passed to \code{\link{E}()}}
-  \item{mu}{ object of class \code{"Distribution"}; integration measure; defaulting to \code{e2} }
-}
-%\details{}
-\value{ von Mises distance of \code{e1} and \code{e2} }
-\section{Methods}{
-\describe{
-  \item{e1 = "UnivariateDistribution", e2 = "UnivariateDistribution":}{
-    von Mises distance of two univariate distributions.
-  }
-  \item{e1 = "numeric", e2 = "UnivariateDistribution":}{
-    von Mises distance between the empirical formed from a data set (e1) and a 
-    univariate distribution. 
-  }
-}}
-\references{
-    Rieder, H. (1994) \emph{Robust Asymptotic Statistics}. New York: Springer.
-}
-\author{Matthias Kohl \email{Matthias.Kohl at stamats.de},\cr
-        Peter Ruckdeschel \email{Peter.Ruckdeschel at uni-bayreuth.de}}
-%\note{ ~~further notes~~ }
-\seealso{\code{\link{ContaminationSize}}, \code{\link{TotalVarDist}}, 
-    \code{\link{HellingerDist}}, \code{\link{KolmogorovDist}},
-    \code{\link[distr]{Distribution-class}}}
-\examples{
-vonMisesDist(Norm(), Gumbel())
-vonMisesDist(Norm(), Gumbel(), mu = Norm())
-vonMisesDist(Norm(), Td(10))
-vonMisesDist(Norm(mean = 50, sd = sqrt(25)), Binom(size = 100))
-vonMisesDist(Pois(10), Binom(size = 20)) 
-vonMisesDist(rnorm(100),Norm())
-vonMisesDist((rbinom(50, size = 20, prob = 0.5)-10)/sqrt(5), Norm())
-vonMisesDist(rbinom(50, size = 20, prob = 0.5), Binom(size = 20, prob = 0.5))
-vonMisesDist(rbinom(50, size = 20, prob = 0.5), Binom(size = 20, prob = 0.5), mu = Pois())
-}
-\concept{distance}
-\keyword{distribution}

Added: pkg/distrMod/inst/scripts/example_CvMMDE.R
===================================================================
--- pkg/distrMod/inst/scripts/example_CvMMDE.R	                        (rev 0)
+++ pkg/distrMod/inst/scripts/example_CvMMDE.R	2008-02-20 12:31:25 UTC (rev 81)
@@ -0,0 +1,10 @@
+require(distrMod)
+x=rnorm(30)
+NF=NormLocationScaleFamily()
+system.time(print(MDEstimator(x,NF,CvMDist)))
+system.time(print(MDEstimator(x,NF,CvMDist,useApply=TRUE)))
+MDEstimator(rnorm(30),NF,CvMDist)
+MDEstimator(rnorm(30),NF,CvMDist)
+MDEstimator(rnorm(300),NF,CvMDist)
+MDEstimator(rnorm(300,mean=2,sd=2),NF,CvMDist)
+MDEstimator(rnorm(300,mean=2,sd=2),NF,CvMDist)

Modified: pkg/distrMod/man/MDEstimator.Rd
===================================================================
--- pkg/distrMod/man/MDEstimator.Rd	2008-02-20 05:04:29 UTC (rev 80)
+++ pkg/distrMod/man/MDEstimator.Rd	2008-02-20 12:31:25 UTC (rev 81)
@@ -65,10 +65,10 @@
 MDEstimator(x = x, ParamFamily = G, distance = KolmogorovDist)
 
 ## von Mises minimum distance estimator with default mu
-MDEstimator(x = x, ParamFamily = G, distance = vonMisesDist)
+MDEstimator(x = x, ParamFamily = G, distance = CvMDist)
 
 ## von Mises minimum distance estimator with mu = N(0,1)
-MDEstimator(x = x, ParamFamily = G, distance = vonMisesDist, mu = Norm())
+MDEstimator(x = x, ParamFamily = G, distance = CvMDist, mu = Norm())
 
 ## Total variation minimum distance estimator
 ## gamma distributions are discretized



More information about the Distr-commits mailing list