[Yuima-commits] r100 - pkg/yuima/R

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Tue Jul 13 18:03:47 CEST 2010


Author: iacus
Date: 2010-07-13 18:03:47 +0200 (Tue, 13 Jul 2010)
New Revision: 100

Modified:
   pkg/yuima/R/qmle.R
Log:
optimzed likelihhod for one dim x

Modified: pkg/yuima/R/qmle.R
===================================================================
--- pkg/yuima/R/qmle.R	2010-07-13 15:38:56 UTC (rev 99)
+++ pkg/yuima/R/qmle.R	2010-07-13 16:03:47 UTC (rev 100)
@@ -395,12 +395,22 @@
 
 	
 	vec <- env$deltaX-h*drift[-n,]
+
 	K <- -0.5*d.size * log( (2*pi*h) )
 
-	
-	for(t in 1:(n-1)){
+	dimB <- dim(diff[, , 1])
+
+	if(is.null(dimB)){  # one dimensional X
+	  for(t in 1:(n-1)){
+		yB <- diff[, , t]^2
+		logdet <- log(yB)
+		pn <- K - 0.5*logdet-0.5*vec[t, ]^2/(h*yB) 
+		QL <- QL+pn
+			
+		}
+	} else {  # multidimensional X
+	 for(t in 1:(n-1)){
 		yB <- diff[, , t] %*% t(diff[, , t])
-
 		logdet <- log(det(yB))
 		if(is.infinite(logdet) ){ # should we return 1e10?
 			pn <- log(1)
@@ -411,7 +421,11 @@
 					  ((-1/(2*h))*t(vec[t, ])%*%solve(yB)%*%vec[t, ]) 
 			QL <- QL+pn
 		}
+	 }
 	}
+	
+	
+	
 	if(QL==-Inf){
 		yuima.warn("quasi likelihood is too small to calculate.")
 	}



More information about the Yuima-commits mailing list