[Distr-commits] r271 - branches/distr-2.0/pkg/distrMod/R

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Wed Aug 27 08:58:32 CEST 2008


Author: ruckdeschel
Date: 2008-08-27 08:58:31 +0200 (Wed, 27 Aug 2008)
New Revision: 271

Modified:
   branches/distr-2.0/pkg/distrMod/R/mleCalc-methods.R
Log:
small bug in particular mleCalc-method for BinomFamily

Modified: branches/distr-2.0/pkg/distrMod/R/mleCalc-methods.R
===================================================================
--- branches/distr-2.0/pkg/distrMod/R/mleCalc-methods.R	2008-08-26 20:51:48 UTC (rev 270)
+++ branches/distr-2.0/pkg/distrMod/R/mleCalc-methods.R	2008-08-27 06:58:31 UTC (rev 271)
@@ -133,8 +133,9 @@
 
 setMethod("mleCalc", signature(x = "numeric", PFam = "BinomFamily"),
            function(x, PFam, ...){
-           theta <- mean(x)
-           ll <- -sum(dbinom(x, size=size(param(PFam)), prob=theta, log=TRUE))
+           size <- size(param(distribution(PFam)))
+           theta <- mean(x)/size
+           ll <- -sum(dbinom(x, size=size, prob=theta, log=TRUE))
            names(ll) <- "neg.Loglikelihood"
            crit.fct <- function(prob)
                           -sum(dbinom(x, size=size(param(PFam)), prob=prob, 
@@ -189,7 +190,7 @@
            sd0 <- sd(x); mn <- mean(x); 
            theta <- c(mn, sd0); 
            names(theta) <- c("mean", "sd")
-           ll <- -sum(dnorm(x, mean=mn, sd = sd0, log=TRUE))
+           ll <- -sum(dnorm(x, mean = mn, sd = sd0, log = TRUE))
            names(ll) <- "neg.Loglikelihood"
            crit.fct <- function(mean,sd)
                            -sum(dnorm(x, mean=mean, sd = sd, log=TRUE))



More information about the Distr-commits mailing list