[Depmix-commits] r687 - in pkg/depmixS4: . R

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Wed Jun 24 15:28:33 CEST 2020


Author: maarten
Date: 2020-06-24 15:28:32 +0200 (Wed, 24 Jun 2020)
New Revision: 687

Modified:
   pkg/depmixS4/NEWS
   pkg/depmixS4/R/EM.R
Log:
changed rdirichlet to give vector of 1s when length(alpha) = 1; fixes issue with random.start in EM when nclasses=1

Modified: pkg/depmixS4/NEWS
===================================================================
--- pkg/depmixS4/NEWS	2020-01-23 11:24:17 UTC (rev 686)
+++ pkg/depmixS4/NEWS	2020-06-24 13:28:32 UTC (rev 687)
@@ -1,3 +1,14 @@
+Changes in depmixS4 version 1.4-2
+
+Major changes
+  o  
+
+Minor changes
+
+  o Changed rdirichlet to reliably give a vector of 1's when alpha has length 1. 
+    This fixes issue with random.start in EM for nclasses = 1 (see 
+    https://stackoverflow.com/q/56735420/13797727)
+
 Changes in depmixS4 version 1.4-1
 
 Major changes

Modified: pkg/depmixS4/R/EM.R
===================================================================
--- pkg/depmixS4/R/EM.R	2020-01-23 11:24:17 UTC (rev 686)
+++ pkg/depmixS4/R/EM.R	2020-06-24 13:28:32 UTC (rev 687)
@@ -6,9 +6,10 @@
 rdirichlet <- function(n, alpha) {
   # taken from gtools
     l <- length(alpha)
+    if(l == 1) return(as.matrix(rep(1,n)))
     x <- matrix(rgamma(l * n, alpha), ncol = l, byrow = TRUE)
     sm <- x %*% rep(1, l)
-    x/as.vector(sm)
+    return(x/as.vector(sm))
 }
 
 which.is.max <- function(x) {



More information about the depmix-commits mailing list