[Distr-commits] r185 - in branches/distr-2.0/pkg/distrMod: R man

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Mon Jul 21 06:43:16 CEST 2008


Author: stamats
Date: 2008-07-21 06:43:16 +0200 (Mon, 21 Jul 2008)
New Revision: 185

Modified:
   branches/distr-2.0/pkg/distrMod/R/L2GroupFamilies.R
   branches/distr-2.0/pkg/distrMod/R/MLEstimator.R
   branches/distr-2.0/pkg/distrMod/R/SimpleL2ParamFamilies.R
   branches/distr-2.0/pkg/distrMod/man/MCEstimator.Rd
   branches/distr-2.0/pkg/distrMod/man/MDEstimator.Rd
   branches/distr-2.0/pkg/distrMod/man/MLEstimator.Rd
Log:
explicitly introduce names for the parameters which are then printed

Modified: branches/distr-2.0/pkg/distrMod/R/L2GroupFamilies.R
===================================================================
--- branches/distr-2.0/pkg/distrMod/R/L2GroupFamilies.R	2008-07-18 10:17:04 UTC (rev 184)
+++ branches/distr-2.0/pkg/distrMod/R/L2GroupFamilies.R	2008-07-21 04:43:16 UTC (rev 185)
@@ -20,9 +20,11 @@
             if(length(distrSymm at SymmCenter) != 1)
                 stop("slot 'SymmCenter' of 'distrSymm' has wrong dimension")
                     }
-         }      
- 
-    param <- ParamFamParameter(name = "location", main = loc, trafo = trafo)
+         }
+
+    param0 <- loc
+    names(param0) <- "loc"
+    param <- ParamFamParameter(name = "location", main = param0, trafo = trafo)
     modifyParam <- function(theta){}
     body(modifyParam) <- substitute({ scale*centraldistribution+theta },
                                       list(scale = scale))
@@ -103,7 +105,10 @@
             if(length(distrSymm at SymmCenter) != 1)
                 stop("slot 'SymmCenter' of 'distrSymm' has wrong dimension")
                     }
-         }      
+         }
+
+    param0 <- scale
+    names(param0) <- "scale"
     param <- ParamFamParameter(name = "scale", main = scale, trafo = trafo)
     modifyParam <- function(theta){}
     body(modifyParam) <- substitute({ theta*centraldistribution+loc },
@@ -187,8 +192,11 @@
             if(length(distrSymm at SymmCenter) != 1)
                 stop("slot 'SymmCenter' of 'distrSymm' has wrong dimension")
                     }
-         }      
-    param <- ParamFamParameter(name = "location and scale", main = c(loc, scale),
+         }
+
+    param0 <- c(loc, scale)
+    names(param0) <- c("loc", "scale")
+    param <- ParamFamParameter(name = "location and scale", main = param0,
                                trafo = trafo)
     modifyParam <- function(theta){theta[2]*centraldistribution+theta[1] }
     props <- c(paste("The", name, "is invariant under"),

Modified: branches/distr-2.0/pkg/distrMod/R/MLEstimator.R
===================================================================
--- branches/distr-2.0/pkg/distrMod/R/MLEstimator.R	2008-07-18 10:17:04 UTC (rev 184)
+++ branches/distr-2.0/pkg/distrMod/R/MLEstimator.R	2008-07-21 04:43:16 UTC (rev 185)
@@ -31,7 +31,7 @@
     res <- MCEstimator(x = x, ParamFamily = ParamFamily, criterion = negLoglikelihood,
                 interval = interval, par = par, ...)
     names(res$criterion) <- "negative log-likelihood"
-    class(res) <- c("MLEstimator", "MCEstimator", "Estimate")
+    class(res) <- c("MCEstimator", "Estimate")
 
     return(res)
 }

Modified: branches/distr-2.0/pkg/distrMod/R/SimpleL2ParamFamilies.R
===================================================================
--- branches/distr-2.0/pkg/distrMod/R/SimpleL2ParamFamilies.R	2008-07-18 10:17:04 UTC (rev 184)
+++ branches/distr-2.0/pkg/distrMod/R/SimpleL2ParamFamilies.R	2008-07-21 04:43:16 UTC (rev 185)
@@ -8,8 +8,10 @@
         distrSymm <- SphericalSymmetry(SymmCenter = size*prob)
     else
         distrSymm <- NoSymmetry()
