[Depmix-commits] r151 - in trunk: R man tests

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Tue Jun 10 17:14:02 CEST 2008


Author: ingmarvisser
Date: 2008-06-10 17:14:02 +0200 (Tue, 10 Jun 2008)
New Revision: 151

Modified:
   trunk/R/depmixfit.R
   trunk/R/forwardbackward.R
   trunk/man/depmix-methods.Rd
   trunk/man/depmixS4-package.Rd
   trunk/man/forwardbackward.Rd
   trunk/man/posterior.Rd
   trunk/tests/depmixNew-test1.R
   trunk/tests/depmixNew-test2.R
   trunk/tests/depmixNew-test3.R
Log:
More minor changes in documentation

Modified: trunk/R/depmixfit.R
===================================================================
--- trunk/R/depmixfit.R	2008-06-10 14:17:13 UTC (rev 150)
+++ trunk/R/depmixfit.R	2008-06-10 15:14:02 UTC (rev 151)
@@ -7,13 +7,13 @@
 		# otherwise EM is good
 		
 		# can/does EM deal with fixed constraints??? it should be possible for sure
-		if(is.null(method)) {
-			if(object at stationary&is.null(equal)&is.null(conrows)) {
-				method="EM"
-			} else {
-				method="donlp"
-			}
-		}
+ 		if(is.null(method)) {
+ 			if(is.null(equal)&is.null(conrows)) {
+ 				method="EM"
+ 			} else {
+ 				method="donlp"
+ 			}
+ 		}
 		
 		# determine which parameters are fixed
 		if(!is.null(fixed)) {
Modified: trunk/R/forwardbackward.R
===================================================================
--- trunk/R/forwardbackward.R	2008-06-10 14:17:13 UTC (rev 150)
+++ trunk/R/forwardbackward.R	2008-06-10 15:14:02 UTC (rev 151)
@@ -6,8 +6,10 @@
 
 setMethod("forwardbackward","depmix",
 	function(object, return.all=TRUE, ...) {
-	fb(init=object at init,A=object at trDens,B=object at dens,ntimes=ntimes(object), 
-		stationary=object at stationary,return.all=return.all)
-}
+		fb(init=object at init,A=object at trDens,B=object at dens,ntimes=ntimes(object), 
+			stationary=object at stationary,return.all=return.all)
+	}
+)
 
 
+
Modified: trunk/man/depmix-methods.Rd
===================================================================
--- trunk/man/depmix-methods.Rd	2008-06-10 14:17:13 UTC (rev 150)
+++ trunk/man/depmix-methods.Rd	2008-06-10 15:14:02 UTC (rev 151)
@@ -23,48 +23,50 @@
 \title{ Depmix methods. }
 
 \description{
+
 Computes the log likelihood of a depmix object.
+
 }
 
 \usage{
+	
 	\S4method{logLik}{depmix}(object,method="lystig")
-
+	
 	\S4method{nobs}{depmix}(object, ...)
-	
 	\S4method{npar}{depmix}(object)
 	\S4method{freepars}{depmix}(object)
+	
 	\S4method{setpars}{depmix}(object,values, which="pars",...)
 	\S4method{getpars}{depmix}(object,which="pars",...)	
 
 }
-%- maybe also 'usage' for other objects documented here.
 \arguments{
 
-  \item{object}{A \code{depmix} pobject}
-  
+  \item{object}{A \code{depmix} object.}
+    
+  \item{values}{To be used in \code{setpars} to set new parameter values.}
+
   \item{method}{The log likelihood can be computed by either the forward
-  backward algorithm from Rabiner, 1989, or by the method of Lystig &
+  backward algorithm from Rabiner, 1989, or by the method of Lystig and
   Hughes, 2002.  The latter is the default as it is faster because in the
   forward backward routine the state and transition smoothed probabilities
-  are also computed which are not neccessary for the log likelihood. Those
+  are also computed which are not neccessary for the log likelihood.  Those
   smoothed variables, and the forward and backward variables are accessible
-  through the \code{forwardbackward} function.}
-  
-  \item{values}{To be used in \code{setpars} to set new parameter values.}
-  
-  \item{which}{The default "pars" returns a vector of all parameters of a
-	  \code{depmix} object; the alternative value "fixed" return a
-	  logical vector of the same length indicating which parameters are
-	  fixed. The setpars functions sets parameters (or the logical fixed 
-	  vector) 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.}
+  through the \code{forwardbackward} function.} \item{which}{The default
+  "pars" returns a vector of all parameters of a
 	  
+  \code{depmix} object; the alternative value "fixed" return a logical
+  vector of the same length indicating which parameters are fixed.  The
+  setpars functions sets parameters (or the logical fixed vector) 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{...}{Not used currently.}
 
 }
