[Depmix-commits] r446 - pkg/depmixS4/R
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Tue Nov 23 09:55:46 CET 2010
Author: ingmarvisser
Date: 2010-11-23 09:55:45 +0100 (Tue, 23 Nov 2010)
New Revision: 446
Modified:
pkg/depmixS4/R/responseGLMMULTINOM.R
Log:
Fixed a bug in multinomial response models with n>1; parameters were not normalized such that they did not sum to unity in those cases.
Modified: pkg/depmixS4/R/responseGLMMULTINOM.R
===================================================================
--- pkg/depmixS4/R/responseGLMMULTINOM.R 2010-11-11 15:12:13 UTC (rev 445)
+++ pkg/depmixS4/R/responseGLMMULTINOM.R 2010-11-23 08:55:45 UTC (rev 446)
@@ -38,6 +38,7 @@
if(is.null(w)) w <- rep(1,nrow(object at y))
sw <- sum(w)
pars <- c(apply(object at y,2,function(x){sum(x*w)/sw}))
+ pars <- pars/sum(pars)
object <- setpars(object,pars)
}
object
@@ -52,6 +53,7 @@
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?
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