[Depmix-commits] r447 - pkg/depmixS4/R

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Tue Nov 23 13:18:16 CET 2010


Author: ingmarvisser
Date: 2010-11-23 13:18:16 +0100 (Tue, 23 Nov 2010)
New Revision: 447

Modified:
   pkg/depmixS4/R/responseGLM.R
   pkg/depmixS4/R/responseGLMMULTINOM.R
Log:
Added an error message for multinomial response models with n>1 and link='mlogit' as this case is not handled.

Modified: pkg/depmixS4/R/responseGLM.R
===================================================================
--- pkg/depmixS4/R/responseGLM.R	2010-11-23 08:55:45 UTC (rev 446)
+++ pkg/depmixS4/R/responseGLM.R	2010-11-23 12:18:16 UTC (rev 447)
@@ -62,7 +62,8 @@
 					y <- model.matrix(~factor(y)-1)
 				}
 			}
-			if(family$link=="mlogit") {				
+			if(family$link=="mlogit") {
+				if(any(y>1)) stop("multinomial response with n>1 not allowed with link='mlogit'")
 				parameters$coefficients <- matrix(0,ncol=ncol(y),nrow=ncol(x))
 				if(is.null(fixed)) {
 					fixed <- parameters$coefficients
Modified: pkg/depmixS4/R/responseGLMMULTINOM.R
===================================================================
--- pkg/depmixS4/R/responseGLMMULTINOM.R	2010-11-23 08:55:45 UTC (rev 446)
+++ pkg/depmixS4/R/responseGLMMULTINOM.R	2010-11-23 12:18:16 UTC (rev 447)
@@ -54,6 +54,7 @@
 			res <- matrix(nr=nr)
 			pr <- predict(object)
 			# fix this loop!!!! replace with call to apply? or dmultinomial? or other vectorized version?
+			# possibly use dmultinomial in package mcd2
 			for(i in 1:nrow(object at y)) {
 				res[i,1] <- dmultinom(object at y[i,],pr=pr[i,])
 			}
@@ -71,6 +72,8 @@
 			nr <- nrow(object at y)
 			res <- matrix(nr=nr)
 			pr <- predict(object)
+			# fix this loop!!!! replace with call to apply? or dmultinomial? or other vectorized version?
+			# possibly use dmultinomial in package mcd2
 			for(i in 1:nrow(object at y)) {
 				res[i,1] <- dmultinom(object at y[i,],pr=pr[i,])
 			}


More information about the depmix-commits mailing list