[Depmix-commits] r178 - / trunk/R trunk/man

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Fri Jun 20 15:38:09 CEST 2008


Author: ingmarvisser
Date: 2008-06-20 15:38:08 +0200 (Fri, 20 Jun 2008)
New Revision: 178

Modified:
   todo
   trunk/R/depmixfit.R
   trunk/R/getpars.R
   trunk/R/setpars.R
   trunk/man/depmix.fit.Rd
Log:
Changed getpars and setpars to deal with mix objects correctly; changed examples in depmix.fit.Rd

Modified: todo
===================================================================
--- todo	2008-06-18 18:27:08 UTC (rev 177)
+++ todo	2008-06-20 13:38:08 UTC (rev 178)
@@ -13,7 +13,6 @@
 	c) fit the model to check parameter recovery
 
 
-
 TODO list for depmix package release 0.2-0
 
 Ingmar

Modified: trunk/R/depmixfit.R
===================================================================
--- trunk/R/depmixfit.R	2008-06-18 18:27:08 UTC (rev 177)
+++ trunk/R/depmixfit.R	2008-06-20 13:38:08 UTC (rev 178)
@@ -26,6 +26,7 @@
 				fixed <- getpars(object,"fixed")
 			}
 		}
+		
 		# set those fixed parameters in the appropriate submodels
 		object <- setpars(object,fixed,which="fixed")
 		
Modified: trunk/R/getpars.R
===================================================================
--- trunk/R/getpars.R	2008-06-18 18:27:08 UTC (rev 177)
+++ trunk/R/getpars.R	2008-06-20 13:38:08 UTC (rev 178)
@@ -1,7 +1,7 @@
 setMethod("getpars","mix",
 	function(object,which="pars",...) {
 		parameters <- getpars(object at prior,which=which)
-		if(class(object)=="depmix") {
+		if(class(object)=="depmix"|class(object)=="depmix.fitted") {
 			for(i in 1:object at nstates) {
 				parameters <- c(parameters,getpars(object at transition[[i]],which=which))
 			}
Modified: trunk/R/setpars.R
===================================================================
--- trunk/R/setpars.R	2008-06-18 18:27:08 UTC (rev 177)
+++ trunk/R/setpars.R	2008-06-20 13:38:08 UTC (rev 178)
@@ -17,7 +17,7 @@
 		)
 		bp <- bp+1
 		values <- values[bp:npar(object)]
-		if(class(object)=="depmix") {
+		if(class(object)=="depmix"|class(object)=="depmix.fitted") {
 			for(i in 1:object at nstates) {
 				bp <- npar(object at transition[[i]])
 				switch(which,
Modified: trunk/man/depmix.fit.Rd
===================================================================
--- trunk/man/depmix.fit.Rd	2008-06-18 18:27:08 UTC (rev 177)
+++ trunk/man/depmix.fit.Rd	2008-06-20 13:38:08 UTC (rev 178)
@@ -193,31 +193,23 @@
 data(balance)
 # four binary items on the balance scale task
 
-# now fit some latent class models
-trstart=c(1,0,0,1) 
-# as this is a latent class model, the transitions are not optimized 
-# and hence these values are arbitrary
 instart=c(0.5,0.5)
 set.seed(1)
 respstart=runif(16)
 # note that ntimes argument is used to make this a mixture model
-mod <- depmix(list(d1~1,d2~1,d3~1,d4~1), data=balance, nstates=2,
+mod <- mix(list(d1~1,d2~1,d3~1,d4~1), data=balance, nstates=2,
 	family=list(multinomial(),multinomial(),multinomial(),multinomial()),
-	respstart=respstart,trstart=trstart,instart=instart,
-	ntimes=rep(1,nrow(balance)))
+	respstart=respstart,instart=instart)
 
 mod1 <- fit(mod)
 
 # add age as covariate on class membership by using the prior argument
-trstart=c(1,0,0,1) 
 instart=c(0.5,0.5,0,0) # we need the initial probs and the coefficients of age 
 set.seed(2)
 respstart=runif(16)
-trstart=c(1,0,0,1)
-mod2 <- depmix(list(d1~1,d2~1,d3~1,d4~1), data=balance, nstates=2,
+mod2 <- mix(list(d1~1,d2~1,d3~1,d4~1), data=balance, nstates=2,
 	family=list(multinomial(),multinomial(),multinomial(),multinomial()),
-	trstart=trstart, instart=instart, respstart=respstart,
-	ntimes=rep(1,nrow(balance)), prior=~age, initdata=balance)
+	instart=instart, respstart=respstart, prior=~age, initdata=balance)
 
 mod3 <- fit(mod2)
 



More information about the depmix-commits mailing list