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

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Wed Jul 25 18:01:07 CEST 2012


Author: ingmarvisser
Date: 2012-07-25 18:01:06 +0200 (Wed, 25 Jul 2012)
New Revision: 543

Modified:
   pkg/depmixS4/R/depmix-class.R
Log:
Added compact=TRUE in show method for depmix objects to give shorter presentations; needs work

Modified: pkg/depmixS4/R/depmix-class.R
===================================================================
--- pkg/depmixS4/R/depmix-class.R	2012-07-25 16:00:17 UTC (rev 542)
+++ pkg/depmixS4/R/depmix-class.R	2012-07-25 16:01:06 UTC (rev 543)
@@ -189,19 +189,37 @@
 # 
 # PRINT method
 # 
+# 
+# PRINT method
+# 
 
 setMethod("show","depmix",
 	function(object) {
-		cat("Initial state probabilties model \n")
-		show(object at prior)
-		cat("\n")
-		for(i in 1:object at nstates) {
-			cat("Transition model for state (component)", i,"\n")
-			show(object at transition[[i]])
+		ns <- nstates(object)
+		if(is.null(attr(object,"type"))) { 
+			cat("Initial state probabilties model \n")
+			show(object at prior)
 			cat("\n")
+			for(i in 1:object at nstates) {
+				cat("Transition model for state (component)", i,"\n")
+				show(object at transition[[i]])
+				cat("\n")
+			}
+			cat("\n")
+		} else {
+			if(attr(object,"type")=="hmm") { 
+				cat("Initial state probabilties\n")
+				print(object at prior@parameters$coefficients[1:ns])
+				cat("\nTransition matrix \n")
+				pars <- getpars(object)
+				trm <- matrix(pars[(ns+1):(ns^2+ns)],ns,ns,byr=T)
+				rownames(trm) <- paste("fromS",1:ns,sep="")
+				colnames(trm) <- paste("toS",1:ns,sep="")
+				print(trm)
+				cat("\n")
+			} 
 		}
-		cat("\n")
-		for(i in 1:object at nstates) {
+		for(i in 1:ns) {
 			cat("Response model(s) for state", i,"\n\n")
 			for(j in 1:object at nresp) {
 				cat("Response model for response",j,"\n")



More information about the depmix-commits mailing list