[Depmix-commits] r353 - in trunk: . R man

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Mon Feb 22 15:52:53 CET 2010


Author: ingmarvisser
Date: 2010-02-22 15:52:53 +0100 (Mon, 22 Feb 2010)
New Revision: 353

Modified:
   trunk/NEWS
   trunk/R/depmixfit.R
   trunk/depmixNew-test6.R
   trunk/man/depmix.fit.Rd
Log:
Added Rsolnp support to help files.

Modified: trunk/NEWS
===================================================================
--- trunk/NEWS	2010-02-22 13:28:34 UTC (rev 352)
+++ trunk/NEWS	2010-02-22 14:52:53 UTC (rev 353)
@@ -1,4 +1,13 @@
 
+Changes in depmixS4 version 0.4-0
+
+  o added optimization using Rsolnp, which can be invoked by using 
+    method="rsolnp" in calling fit on (dep-)mix objects. The Rsolnp 
+    solver is currently available from r-forge. 
+
+  o 
+
+
 Changes in depmixS4 version 0.3-0
   
   o added multinomial response function with identity link (no covariates

Modified: trunk/R/depmixfit.R
===================================================================
--- trunk/R/depmixfit.R	2010-02-22 13:28:34 UTC (rev 352)
+++ trunk/R/depmixfit.R	2010-02-22 14:52:53 UTC (rev 353)
@@ -129,6 +129,9 @@
 					...
 				)
 				
+				if(class(object)=="depmix") class(object) <- "depmix.fitted"
+				if(class(object)=="mix") class(object) <- "mix.fitted"
+				
 				# convergence info
 				object at message <- result$message
 				
@@ -184,6 +187,9 @@
 					control = list(trace = 1)
 				)
 				
+				if(class(object)=="depmix") class(object) <- "depmix.fitted"
+				if(class(object)=="mix") class(object) <- "mix.fitted"
+				
 				object at message <- c(res$convergence," (0 is good in Rsolnp, check manual for other values)")
 				
 				# put the result back into the model
@@ -192,9 +198,6 @@
 				
 			}
 			
-			if(class(object)=="depmix") class(object) <- "depmix.fitted"
-			if(class(object)=="mix") class(object) <- "mix.fitted"
-			
 			object at conMat <- linconFull
 			object at lin.upper <- lin.u
 			object at lin.lower <- lin.l

Modified: trunk/depmixNew-test6.R
===================================================================
--- trunk/depmixNew-test6.R	2010-02-22 13:28:34 UTC (rev 352)
+++ trunk/depmixNew-test6.R	2010-02-22 14:52:53 UTC (rev 353)
@@ -46,7 +46,6 @@
 fm1sol <- fit(stmod,equal=conpat,method="rsolnp")
 fm1don <- fit(stmod,equal=conpat,method="donlp")
 
-
 fm1sol
 fm1don
 
@@ -56,6 +55,7 @@
 getpars(fm1sol)
 getpars(fm1don)
 
+all.equal(getpars(fm1sol), getpars(fm1don))
 
 
 

Modified: trunk/man/depmix.fit.Rd
===================================================================
--- trunk/man/depmix.fit.Rd	2010-02-22 13:28:34 UTC (rev 352)
+++ trunk/man/depmix.fit.Rd	2010-02-22 14:52:53 UTC (rev 353)
@@ -64,9 +64,9 @@
 \details{ 
 
 	Models are fitted by the EM algorithm if there are no constraints on
-	the parameters.  Otherwise the general optimizer \code{donlp2} from the
-	package \code{Rdonlp2} is used which handles general linear
-	(in-)equality constraints.
+	the parameters.  Otherwise the general optimizers \code{donlp2} (from
+	package \code{Rdonlp2}) or \code{solnp} (from package \code{Rsolnp})
+	are used which handle general linear (in-)equality constraints.
 	
 	Three types of constraints can be specified on the parameters: fixed,
 	equality, and general linear (in-)equality constraints.  Constraint
@@ -79,7 +79,7 @@
 	estimated to be equal. Any integers can be used in this way except 0
 	and 1, which indicate fixed and free parameters, respectively. 
 
-	Using the \code{donlp2} optimizer a Newton-Raphson scheme is employed
+	Using \code{donlp2} or \code{solnp}, a Newton-Raphson scheme is employed
 	to estimate parameters subject to linear constraints by imposing:
 	
 			bl <= A*x <= bu,
@@ -121,7 +121,9 @@
 	through \code{\link{posterior}}.
 	
 	As fitted models are depmixS4 models, they can be used as starting
-	values for new fits, for example with constraints added. 
+	values for new fits, for example with constraints added. Note that 
+	when refitting already fitted models, the constraints, if any, are not
+	added automatically, they have to be added again. 
 
 }
 
@@ -137,13 +139,15 @@
 
 data(speed)
 
-# 2-state model on rt and corr from speed data set with Pacc as covariate on the transition matrix
-# starting values for the transition pars (without those EM does not get off the ground)
+# 2-state model on rt and corr from speed data set 
+# with Pacc as covariate on the transition matrix
+# starting values for the transition pars (without 
+# those EM does not get off the ground)
 set.seed(1)
 tr=runif(6)
 trst=c(tr[1:2],0,tr[3:5],0,tr[6])
-mod1 <- depmix(list(rt~1,corr~1),data=speed,transition=~Pacc,nstates=2,family=list(gaussian(),multinomial()),
-	trstart=trst)
+mod1 <- depmix(list(rt~1,corr~1),data=speed,transition=~Pacc,nstates=2,
+	family=list(gaussian(),multinomial()),trstart=trst)
 # fit the model
 fmod1 <- fit(mod1)
 fmod1 # to see the logLik and optimization information



More information about the depmix-commits mailing list