[Distr-commits] r369 - pkg/distrMod/R

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Tue Dec 9 11:11:09 CET 2008


Author: stamats
Date: 2008-12-09 11:11:09 +0100 (Tue, 09 Dec 2008)
New Revision: 369

Modified:
   pkg/distrMod/R/mleCalc-methods.R
Log:
standardization by n not by (n-1) as in case of sd ...

Modified: pkg/distrMod/R/mleCalc-methods.R
===================================================================
--- pkg/distrMod/R/mleCalc-methods.R	2008-12-08 12:46:50 UTC (rev 368)
+++ pkg/distrMod/R/mleCalc-methods.R	2008-12-09 10:11:09 UTC (rev 369)
@@ -177,7 +177,8 @@
 
 setMethod("mleCalc", signature(x = "numeric", PFam = "NormScaleFamily"),
            function(x, PFam, ...){
-           theta <- sd(x); mn <- mean(distribution(PFam))
+           n <- length(x)
+           theta <- sqrt((n-1)/n)*sd(x); mn <- mean(distribution(PFam))
            ll <- -sum(dnorm(x, mean=mn, sd = theta, log=TRUE))
            names(ll) <- "neg.Loglikelihood"
            crit.fct <- function(sd)
@@ -190,7 +191,8 @@
 
 setMethod("mleCalc", signature(x = "numeric", PFam = "NormLocationScaleFamily"),
            function(x, PFam, ...){
-           sd0 <- sd(x); mn <- mean(x); 
+           n <- length(x)
+           sd0 <- sqrt((n-1)/n)*sd(x); mn <- mean(x); 
            theta <- c(mn, sd0); 
            names(theta) <- c("mean", "sd")
            ll <- -sum(dnorm(x, mean = mn, sd = sd0, log = TRUE))



More information about the Distr-commits mailing list