+
 \value{
   
 	\item{logLik} {returns a \code{logLik} object with attributes \code{df} and \code{nobs}.}
@@ -82,7 +84,7 @@
 }
 \author{Ingmar Visser}
 \examples{
-
+	# add some examples here in the future
 }
 
 \keyword{methods}

Modified: trunk/man/depmixS4-package.Rd
===================================================================
--- trunk/man/depmixS4-package.Rd	2008-06-10 14:17:13 UTC (rev 150)
+++ trunk/man/depmixS4-package.Rd	2008-06-10 15:14:02 UTC (rev 151)
@@ -18,22 +18,26 @@
 \tabular{ll}{
 Package: \tab depmixS4\cr
 Type: \tab Package\cr
-Version: \tab 0.2\cr
-Date: \tab 2008-06-09\cr
+Version: \tab 0.2-0\cr
+Date: \tab 2008-06-10\cr
 License: \tab GPL\cr
 }
 
 Model fitting is done in two steps; first, models are specified through the
-depmix function, which uses standard arguments to eg specify GLM densities
-for the responses; second, the model is fitted; the fit function is used to 
+\code{depmix} function, which uses standard arguments to eg specify GLM densities
+for the responses; second, the model is fitted; the \code{fit} function is used to 
 provide extra arguments concerning the optimization, such as providing 
 constraints on parameters. 
 
 }
 \author{
+
 Ingmar Visser & Maarten Speekenbrink
+
 Maintainer: i.visser at uva.nl
+
 }
+
 \references{
 
 On hidden Markov models: Lawrence R. Rabiner (1989).  A tutorial on
@@ -44,10 +48,15 @@
 analysis}.  Sage Publications.
 
 }
+
 \keyword{ package }
+
 \seealso{
-\code{\link[<depmixS4>:<depmixS4>-package]{depmix}}
+
+\code{\link[depmixS4]{depmix}}
+
 }
+
 \examples{
 # These should be added at some point ...
 }
\ No newline at end of file

Modified: trunk/man/forwardbackward.Rd
===================================================================
--- trunk/man/forwardbackward.Rd	2008-06-10 14:17:13 UTC (rev 150)
+++ trunk/man/forwardbackward.Rd	2008-06-10 15:14:02 UTC (rev 151)
@@ -14,7 +14,7 @@
 
 \usage{
 
-	\S4method{posterior}{depmix}(object, return.all=TRUE, ...)
+	\S4method{forwardbackward}{depmix}(object, return.all=TRUE, ...)
 
 }
 
