[Depmix-commits] r397 - trunk/R

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Tue Mar 9 13:27:20 CET 2010


Author: ingmarvisser
Date: 2010-03-09 13:27:20 +0100 (Tue, 09 Mar 2010)
New Revision: 397

Modified:
   trunk/R/depmixfit.R
   trunk/R/responseMVN.R
Log:
Bounds in MVNresponse, example in ...test7.R

Modified: trunk/R/depmixfit.R
===================================================================
--- trunk/R/depmixfit.R	2010-03-09 09:25:37 UTC (rev 396)
+++ trunk/R/depmixfit.R	2010-03-09 12:27:20 UTC (rev 397)
@@ -35,12 +35,13 @@
 		
 		if(method=="donlp"||method=="rsolnp") {
 			
-			if(method=="donlp"&!require(Rdonlp2)) {
+			reqdon <- require(Rdonlp2,quietly=TRUE)
+			if(method=="donlp"&!reqdon) {
 				warning("Rdonlp2 not available, method changed to rsolnp")
 				method="rsolnp"
 			}
 			
-			if(method=="rsolnp"&!(require(Rsolnp))) stop("Optimization requires either 'Rdonlp2' or 'Rsolnp'")
+			if(method=="rsolnp"&!(require(Rsolnp,quietly=TRUE))) stop("Optimization requires either 'Rdonlp2' or 'Rsolnp'")
 			
 			# determine which parameters are fixed
  			if(fi) {

Modified: trunk/R/responseMVN.R
===================================================================
--- trunk/R/responseMVN.R	2010-03-09 09:25:37 UTC (rev 396)
+++ trunk/R/responseMVN.R	2010-03-09 12:27:20 UTC (rev 397)
@@ -15,8 +15,6 @@
 	cov
 }
 
-
-
 setClass("MVNresponse",
   representation(formula="formula"),
   contains="response"
@@ -50,7 +48,6 @@
     	invSigma <- solve(sigma)
     }
 	# check consistency
-	
 	if (NCOL(x) != NCOL(invSigma)) {
 	    stop("x and sigma have non-conforming size")
 	}
@@ -84,7 +81,6 @@
     }
 }
 
-
 setMethod("logDens","MVNresponse",
 	function(object,...) {
 		dm_dmvnorm(x=object at y,mean=predict(object),sigma=par2cov(object at parameters$Sigma),log=TRUE,...)
@@ -139,11 +135,19 @@
 		y <- model.response(mf)
 		if(!is.matrix(y)) y <- matrix(y,ncol=1)
 		parameters <- list()
-		constr <- NULL
 		parameters$coefficients <- matrix(0.0,ncol=ncol(y),nrow=ncol(x))
 		parameters$Sigma <- cov2par(diag(ncol(y)))
 		npar <- length(unlist(parameters))
-# 		constr <- list(parlow=c(rep(-Inf,length(unlist(parameters$coefficients))),
+		parlow.coeff=rep(-Inf,length(unlist(parameters$coefficients)))
+		parup.coeff=rep(Inf,length(unlist(parameters$coefficients)))
+		parup.cov <- rep(Inf,length(unlist(parameters$Sigma)))
+		mcov <- matrix(-Inf,ncol(y),ncol(y))
+		diag(mcov) <- .Machine$double.eps
+		parlow.cov <- cov2par(mcov)
+		constr <- list(	
+			parup = c(parup.coeff,parup.cov),
+			parlow = c(parlow.coeff,parlow.cov)
+		)
 		if(is.null(fixed)) fixed <- as.logical(rep(0,npar))
 		if(!is.null(pstart)) {
 			if(length(pstart)!=npar) stop("length of 'pstart' must be",npar)



More information about the depmix-commits mailing list