[Depmix-commits] r540 - pkg/depmixS4/R
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Wed Jul 25 16:55:55 CEST 2012
Author: ingmarvisser
Date: 2012-07-25 16:55:55 +0200 (Wed, 25 Jul 2012)
New Revision: 540
Modified:
pkg/depmixS4/R/depmix-class.R
Log:
Added methods for getmodel generic for mix and depmix objects, eg getmodel(object,which="transition",state=2) gives the transition model for state 2 of a depmix object
Modified: pkg/depmixS4/R/depmix-class.R
===================================================================
--- pkg/depmixS4/R/depmix-class.R 2012-07-25 14:54:45 UTC (rev 539)
+++ pkg/depmixS4/R/depmix-class.R 2012-07-25 14:55:55 UTC (rev 540)
@@ -50,6 +50,22 @@
}
)
+setMethod("getmodel","mix",
+ function(object, which="response", state=1, number) {
+ ans=switch(
+ which,
+ "response" = 1,
+ "prior" = 2,
+ stop("Invalid 'which' argument in getmodel on 'mix' object.")
+ )
+ if(ans==1) {
+ if(is.null(number)) number <- 1
+ return(object at response[[state]][[number]])
+ }
+ if(ans==2) return(object at prior)
+ }
+)
+
setMethod("simulate",signature(object="mix"),
function(object,nsim=1,seed=NULL,...) {
@@ -197,6 +213,24 @@
}
)
+setMethod("getmodel","depmix",
+ function(object, which="response", state=1, number) {
+ ans=switch(
+ which,
+ "response" = 1,
+ "prior" = 2,
+ "transition"=3,
+ stop("Invalid 'which' argument in getmodel on 'mix' object.")
+ )
+ if(ans==1) {
+ if(is.null(number)) number <- 1
+ return(object at response[[state]][[number]])
+ }
+ if(ans==2) return(object at prior)
+ if(ans==3) return(object at transition[[state]])
+ }
+)
+
setMethod("is.stationary",signature(object="depmix"),
function(object) {
return(object at stationary)
More information about the depmix-commits
mailing list