[Distr-commits] r1269 - in branches/distr-2.8/pkg/distrMod: R inst

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Sat Aug 11 00:11:43 CEST 2018


Author: ruckdeschel
Date: 2018-08-11 00:11:43 +0200 (Sat, 11 Aug 2018)
New Revision: 1269

Modified:
   branches/distr-2.8/pkg/distrMod/R/SimpleL2ParamFamilies.R
   branches/distr-2.8/pkg/distrMod/inst/NEWS
Log:
[distrMod] branch 2.8:
+ in fam.fall to NbinomFamily (with two parameters ) we had matrix(Tr, dimnames = DN) without
  specifying nrow and ncol 
+ (robust) start parameters for Nbinom family with two parameters


Modified: branches/distr-2.8/pkg/distrMod/R/SimpleL2ParamFamilies.R
===================================================================
--- branches/distr-2.8/pkg/distrMod/R/SimpleL2ParamFamilies.R	2018-08-10 17:47:04 UTC (rev 1268)
+++ branches/distr-2.8/pkg/distrMod/R/SimpleL2ParamFamilies.R	2018-08-10 22:11:43 UTC (rev 1269)
@@ -202,7 +202,11 @@
     body(modifyParam) <- substitute({ Nbinom(size = theta[1], prob = theta[2]) })
     props <- ""
     
-    startPar <- function(x,...){ param1 <- c(1,0.5)
+    startPar <- function(x,...){ m0 <- median(x)
+                                 s0 <- mad(x)
+                                 p0 <- min(0.99,max(m0/s0^2,0.01))
+                                 n0 <- m0^2/max(s0^2-m0,0.1)
+                                 param1 <- c(n0,p0)
                                  names(param1) <- c("size","prob")
                                  return(param1)}
     makeOKPar <- function(param) {if(param["prob"]<=0) param["prob"] <- .Machine$double.eps
@@ -259,7 +263,7 @@
         .returnClsName = "NbinomwithSizeFamily")
     if(!is.function(trafo))
        f.call <- substitute(NbinomwithSizeFamily(size = s, prob = p,
-  	                     trafo = matrix(Tr, dimnames = DN)),
+  	                     trafo = matrix(Tr, 2,2, dimnames = DN)),
   	                     list(s = size, p = prob, Tr = trafo,
                          DN = list(nms,nms)))    
     else
@@ -290,7 +294,10 @@
     body(modifyParam) <- substitute({ Nbinom(size = theta[1], prob = theta[1]/(theta[1]+theta[2])) })
     props <- ""
     
-    startPar <- function(x,...){ param1 <- c(1,0.5)
+    startPar <- function(x,...){ m0 <- median(x)
+                                 s0 <- mad(x)
+                                 n0 <- m0^2/max(s0^2-m0,0.1)
+                                 param1 <- c(n0,m0)
                                  names(param1) <- c("size","mean")
                                  return(param1)}
     makeOKPar <- function(param) {if(param["mean"]<=0) param["mean"] <- .Machine$double.eps
@@ -363,7 +370,7 @@
         .returnClsName = "NbinomMeanSizeFamily")
     if(!is.function(trafo)){
        f.call <- substitute(NbinomMeanSizeFamily(size = s, mean = m,
-  	                     trafo = matrix(Tr, dimnames = DN)),
+  	                     trafo = matrix(Tr, 2,2, dimnames = DN)),
   	                     list(s = size, m = mean, Tr = trafo, DN = list(nms,nms)))    
     }else{
        f.call <- substitute(NbinomMeanSizeFamily(size = s, mean = m,

Modified: branches/distr-2.8/pkg/distrMod/inst/NEWS
===================================================================
--- branches/distr-2.8/pkg/distrMod/inst/NEWS	2018-08-10 17:47:04 UTC (rev 1268)
+++ branches/distr-2.8/pkg/distrMod/inst/NEWS	2018-08-10 22:11:43 UTC (rev 1269)
@@ -52,6 +52,8 @@
 + argument distance did not show it came from CvMDist, CvMDist2 via CvMMDEstiamtor when unparsed -- 
   now the unparsed argument in CvMMDEstimator is called CvMDist0 so shows that it is related to 
   CvMDist 
++ in fam.fall to NbinomFamily (with two parameters ) we had matrix(Tr, dimnames = DN) without
+  specifying nrow and ncol 
   
 under the hood:
 
@@ -65,16 +67,19 @@
    + in case <paramname>.0 is already used otherwise (as in NbinomMeanSizeFamily) we use <paramname>.00 instead
 + replaced integration for AbscontDistribution(s) in .CvMMDCovariance by integration on quantile scale
    => CvMMDEstimator now works with variances even for Gamma distributions for shape < 1 ...   
++ tuned .CvMMDCovariance() in asCvMVarianceQtl.R for speed (like with kStepEstimator timings are 
+   taken in comment ##-t-##) as the function .CvMMDCovariance was much slower than 
+   .oldCvMMDCovariance for Generalized EVD with Mu Unknown... / now they are at equal there 
++ revised .CvMMDCovariance() to get more performant for discrete distributions / 
+   -> thereby corrected an error in the intermediate formulae, which by
+  centering/standarizing of the IC in the end already cancelled out beforehand...
+  but now we are more accurate as to differences in the integration measure mu 
+  and the model distribution (important for integration w.r.t. emp. measure)
 + .process.meCalcRes gains arg "x" to be able to pass on emp.CDF for mu in CvMMDEstimator
    if arg asvar.fct of MCEstimator has "x" in formals the observations x are passed on to asvar.fct, 
    otherwise they are not; correspondingly "x" is passed on to .process.meCalcRes in
    MCEstimator(), MDEstimator(), MLEstimator(). 
 + old .CvMMDCovariance() becomes .oldCvMMDCovariance
-+ revised .CvMMDCovariance() to get more performant for discrete distributions / 
-   -> thereby corrected an error in the intermediate formulae, which by
-  centering/standarizing of the IC in the end already cancelled out beforehand...
-  but now we are more accurate as to differences in the integration measure mu 
-  and the model distribution (important for integration w.r.t. emp. measure)
 + new wrapper .CvMMDCovarianceWithMux which uses emp cdf as mu
 + new wrappe CvMDist2 which by default uses model distribution as mu
 + CvMMDEstimator gains argument muDatOrMod = c("Dat","Mod") to distinguish two cases
@@ -96,7 +101,9 @@
 + based on this tag "( mu = ... )" later on, in pkg RobAStBase, a (conditional) 
   coerce method produces the pIC of the MDE by means of .CvMMDCovariance[WithMux]
 + new subclasses "MLEstimate", "MDEstimate", "CvMMDEstimate" for internal method dispatch  
++ (robust) start parameters for Nbinom family with two parameters
 
+
 ##############
 v 2.7
 ##############



More information about the Distr-commits mailing list