[Depmix-commits] r282 - pkg/depmix/R

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Wed Jul 8 16:06:54 CEST 2009


Author: ingmarvisser
Date: 2009-07-08 16:06:54 +0200 (Wed, 08 Jul 2009)
New Revision: 282

Modified:
   pkg/depmix/R/depmix.R
Log:
Changed the call to npsol code, which now uses an option file for setting iteration limit and other optional control parameters.

Modified: pkg/depmix/R/depmix.R
===================================================================
--- pkg/depmix/R/depmix.R	2009-07-08 11:45:10 UTC (rev 281)
+++ pkg/depmix/R/depmix.R	2009-07-08 14:06:54 UTC (rev 282)
@@ -86,9 +86,9 @@
 		}
 	}
 	
- 	initLogl=loglike(dat=dat,dmm=xgmod,tdcov=tdcov,print=0,set=FALSE)$logl
- 	if(is.nan(initLogl) || is.infinite(initLogl)) stop("Initial model inadmissible, better starting values needed?!\n")
- 	if(printlevel>0) cat("Initial loglikelihood: ", initLogl, " \n")
+	initLogl=loglike(dat=dat,dmm=xgmod,tdcov=tdcov,print=0,set=FALSE)$logl
+	if(is.nan(initLogl) || is.infinite(initLogl)) stop("Initial model inadmissible, better starting values needed?!\n")
+	if(printlevel>0) cat("Initial loglikelihood: ", initLogl, " \n")
 	
 	timeUsed=0
 	
@@ -196,21 +196,21 @@
 		} # else nothing to do, bl and bu are already defined
 		
 		## npsol optimization options
- 		itlim=paste(c("Iteration Limit = ", iterlim , "   "), collapse=" ")
- 		npopts=c(itlim,
- 			"Print level = 20 ",
- 			"Minor print level = 10",
- 			"Derivative level = 0 ",
- 			"Hessian = No ",
- 			"Verify level = 0 ")
+#  		itlim=paste(c("Iteration Limit = ", iterlim , "   "), collapse=" ")
+#  		npopts=c(itlim,
+#  			"Print level = 20 ",
+#  			"Minor print level = 10",
+#  			"Derivative level = 0 ",
+#  			"Hessian = No ",
+#  			"Verify level = 0 ")
 		
 # 			"Optimality tolerance = 1.0e-12 ")
 		# verify options: 0 is good for standard markovian and latent class models
 		# verify level should be 3 for new types of models, ie with new distributions etc.
 		
- 		optset=lapply(npopts,FUN=optfor <- function(opt) {.Fortran("npoptn",as.character(opt),PACKAGE="depmix") } )
+#  		optset=lapply(npopts,FUN=optfor <- function(opt) {.Fortran("npoptn",as.character(opt),PACKAGE="depmix") } )
 		# optfile can be used to read in an optionsfile called npoptn from the working directory
-		optfile=0 # using this will override above specified default options
+		optfile=1 # using this will override above specified default options
 		derivatives=der # are derivatives to be used or not
 		cj=1 # non linear constraints are not supported yet, hence cj=1
 		maxnpcalls=1 # maxnpcalls is not used at the moment
@@ -314,7 +314,7 @@
 	
 	##  call optim or nlm to optimize the model
 	if(method=="optim" || method=="nlm") {
-		vfactor=15
+# 		vfactor=15
 		# reparametrize for optim and nlm
 		noptpars=length(fitpars)
 		# un-constrained pars
@@ -612,10 +612,10 @@
 		warning("gradients not available for items other than multinomial and gaussian.")
 	}
 	
- 	if(hess) {
- 		warning("Hessian not implemented (yet).\n")
- 		hess=0
- 	}
+	if(hess) {
+		warning("Hessian not implemented (yet).\n")
+		hess=0
+	}
 	
 	if(tdcov) {
 		pars=xgmod$pars



More information about the depmix-commits mailing list