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

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Thu Jul 26 13:41:11 CEST 2012


Author: ingmarvisser
Date: 2012-07-26 13:41:10 +0200 (Thu, 26 Jul 2012)
New Revision: 547

Modified:
   pkg/depmixS4/R/depmix-class.R
   pkg/depmixS4/man/depmix-methods.Rd
   pkg/depmixS4/man/makeDepmix.Rd
Log:
Added help for getmodel; number=1 as default in getmodel

Modified: pkg/depmixS4/R/depmix-class.R
===================================================================
--- pkg/depmixS4/R/depmix-class.R	2012-07-26 11:38:58 UTC (rev 546)
+++ pkg/depmixS4/R/depmix-class.R	2012-07-26 11:41:10 UTC (rev 547)
@@ -51,7 +51,7 @@
 )
 
 setMethod("getmodel","mix",
-		function(object, which="response", state=1, number) {
+		function(object, which="response", state=1, number=1) {
 				ans=switch(
 						which,
 						"response" = 1,
@@ -59,7 +59,6 @@
 						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)
@@ -156,6 +155,7 @@
 
 setMethod("summary","mix",
 		function(object,which="all",compact=TRUE) {
+				ns <- object at nstates
 				ans=switch(which,
 						"all" = 1,
 						"response" = 2,
@@ -247,16 +247,15 @@
 )
 
 setMethod("getmodel","depmix",
-		function(object, which="response", state=1, number) {
+		function(object, which="response", state=1, number=1) {
 				ans=switch(
 						which,
 						"response" = 1,
 						"prior" = 2,
-						"transition"=3,
+						"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)

Modified: pkg/depmixS4/man/depmix-methods.Rd
===================================================================
--- pkg/depmixS4/man/depmix-methods.Rd	2012-07-26 11:38:58 UTC (rev 546)
+++ pkg/depmixS4/man/depmix-methods.Rd	2012-07-26 11:41:10 UTC (rev 547)
@@ -30,6 +30,11 @@
 \alias{getpars,depmix-method}
 \alias{getpars,mix-method}
 
+\alias{getmodel}
+\alias{getmodel,depmix-method}
+\alias{getmodel,mix-method}
+
+
 \title{ 'depmix' and 'mix' methods. }
 
 \description{
@@ -57,6 +62,9 @@
 	
 	\S4method{getpars}{depmix}(object,which="pars",...)	
 	\S4method{getpars}{mix}(object,which="pars",...)	
+	
+	\S4method{getmodel}{depmix}(object,which="response",state=1,number=1)	
+	\S4method{getmodel}{mix}(object,which="response",state=1,number=1)
 }
 \arguments{
 
@@ -73,14 +81,25 @@
   smoothed variables, and the forward and backward variables are accessible
   through the \code{\link{forwardbackward}} function.} 
 
-	\item{which}{The default "pars" returns a vector of all parameters of a
-	\code{depmix} object; the alternative value "fixed" returns a logical
-	vector of the same length indicating which parameters are fixed.  The
-	setpars functions sets parameters to new values; \code{setpars} also
-	recomputes the dens, trans and init slots of \code{depmix} objects.  Note
-	that the \code{getpars} and \code{setpars} functions for \code{depmix}
-	objects simply call the functions of the same name for the response and
-	transition models.}
+	\item{which}{\code{getpars} function: The default "pars" returns a vector
+	of all parameters of a \code{depmix} object; the alternative value
+	"fixed" returns a logical vector of the same length indicating which
+	parameters are fixed.  The setpars functions sets parameters to new
+	values; \code{setpars} also recomputes the dens, trans and init slots of
+	\code{depmix} objects.  Note that the \code{getpars} and \code{setpars}
+	functions for \code{depmix} objects simply call the functions of the same
+	name for the response and transition models.
+	
+	\code{getmodel} function: possible values are "response" (the default),
+	"prior" and "transition" to return the corresponding submodels.  }
+	
+	\item{state}{In \code{getmodel} this determines the submodel to be
+	returned (together with number in the case of response models); when
+	which="transition", \code{getmodel} returns the transition submodel for
+	state=\code{state}.}
+
+	\item{number}{In \code{getmodel} this determines the "response" model to
+	be returned from state \code{state}.}
 	  
   \item{...}{Not used currently.}
 
@@ -99,6 +118,10 @@
 	\item{setpars}{returns a \code{(dep-)mix} object with new parameter values.}
 
 	\item{getpars}{returns a vector with the current parameter values.}
+	
+	\item{getmodel}{returns a submodel of a \code{(dep-)mix} model; the prior
+	model, one of the transition models (determined by argument state) or one
+	of the response models (determined by arguments state and number).}
 
 }
 
@@ -110,6 +133,10 @@
 data(speed)
 mod <- depmix(list(rt~1,corr~1),data=speed,nstates=2,family=list(gaussian(),multinomial()))
 
+getmodel(mod,"response",2,1)
+
+getmodel(mod,"prior")
+
 # get the loglikelihood of the model
 logLik(mod)
 
@@ -119,7 +146,7 @@
 
 # to see which parameters are fixed (by default only baseline parameters in
 # the multinomial logistic models for the transition models and the initial
-# state probabilities model
+# state probabilities model)
 mod <- setpars(mod, getpars(mod,which="fixed"))
 mod
 

Modified: pkg/depmixS4/man/makeDepmix.Rd
===================================================================
--- pkg/depmixS4/man/makeDepmix.Rd	2012-07-26 11:38:58 UTC (rev 546)
+++ pkg/depmixS4/man/makeDepmix.Rd	2012-07-26 11:41:10 UTC (rev 547)
@@ -290,7 +290,7 @@
 mod <- makeDepmix(response=rModels,transition=transition,prior=inMod,ntimes=c(168,134,137),stat=FALSE)
 
 fm3 <- fit(mod,emc=em.control(rand=FALSE))
-summary(fm3)
+summary(fm3,compact=FALSE)
 
 }
 



More information about the depmix-commits mailing list