@@ -32,7 +32,7 @@
 \value{
 	
 	\code{forwardbackward} returns a list of the following (the variables 
-	are named after the notation from Rabiner (1989).
+	are named after the notation from Rabiner, 1989):
 
 	\item{alpha}{The forward variables.}
 	

Modified: trunk/man/posterior.Rd
===================================================================
--- trunk/man/posterior.Rd	2008-06-10 14:17:13 UTC (rev 150)
+++ trunk/man/posterior.Rd	2008-06-10 15:14:02 UTC (rev 151)
@@ -19,7 +19,6 @@
 
 \arguments{
   \item{object}{A depmix object.}
-  \item{\dots}{Not currently used.}
 }
 
 \value{

Modified: trunk/tests/depmixNew-test1.R
===================================================================
--- trunk/tests/depmixNew-test1.R	2008-06-10 14:17:13 UTC (rev 150)
+++ trunk/tests/depmixNew-test1.R	2008-06-10 15:14:02 UTC (rev 151)
@@ -141,19 +141,11 @@
 
 mod <- depmix(list(rt~1,corr~1),data=speed,family=list(gaussian(),multinomial()),transition=~Pacc,trstart=trstart,instart=instart,respst=resp,nst=2)
 
-
 mod1 <- setpars(mod,getpars(mod))
 
 cat("Test 5: ", all.equal(getpars(mod),getpars(mod1)), "(getpars and setpars) \n")
 
 
-# 
-# SPECIFYING MODELS THE EASY WAY
-# 
 
-# mod <- depmix(rt~1,data=speed,nstates=2)
-# mod
 
 
-
-

Modified: trunk/tests/depmixNew-test2.R
===================================================================
--- trunk/tests/depmixNew-test2.R	2008-06-10 14:17:13 UTC (rev 150)
+++ trunk/tests/depmixNew-test2.R	2008-06-10 15:14:02 UTC (rev 151)
@@ -4,49 +4,43 @@
 # 
 
 # 
-# test model with EM optimization, no covariates
+# test model with EM optimization
 # 
 
+rm(list=ls())
+
 require(depmixS4)
 
 data(speed)
 
-trstart=c(0.899,0.101,0.084,0.916)
-mod <- depmix(list(rt~1,corr~1),data=speed,nstates=2,family=list(gaussian(),multinomial()),trstart=trstart)
-
-# logLik before fitting
-logLik(mod)
-mod1 <- fit(mod)
-# logLik after fitting
-logLik(mod1)
-
-
-# 
-# Test optimization using Rdonlp2
-# 
-
-trstart=c(0.899,0.101,0,0.01,0.084,0.916,0,0)
+trstart=c(0.899,0.101,0,0,0.084,0.916,0,0)
 instart=c(0.5,0.5)
 resp <- c(5.52,0.202,0.472,0.528,6.39,0.24,0.098,0.902)
 
 mod <- depmix(list(rt~1,corr~1),data=speed,transition=~Pacc,nstates=2,family=list(gaussian(),multinomial()),
 	respstart=resp,trstart=trstart,instart=instart)
 
-mod2 <- fit(mod,meth="EM")
+mod1 <- fit(mod)
 
-ll <- logLik(mod2)
+ll <- logLik(mod1)
 
-cat("Test 1: ", ll, "(loglike of speed data with covariate, hopefully better than 300.5701) \n")
+cat("Test 1: ", ll, " hopefully better than 300.5701 \n")
 
+
 # 
+# NOW FIX SOME PARAMETERS
+# 
+
 # now constrain the initial state probs to be 0 and 1 
 # also constrain the guessing probs to be 0.5 and 0.5 
-# 
 
 # set the starting values of this model to the optimized 
 # values of the previously fitted model to speed optimization
+
 pars <- c(unlist(getpars(mod1)))
+
 # set some to other values, ie the ones that we want to constrain
+
 pars[2]=+Inf
 pars[14]=0
 
@@ -67,6 +61,7 @@
 
 # set the starting values of this model to the optimized 
 # values of the previously fitted model to speed optimization
+
 pars <- c(unlist(getpars(mod2)))
 mod <- setpars(mod,pars)
 
@@ -83,3 +78,6 @@
 cat("Test3: log Likelihood ratio significant, constraints not tenable.")
 
 
+
+
+
Modified: trunk/tests/depmixNew-test3.R
===================================================================
--- trunk/tests/depmixNew-test3.R	2008-06-10 14:17:13 UTC (rev 150)
+++ trunk/tests/depmixNew-test3.R	2008-06-10 15:14:02 UTC (rev 151)
@@ -9,6 +9,8 @@
 # BALANCE SCALE data example with age as covariate on class membership
 # 
 
+rm(list=ls())
+
 require(depmixS4)
 
 data(balance)



More information about the depmix-commits mailing list