+    param0 <- prob
+    names(param0) <- "prob"
     param <- ParamFamParameter(name = "probability of success",  
-                            main = prob, trafo = trafo)
+                               main = param0, trafo = trafo)
     modifyParam <- function(theta){ Binom(size = size, prob = theta) }
     body(modifyParam) <- substitute({ Binom(size = size, prob = theta) }, list(size = size))
     props <- c("The Binomial family is symmetric with respect to prob = 0.5;", 
@@ -45,8 +47,10 @@
     name <- "Poisson family"
     distribution <- Pois(lambda = lambda)
     distrSymm <- NoSymmetry()
+    param0 <- lambda
+    names(param0) <- "lambda"
     param <- ParamFamParameter(name = "positive mean",
-                            main = lambda, trafo = trafo)
+                               main = param0, trafo = trafo)
     modifyParam <- function(theta){ Pois(lambda = theta) }
     props <- character(0)
     L2deriv.fct <- function(param){
@@ -76,8 +80,10 @@
     name <- "Gamma family"
     distribution <- Gammad(scale = scale, shape = shape)
     distrSymm <- NoSymmetry()
+    param0 <- c(scale, shape)
+    names(param0) <- c("scale", "shape")
     param <- ParamFamParameter(name = "scale and shape",  
-                        main = c(scale, shape), trafo = trafo)
+                        main = param0, trafo = trafo)
     modifyParam <- function(theta){ Gammad(scale = theta[1], shape = theta[2]) }
     props <- c("The Gamma family is scale invariant via the parametrization",
                "'(nu,shape)=(log(scale),shape)'")
@@ -117,7 +123,9 @@
     name <- "normal location family"
     distribution <- Norm(mean = mean, sd = sd)
     distrSymm <- SphericalSymmetry(SymmCenter = mean)
