[Distr-commits] r1235 - in branches/distr-2.8/pkg/distrMod: . R inst man
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Tue Jul 31 12:16:16 CEST 2018
Author: ruckdeschel
Date: 2018-07-31 12:16:16 +0200 (Tue, 31 Jul 2018)
New Revision: 1235
Modified:
branches/distr-2.8/pkg/distrMod/NAMESPACE
branches/distr-2.8/pkg/distrMod/R/MDEstimator.R
branches/distr-2.8/pkg/distrMod/R/mleCalc-methods.R
branches/distr-2.8/pkg/distrMod/inst/NEWS
branches/distr-2.8/pkg/distrMod/man/MDEstimator.Rd
Log:
[distrMod] branch 2.8
ported svnrev 1233 to branch 2.8, i.e. CvMMDEstimator, KolmogorovMDEstimator, TotalVarMDEstimator, HellingerMDEstimator
and enhanced example in mleCalc-methods.R
Modified: branches/distr-2.8/pkg/distrMod/NAMESPACE
===================================================================
--- branches/distr-2.8/pkg/distrMod/NAMESPACE 2018-07-31 07:03:05 UTC (rev 1234)
+++ branches/distr-2.8/pkg/distrMod/NAMESPACE 2018-07-31 10:16:16 UTC (rev 1235)
@@ -73,7 +73,9 @@
export("distrModMASK")
export("trafoEst")
export("distrModOptions", "distrModoptions", "getdistrModOption",
- "Estimator", "MCEstimator", "MLEstimator", "MDEstimator")
+ "Estimator", "MCEstimator", "MLEstimator", "MDEstimator",
+ "CvMMDEstimator", "KolmogorovMDEstimator", "TotalVarMDEstimator",
+ "HellingerMDEstimator"))
export("NonSymmetric", "EvenSymmetric", "OddSymmetric", "FunSymmList")
export("ParamFamParameter", "ParamFamily", "L2ParamFamily",
"BinomFamily", "PoisFamily", "NbinomFamily", "NormLocationFamily",
Modified: branches/distr-2.8/pkg/distrMod/R/MDEstimator.R
===================================================================
--- branches/distr-2.8/pkg/distrMod/R/MDEstimator.R 2018-07-31 07:03:05 UTC (rev 1234)
+++ branches/distr-2.8/pkg/distrMod/R/MDEstimator.R 2018-07-31 10:16:16 UTC (rev 1235)
@@ -60,3 +60,51 @@
return(.checkEstClassForParamFamily(ParamFamily,res))
}
+CvMMDEstimator <- function(x, ParamFamily, paramDepDist = FALSE,
+ startPar = NULL, Infos,
+ trafo = NULL, penalty = 1e20,
+ validity.check = TRUE, asvar.fct = .CvMMDCovariance,
+ na.rm = TRUE, ..., .withEvalAsVar = TRUE){
+ MDEstimator(x = x, ParamFamily = ParamFamily, distance = CvMDist,
+ paramDepDist = paramDepDist, startPar = startPar, Infos = Infos,
+ trafo = trafo, penalty = penalty, validity.check = validity.check,
+ asvar.fct = asvar.fct, na.rm = na.rm,
+ ..., .withEvalAsVar = .withEvalAsVar)
+}
+
+KolmogorovMDEstimator <- function(x, ParamFamily, paramDepDist = FALSE,
+ startPar = NULL, Infos,
+ trafo = NULL, penalty = 1e20,
+ validity.check = TRUE, asvar.fct, na.rm = TRUE, ...,
+ .withEvalAsVar = TRUE){
+ MDEstimator(x = x, ParamFamily = ParamFamily, distance = KolmogorovDist,
+ paramDepDist = paramDepDist, startPar = startPar, Infos = Infos,
+ trafo = trafo, penalty = penalty, validity.check = validity.check,
+ asvar.fct = asvar.fct, na.rm = na.rm,
+ ..., .withEvalAsVar = .withEvalAsVar)
+}
+
+TotalVarMDEstimator <- function(x, ParamFamily, paramDepDist = FALSE,
+ startPar = NULL, Infos,
+ trafo = NULL, penalty = 1e20,
+ validity.check = TRUE, asvar.fct, na.rm = TRUE, ...,
+ .withEvalAsVar = TRUE){
+ MDEstimator(x = x, ParamFamily = ParamFamily, distance = TotalVarDist,
+ paramDepDist = paramDepDist, startPar = startPar, Infos = Infos,
+ trafo = trafo, penalty = penalty, validity.check = validity.check,
+ asvar.fct = asvar.fct, na.rm = na.rm,
+ ..., .withEvalAsVar = .withEvalAsVar)
+}
+
+HellingerMDEstimator <- function(x, ParamFamily, paramDepDist = FALSE,
+ startPar = NULL, Infos,
+ trafo = NULL, penalty = 1e20,
+ validity.check = TRUE, asvar.fct, na.rm = TRUE, ...,
+ .withEvalAsVar = TRUE){
+ MDEstimator(x = x, ParamFamily = ParamFamily, distance = HellingerDist,
+ paramDepDist = paramDepDist, startPar = startPar, Infos = Infos,
+ trafo = trafo, penalty = penalty, validity.check = validity.check,
+ asvar.fct = asvar.fct, na.rm = na.rm,
+ ..., .withEvalAsVar = .withEvalAsVar)
+}
+
Modified: branches/distr-2.8/pkg/distrMod/R/mleCalc-methods.R
===================================================================
--- branches/distr-2.8/pkg/distrMod/R/mleCalc-methods.R 2018-07-31 07:03:05 UTC (rev 1234)
+++ branches/distr-2.8/pkg/distrMod/R/mleCalc-methods.R 2018-07-31 10:16:16 UTC (rev 1235)
@@ -291,7 +291,20 @@
optimReturn(re2)
MCEstimator(x = x, ParamFamily = nF, criterion = negLoglikelihood3)
MCEstimator(x = x, ParamFamily = nF, criterion = negLoglikelihood3, fn="LU")
+
+## this shows how to do validity checks every fourth evaluation
+count <- 0
+negLoglikelihood4 <- function(x, Distribution, check.validity){
+ count <<- count +1
+ if(count %% 4==0)print(c(chk=check.validity))
+ print(count)
+ res <- -sum(log(Distribution at d(x)))
+ names(res) <- "Negative Log-Likelihood"
+ return(res)
}
+MCEstimator(x = x, ParamFamily = nF, criterion = negLoglikelihood4)
+
+}
##########################################################################
# end added 2018 07 30
##########################################################################
Modified: branches/distr-2.8/pkg/distrMod/inst/NEWS
===================================================================
--- branches/distr-2.8/pkg/distrMod/inst/NEWS 2018-07-31 07:03:05 UTC (rev 1234)
+++ branches/distr-2.8/pkg/distrMod/inst/NEWS 2018-07-31 10:16:16 UTC (rev 1235)
@@ -17,13 +17,30 @@
information needed to produce the respective plot, which at a later stage could be used by different graphic engines (like, e.g.
\code{ggplot}) to produce the plot in a different framework. A more detailed description will follow in a subsequent version.
+ DESCRIPTION tag SVNRevision changed to VCS/SVNRevision
++ "cleverer parsing of dots" in M[L,C,D]Estimator:
+ Triggered by an error observed by Kornelius Rohmeyer, we now parse the dots (...) argument
+ of M[L,C,D]Estimator a little more closely and filter out obvious clashes: We filter out taboo arguments
+ (causing clashes with formals in optim/optimize and calling arguments); from the remaining ones only
+ [exactly] _named_ arguments of the optimizer (optim/optimize) and those matching either exactly arguments
+ of the criterion or all remaining ones (if ... is a formal of the criterion) are passed on:
+ This way, one can, if desired, do evaluation-wise validity checks in the criterion.
++ For diagnostic purposes, MCEstimate-class gains a slot optimReturn (of class "ANY" and filled by
+ NULL by default) which is filled by the return value of the optimizer in "mceCalc" -- it has a
+ corresponding accessor
+under the hood:
+
+As this is more for internal purposes, example code for the parsing of dots argument
+is in lines ll 256--294 in mleCalc-methods.R (wrapped in a if(FALSE){ }).
+
##############
v 2.7
##############
user-visible CHANGES:
+ replaced http://CRAN... by https://CRAN... (also in CITATION and similar files)
++ new wrapper to MDEstimator: CvMMDEstimator, KolmogorovMDEstimator, TotalVarMDEstimator,
+ HellingerMDEstimator
+ exported .CvMMDCovariance in distrMod
+ added call to return value of qqplot
+ qqplot and returnlevelplot have adopted the same argument naming (and selection paradigm)
Modified: branches/distr-2.8/pkg/distrMod/man/MDEstimator.Rd
===================================================================
--- branches/distr-2.8/pkg/distrMod/man/MDEstimator.Rd 2018-07-31 07:03:05 UTC (rev 1234)
+++ branches/distr-2.8/pkg/distrMod/man/MDEstimator.Rd 2018-07-31 10:16:16 UTC (rev 1235)
@@ -1,5 +1,9 @@
\name{MDEstimator}
\alias{MDEstimator}
+\alias{CvMMDEstimator}
+\alias{KolmogorovMDEstimator}
+\alias{TotalVarMDEstimator}
+\alias{HellingerMDEstimator}
\title{ Function to compute minimum distance estimates }
\description{
@@ -8,9 +12,21 @@
}
\usage{
MDEstimator(x, ParamFamily, distance = KolmogorovDist, dist.name,
- paramDepDist = FALSE, startPar = NULL, Infos, trafo = NULL,
+ paramDepDist = FALSE, startPar = NULL, Infos, trafo = NULL,
penalty = 1e20, validity.check = TRUE, asvar.fct, na.rm = TRUE,
..., .withEvalAsVar = TRUE)
+CvMMDEstimator(x, ParamFamily, paramDepDist = FALSE, startPar = NULL, Infos,
+ trafo = NULL, penalty = 1e20, validity.check = TRUE,
+ asvar.fct = .CvMMDCovariance, na.rm = TRUE, ..., .withEvalAsVar = TRUE)
+KolmogorovMDEstimator(x, ParamFamily, paramDepDist = FALSE, startPar = NULL, Infos,
+ trafo = NULL, penalty = 1e20, validity.check = TRUE, asvar.fct,
+ na.rm = TRUE, ..., .withEvalAsVar = TRUE)
+TotalVarMDEstimator(x, ParamFamily, paramDepDist = FALSE, startPar = NULL, Infos,
+ trafo = NULL, penalty = 1e20, validity.check = TRUE, asvar.fct,
+ na.rm = TRUE, ..., .withEvalAsVar = TRUE)
+HellingerMDEstimator(x, ParamFamily, paramDepDist = FALSE, startPar = NULL, Infos,
+ trafo = NULL, penalty = 1e20, validity.check = TRUE, asvar.fct,
+ na.rm = TRUE, ..., .withEvalAsVar = TRUE)
}
%- maybe also 'usage' for other objects documented here.
\arguments{
@@ -54,6 +70,9 @@
and possibly \code{\dots}; e.g. \code{KolmogorovDist} (default),
\code{TotalVarDist} or \code{HellingerDist}. Uses \code{\link{mceCalc}}
for method dispatch.
+
+ The functions \code{CvMMDEstimator}, \code{KolmogorovMDEstimator}, \code{TotalVarMDEstimator},
+ and \code{HellingerMDEstimator} are aliases where the distance is fixed.
}
\value{
An object of S4-class \code{"MCEstimate"} which inherits from class
@@ -84,16 +103,18 @@
## Kolmogorov(-Smirnov) minimum distance estimator
MDEstimator(x = x, ParamFamily = G, distance = KolmogorovDist)
+## or
+KolmogorovMDEstimator(x = x, ParamFamily = G)
## von Mises minimum distance estimator with default mu
MDEstimator(x = x, ParamFamily = G, distance = CvMDist)
-\donttest{
-## taken out of CRAN-tests because it takes some time...
-
+\dontrun{
## von Mises minimum distance estimator with default mu
MDEstimator(x = x, ParamFamily = G, distance = CvMDist,
asvar.fct = .CvMMDCovariance)
+## or
+CvMMDEstimator(x = x, ParamFamily = G)
## von Mises minimum distance estimator with mu = N(0,1)
MDEstimator(x = x, ParamFamily = G, distance = CvMDist, mu = Norm())
@@ -101,13 +122,17 @@
## Total variation minimum distance estimator
## gamma distributions are discretized
MDEstimator(x = x, ParamFamily = G, distance = TotalVarDist)
+## or
+TotalVarMDEstimator(x = x, ParamFamily = G)
## or smoothing of emprical distribution (takes some time!)
-MDEstimator(x = x, ParamFamily = G, distance = TotalVarDist, asis.smooth.discretize = "smooth")
+#MDEstimator(x = x, ParamFamily = G, distance = TotalVarDist, asis.smooth.discretize = "smooth")
## Hellinger minimum distance estimator
## gamma distributions are discretized
distroptions(DistrResolution = 1e-10)
MDEstimator(x = x, ParamFamily = G, distance = HellingerDist, startPar = c(1,2))
+## or
+HellingerMDEstimator(x = x, ParamFamily = G, startPar = c(1,2))
distroptions(DistrResolution = 1e-6) # default
## or smoothing of emprical distribution (takes some time!)
MDEstimator(x = x, ParamFamily = G, distance = HellingerDist, asis.smooth.discretize = "smooth")
More information about the Distr-commits
mailing list