[Depmix-commits] r600 - in pkg/depmixS4: R man

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Tue Sep 17 11:58:56 CEST 2013


Author: maarten
Date: 2013-09-17 11:58:56 +0200 (Tue, 17 Sep 2013)
New Revision: 600

Modified:
   pkg/depmixS4/R/viterbi.R
   pkg/depmixS4/man/depmix.Rd
   pkg/depmixS4/man/em.control.Rd
Log:
- added names for posterior state columns in "posterior"
- added reference to classification likelihood in ?em.control
- moved classification likelihood example from ?depmix to ?em.control 

Modified: pkg/depmixS4/R/viterbi.R
===================================================================
--- pkg/depmixS4/R/viterbi.R	2013-09-17 08:19:28 UTC (rev 599)
+++ pkg/depmixS4/R/viterbi.R	2013-09-17 09:58:56 UTC (rev 600)
@@ -56,7 +56,9 @@
 			}
 		}
 	}
-	
+  
+  colnames(delta) <- paste("S",1:ns,sep="")
+  
 	delta <- data.frame(state,delta) 	
 	return(delta)
 }

Modified: pkg/depmixS4/man/depmix.Rd
===================================================================
--- pkg/depmixS4/man/depmix.Rd	2013-09-17 08:19:28 UTC (rev 599)
+++ pkg/depmixS4/man/depmix.Rd	2013-09-17 09:58:56 UTC (rev 600)
@@ -247,16 +247,6 @@
 plot(as.ts(posterior(fm2)[,2]),ylab="probability",
 main="Posterior probability of state 1 (volatile, negative markets).")
 
-# using "hard" assignment of observations to the states, we can maximise the
-# classification likelihood instead of the usual marginal likelihood
-# (this example uses the model at the start of these examples)
-data(speed)	
-mod <- depmix(list(rt~1,corr~1),data=speed,nstates=2,
-    family=list(gaussian(),multinomial("identity")),ntimes=c(168,134,137))
-set.seed(1)
-# fit the model by calling fit
-fm3 <- fit(mod,emcontrol=em.control(classification="hard"))
-
 }
 
 \keyword{methods}

Modified: pkg/depmixS4/man/em.control.Rd
===================================================================
--- pkg/depmixS4/man/em.control.Rd	2013-09-17 08:19:28 UTC (rev 599)
+++ pkg/depmixS4/man/em.control.Rd	2013-09-17 09:58:56 UTC (rev 600)
@@ -58,20 +58,25 @@
 estimation from different starting values.
 
 Argument \code{classification} is used to choose either soft (default) or
-hard classification to states. When using soft classification, observations
+hard classification of observations to states. When using soft classification, observations
 are assigned to states with a weight equal to the posterior probability of
 the state. When using hard classification, observations are assigned to states
 according to the maximum a posteriori (MAP) states (i.e., each observation
 is assigned to one state, which is determined by the Viterbi algorithm in the
-case of \code{depmix} models). Warning: hard classification is mainly 
-implemented for testing purposes and its use is currently not advised.
-
+case of \code{depmix} models). As a result, the EM algorithm will find a local
+maximum of the classification likelihood (Celeux & Govaert, 1992). 
+Warning: hard classification is an experimental feature, 
+especially for hidden Markov models, and its use is currently not advised.
 }
 
 \references{
 	Lawrence R. Rabiner (1989).  A tutorial on hidden Markov models and
 	selected applications in speech recognition.  \emph{Proceedings of
 	IEEE}, 77-2, p.  267-295.
+  
+  Gilles Celeux and Gerard Govaert (1992). A classification EM algorithm 
+  for clustering and two stochastic versions. \emph{Computational
+Statistics and Data Analysis, 14}, p. 315-332.
 }
 
 \value{
@@ -83,3 +88,17 @@
 \author{Ingmar Visser & Maarten Speekenbrink}
 
 \keyword{methods}
+
+\examples{
+# using "hard" assignment of observations to the states, we can maximise the
+# classification likelihood instead of the usual marginal likelihood
+data(speed)  
+mod <- depmix(list(rt~1,corr~1),data=speed,nstates=2,
+    family=list(gaussian(),multinomial("identity")),ntimes=c(168,134,137))
+set.seed(1)
+# fit the model by calling fit
+fmod <- fit(mod,emcontrol=em.control(classification="hard"))
+# can get rather different solutions with different starting values...
+set.seed(3)
+fmod2 <- fit(mod,emcontrol=em.control(classification="hard"))
+}
\ No newline at end of file



More information about the depmix-commits mailing list