-    param <- ParamFamParameter(name = "location", main = mean, trafo = trafo)
+    param0 <- mean
+    names(param0) <- "mean"
+    param <- ParamFamParameter(name = "location", main = param0, trafo = trafo)
     modifyParam <- function(theta){ Norm(mean = theta, sd = sd) }
     body(modifyParam) <- substitute({ Norm(mean = theta, sd = sd) }, list(sd = sd))
     props <- c("The normal location family is invariant under",
@@ -148,7 +156,9 @@
     name <- "Gumbel location family"
     distribution <- Gumbel(loc = loc, scale = scale)
     distrSymm <- NoSymmetry()
-    param <- ParamFamParameter(name = "location", main = loc, trafo = trafo)
+    param0 <- loc
+    names(param0) <- "loc"
+    param <- ParamFamParameter(name = "location", main = param0, trafo = trafo)
     modifyParam <- function(theta){ Gumbel(loc = theta, scale = scale) }
     body(modifyParam) <- substitute({ Gumbel(loc = theta, scale = scale) }, list(scale = scale))
     props <- c("The Gumbel location family is invariant under",
@@ -179,7 +189,9 @@
     name <- "normal scale family"
     distribution <- Norm(mean = mean, sd = sd)
     distrSymm <- SphericalSymmetry(SymmCenter = mean)
-    param <- ParamFamParameter(name = "scale", main = sd, trafo = trafo)
+    param0 <- sd
+    names(param0) <- "sd"
+    param <- ParamFamParameter(name = "scale", main = param0, trafo = trafo)
     modifyParam <- function(theta){ Norm(mean = mean, sd = theta) }
     body(modifyParam) <- substitute({ Norm(mean = mean, sd = theta) }, list(mean = mean))
     props <- c("The normal scale family is invariant under",
@@ -212,7 +224,9 @@
     name <- "Exponential scale family"
     distribution <- Exp(rate = rate)
     distrSymm <- NoSymmetry()
-    param <- ParamFamParameter(name = "scale", main = 1/rate, trafo = trafo)
+    param0 <- 1/rate
+    names(param0) <- "scale"
+    param <- ParamFamParameter(name = "scale", main = param0, trafo = trafo)
     modifyParam <- function(theta){ Exp(rate = 1/theta) }
     props <- c("The Exponential scale family is invariant under",
                "the group of transformations 'g(y) = scale*y'",
@@ -244,7 +258,9 @@
     name <- "lognormal scale family"
     distribution <- Lnorm(meanlog = meanlog, sdlog = sdlog)
     distrSymm <- NoSymmetry()
-    param <- ParamFamParameter(name = "scale", main = exp(meanlog), trafo = trafo)
+    param0 <- exp(meanlog)
+    names(param0) <- "scale"
+    param <- ParamFamParameter(name = "scale", main = param0, trafo = trafo)
     modifyParam <- function(theta){ Lnorm(meanlog = log(theta), sdlog = sdlog) }
     body(modifyParam) <- substitute({ Lnorm(meanlog = log(theta), sdlog = sdlog) }, list(sdlog = sdlog))
     props <- c("The Lognormal scale family is invariant under",
@@ -278,7 +294,9 @@
     name <- "normal location and scale family"
     distribution <- Norm(mean = mean, sd = sd)
     distrSymm <- SphericalSymmetry(SymmCenter = mean)
-    param <- ParamFamParameter(name = "location and scale", main = c(mean, sd), trafo = trafo)
+    param0 <- c(mean, sd)
+    names(param0) <- c("mean", "sd")
+    param <- ParamFamParameter(name = "location and scale", main = param0, trafo = trafo)
     modifyParam <- function(theta){ Norm(mean = theta[1], sd = theta[2]) }
     props <- c("The normal location and scale family is invariant under",
                "the group of transformations 'g(x) = sd*x + mean'",

Modified: branches/distr-2.0/pkg/distrMod/man/MCEstimator.Rd
===================================================================
--- branches/distr-2.0/pkg/distrMod/man/MCEstimator.Rd	2008-07-18 10:17:04 UTC (rev 184)
+++ branches/distr-2.0/pkg/distrMod/man/MCEstimator.Rd	2008-07-21 04:43:16 UTC (rev 185)
@@ -45,17 +45,7 @@
 x <- rgamma(50, scale = 0.5, shape = 3)
 
 ## parametric family of probability measures
-theta <- c(1, 2)
-names(theta) <- c("scale", "shape")
-G <- ParamFamily(name = "Gamma family",
-        param = ParamFamParameter(name = "scale and shape", main = theta),
-        distribution = Gammad(scale = 1, shape = 2),
-        modifyParam = function(theta){ 
-                          Gammad(scale = theta[1], shape = theta[2]) 
-                      },
-        props = paste(c("The Gamma family is scale invariant via the",
-                  "parametrization '(nu,shape)=(log(scale),shape)'"),
-                  collapse = " "))
+G <- GammaFamily(scale = 1, shape = 2)
 
 ## Maximum Likelihood estimator
 ## Note: you can directly use function MLEstimator!

Modified: branches/distr-2.0/pkg/distrMod/man/MDEstimator.Rd
===================================================================
--- branches/distr-2.0/pkg/distrMod/man/MDEstimator.Rd	2008-07-18 10:17:04 UTC (rev 184)
+++ branches/distr-2.0/pkg/distrMod/man/MDEstimator.Rd	2008-07-21 04:43:16 UTC (rev 185)
@@ -49,17 +49,7 @@
 x <- rgamma(50, scale = 0.5, shape = 3)
 
 ## parametric family of probability measures
-theta <- c(1, 2)
-names(theta) <- c("scale", "shape")
-G <- ParamFamily(name = "Gamma family",
-        param = ParamFamParameter(name = "scale and shape", main = theta),
-        distribution = Gammad(scale = 1, shape = 2),
-        modifyParam = function(theta){ 
-                          Gammad(scale = theta[1], shape = theta[2]) 
-                      },
-        props = paste(c("The Gamma family is scale invariant via the",
-                  "parametrization '(nu,shape)=(log(scale),shape)'"),
-                  collapse = " "))
+G <- GammaFamily(scale = 1, shape = 2)
 
 ## Kolmogorov(-Smirnov) minimum distance estimator
 MDEstimator(x = x, ParamFamily = G, distance = KolmogorovDist)

Modified: branches/distr-2.0/pkg/distrMod/man/MLEstimator.Rd
===================================================================
--- branches/distr-2.0/pkg/distrMod/man/MLEstimator.Rd	2008-07-18 10:17:04 UTC (rev 184)
+++ branches/distr-2.0/pkg/distrMod/man/MLEstimator.Rd	2008-07-21 04:43:16 UTC (rev 185)
@@ -42,17 +42,7 @@
 x <- rgamma(50, scale = 0.5, shape = 3)
 
 ## parametric family of probability measures
-theta <- c(1, 2)
-names(theta) <- c("scale", "shape")
-G <- ParamFamily(name = "Gamma family",
-        param = ParamFamParameter(name = "scale and shape", main = theta),
-        distribution = Gammad(scale = 1, shape = 2),
-        modifyParam = function(theta){ 
-                          Gammad(scale = theta[1], shape = theta[2]) 
-                      },
-        props = paste(c("The Gamma family is scale invariant via the",
-                  "parametrization '(nu,shape)=(log(scale),shape)'"),
-                  collapse = " "))
+G <- GammaFamily(scale = 1, shape = 2)
 
 ## Maximum likelihood estimator
 (res <- MLEstimator(x = x, ParamFamily = G))



More information about the Distr-commits mailing list