[Depmix-commits] r180 - trunk/R

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Tue Jun 24 15:09:15 CEST 2008


Author: maarten
Date: 2008-06-24 15:09:15 +0200 (Tue, 24 Jun 2008)
New Revision: 180

Modified:
   trunk/R/responseGLMMULTINOM.R
   trunk/R/transInit.R
Log:
- fixed bug in multinomial fit (for number categories, nnet.default now uses softmax=TRUE rather than entropy=TRUE) 

Modified: trunk/R/responseGLMMULTINOM.R
===================================================================
--- trunk/R/responseGLMMULTINOM.R	2008-06-24 13:07:52 UTC (rev 179)
+++ trunk/R/responseGLMMULTINOM.R	2008-06-24 13:09:15 UTC (rev 180)
@@ -15,9 +15,17 @@
 		Wts <- mask
 		Wts[-1,] <- t(pars$coefficients) # set starting weights
 		if(!is.null(w)) {
-			fit <- nnet.default(x,y,weights=w,size=0,entropy=TRUE,skip=TRUE,mask=mask,Wts=Wts,trace=FALSE)
+			if(NCOL(y) < 3) {
+        fit <- nnet.default(x,y,weights=w,size=0,entropy=TRUE,skip=TRUE,mask=mask,Wts=Wts,trace=FALSE)
+      } else {
+        fit <- nnet.default(x,y,weights=w,size=0,softmax=TRUE,skip=TRUE,mask=mask,Wts=Wts,trace=FALSE)
+      }
 		} else {
-			fit <- nnet.default(x,y,size=0,entropy=TRUE,skip=TRUE,mask=mask,Wts=Wts,trace=FALSE)
+		  if(NCOL(y) < 3) {
+        fit <- nnet.default(x,y,size=0,entropy=TRUE,skip=TRUE,mask=mask,Wts=Wts,trace=FALSE)
+      } else {
+        fit <- nnet.default(x,y,size=0,softmax=TRUE,skip=TRUE,mask=mask,Wts=Wts,trace=FALSE)
+      }
 		}
 		pars$coefficients <- t(matrix(fit$wts,ncol=ncol(pars$coefficients),nrow=nrow(pars$coefficients)+1)[-1,])
 		object <- setpars(object,unlist(pars))
Modified: trunk/R/transInit.R
===================================================================
--- trunk/R/transInit.R	2008-06-24 13:07:52 UTC (rev 179)
+++ trunk/R/transInit.R	2008-06-24 13:09:15 UTC (rev 180)
@@ -108,9 +108,17 @@
 		Wts[Wts == Inf] <- .Machine$double.max.exp # Fix this!!!!
 		Wts[Wts == -Inf] <- .Machine$double.min.exp # Fix this!!!!!
 		if(!is.null(w)) {
-      fit <- nnet.default(x,y,weights=w,size=0,entropy=TRUE,skip=TRUE,mask=mask,Wts=Wts,trace=FALSE)
+      if(NCOL(y) < 3) {
+        fit <- nnet.default(x,y,weights=w,size=0,entropy=TRUE,skip=TRUE,mask=mask,Wts=Wts,trace=FALSE)
+      } else {
+        fit <- nnet.default(x,y,weights=w,size=0,softmax=TRUE,skip=TRUE,mask=mask,Wts=Wts,trace=FALSE)
+      }
     } else {
-      fit <- nnet.default(x,y,size=0,entropy=TRUE,skip=TRUE,mask=mask,Wts=Wts,trace=FALSE)
+      if(NCOL(y) < 3) {
+        fit <- nnet.default(x,y,size=0,entropy=TRUE,skip=TRUE,mask=mask,Wts=Wts,trace=FALSE)
+      } else {
+        fit <- nnet.default(x,y,size=0,softmax=TRUE,skip=TRUE,mask=mask,Wts=Wts,trace=FALSE)
+      }
     }
 		pars$coefficients <- t(matrix(fit$wts,ncol=ncol(pars$coefficients),nrow=nrow(pars$coefficients)+1)[-1,])
 		object <- setpars(object,unlist(pars))


More information about the depmix-commits mailing list