[Depmix-commits] r602 - pkg/depmixS4/man

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Wed Sep 18 13:34:36 CEST 2013


Author: ingmarvisser
Date: 2013-09-18 13:34:36 +0200 (Wed, 18 Sep 2013)
New Revision: 602

Modified:
   pkg/depmixS4/man/depmix.fit.Rd
   pkg/depmixS4/man/makeDepmix.Rd
Log:
Reduced run time of examples to less than 5 seconds each

Modified: pkg/depmixS4/man/depmix.fit.Rd
===================================================================
--- pkg/depmixS4/man/depmix.fit.Rd	2013-09-17 12:18:33 UTC (rev 601)
+++ pkg/depmixS4/man/depmix.fit.Rd	2013-09-18 11:34:36 UTC (rev 602)
@@ -1,6 +1,7 @@
 \name{fit}
 
 \alias{fit}
+
 \alias{depmix.fit}
 \alias{fit,depmix-method}
 
@@ -19,17 +20,11 @@
 
 	\code{fit} optimizes parameters of \code{\link{depmix}} or
 	\code{\link{mix}} models, optionally subject to general linear
-	(in)equality constraints.
+	(in)equality constraints. 
 
 }
 
 \usage{
-	
-	\S4method{fit}{depmix}(object, fixed=NULL, equal=NULL, conrows=NULL,
-		conrows.upper=0, conrows.lower=0, method=NULL, emcontrol=em.control(), 
-		verbose=TRUE,...)
-	
-	\S4method{summary}{depmix.fitted}(object,which="all")
 
 	\S4method{fit}{mix}(object, fixed=NULL, equal=NULL, 
 		conrows=NULL, conrows.upper=0, conrows.lower=0, 
@@ -41,6 +36,8 @@
 		...)
 	
 	\S4method{summary}{mix.fitted}(object,which="all")
+	
+	\S4method{summary}{depmix.fitted}(object,which="all")
 
 }
 
@@ -190,7 +187,7 @@
 summary(fmod1)
 
 # same model, now with missing data
-
+\dontrun{
 speed[2,1] <- NA
 speed[3,2] <- NA
 
@@ -202,8 +199,15 @@
 # fit the model
 set.seed(3)
 fmod1ms <- fit(mod1ms)
+}
 
+# instead of the normal likelihood, we can also maximise the "classification" likelihood
+# this uses the maximum a posteriori state sequence to assign observations to states
+# and to compute initial and transition probabilities. 
 
+fmod1b <- fit(mod1,emcontrol=em.control(classification="hard"))
+fmod1b # to see the logLik and optimization information
+
 # FIX SOME PARAMETERS
 
 # get the starting values of this model to the optimized 
@@ -226,19 +230,17 @@
 # fit the model
 fmod2 <- fit(mod2,fixed=!free)
 
-# fit the same model but use Rdonlp2 package with some tweaks
-\dontrun{
-fmod2 <- fit(mod2,fixed=!free,method="donlp",donlpcntr=donlp2Control(te0=FALSE))
-}
-
 # likelihood ratio insignificant, hence fmod2 better than fmod1
 llratio(fmod1,fmod2)
 
-# NOW ADD SOME GENERAL LINEAR CONSTRAINTS
 
+# ADDING SOME GENERAL LINEAR CONSTRAINTS
+
 # set the starting values of this model to the optimized 
 # values of the previously fitted model to speed optimization
 
+\dontrun{
+
 pars <- c(unlist(getpars(fmod2)))
 pars[4] <- pars[8] <- -4
 pars[6] <- pars[10] <- 10
@@ -267,6 +269,8 @@
 # starting values
 fmod3b <- fit(mod3,conrows=conr,fixed=!free) # using free defined above
 
+}
+
 data(balance)
 # four binary items on the balance scale task
 mod4 <- mix(list(d1~1,d2~1,d3~1,d4~1), data=balance, nstates=2,
@@ -276,6 +280,8 @@
 set.seed(1)
 fmod4 <- fit(mod4)
 
+\dontrun{
+
 # add age as covariate on class membership by using the prior argument
 mod5 <- mix(list(d1~1,d2~1,d3~1,d4~1), data=balance, nstates=2,
 	family=list(multinomial("identity"),multinomial("identity"),
@@ -288,14 +294,8 @@
 # check the likelihood ratio; adding age significantly improves the goodness-of-fit
 llratio(fmod5,fmod4)
 
-# instead of the normal likelihood, we can also maximise the "classification" likelihood
-# this uses the maximum a posteriori state sequence to assign observations to states
-# and to compute initial and transition probabilities. 
+}
 
-fmod1b <- fit(mod1,emcontrol=em.control(classification="hard"))
-fmod1b # to see the logLik and optimization information
-
-
 }
 
 \author{Ingmar Visser & Maarten Speekenbrink}

Modified: pkg/depmixS4/man/makeDepmix.Rd
===================================================================
--- pkg/depmixS4/man/makeDepmix.Rd	2013-09-17 12:18:33 UTC (rev 601)
+++ pkg/depmixS4/man/makeDepmix.Rd	2013-09-18 11:34:36 UTC (rev 602)
@@ -281,11 +281,13 @@
 rModels <- list(
   list(
 	  exgaus(rt,pstart=c(5,.1,.1)),
-		GLMresponse(formula=corr~1, data=speed, family=multinomial(), pstart=c(0.5,0.5))
+		GLMresponse(formula=corr~1, data=speed, 
+		family=multinomial("identity"), pstart=c(0.5,0.5))
 	),
 	list(
 		exgaus(rt,pstart=c(6,.1,.1)),
-		GLMresponse(formula=corr~1, data=speed, family=multinomial(), pstart=c(.1,.9))
+		GLMresponse(formula=corr~1, data=speed, 
+		family=multinomial("identity"), pstart=c(.1,.9))
 	)
 )
 
@@ -295,13 +297,13 @@
 transition[[2]] <- transInit(~Pacc,nstates=2,data=speed,pstart=c(trstart[3:4],0,0))
 
 instart=c(0.5,0.5)
-inMod <- transInit(~1,ns=2,ps=instart,data=data.frame(rep(1,3)))
+inMod <- transInit(~1,ns=2,ps=instart,family=multinomial("identity"), data=data.frame(rep(1,3)))
 
 mod <- makeDepmix(response=rModels,transition=transition,prior=inMod,ntimes=c(168,134,137), 
 homogeneous=FALSE)
 
 fm3 <- fit(mod,emc=em.control(rand=FALSE))
-summary(fm3,compact=FALSE)
+summary(fm3)
 }
 
 }



More information about the depmix-commits mailing list