[Yuima-commits] r120 - in pkg/yuima: . R

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Tue Aug 3 20:23:49 CEST 2010


Author: iacus
Date: 2010-08-03 20:23:47 +0200 (Tue, 03 Aug 2010)
New Revision: 120

Modified:
   pkg/yuima/DESCRIPTION
   pkg/yuima/NEWS
   pkg/yuima/R/CPoint.R
   pkg/yuima/R/qmle.R
Log:
fixed time.variable issue in estimation

Modified: pkg/yuima/DESCRIPTION
===================================================================
--- pkg/yuima/DESCRIPTION	2010-07-29 04:24:26 UTC (rev 119)
+++ pkg/yuima/DESCRIPTION	2010-08-03 18:23:47 UTC (rev 120)
@@ -1,8 +1,8 @@
 Package: yuima
 Type: Package
 Title: The YUIMA Project package (unstable version)
-Version: 0.1.10
-Date: 2010-07-24
+Version: 0.1.11
+Date: 2010-08-03
 Depends: methods, zoo, stats4, utils
 Suggests: cubature, mvtnorm
 Author: YUIMA Project Team.

Modified: pkg/yuima/NEWS
===================================================================
--- pkg/yuima/NEWS	2010-07-29 04:24:26 UTC (rev 119)
+++ pkg/yuima/NEWS	2010-08-03 18:23:47 UTC (rev 120)
@@ -1,6 +1,13 @@
+Changes in Version 0.1.11
+
+  o time.variable was not copied in the env where drift and diffusion are 
+	evaluated. Fixed.
+  
+
 Changes in Version 0.1.10
 
-  o added an argument "expand.var" for functions related to asymptotic_term to specify the small variable "epsilon"
+  o added an argument "expand.var" for functions related to asymptotic_term to 
+	specify the small variable "epsilon"
 
 Changes in Version 0.1.09
 

Modified: pkg/yuima/R/CPoint.R
===================================================================
--- pkg/yuima/R/CPoint.R	2010-07-29 04:24:26 UTC (rev 119)
+++ pkg/yuima/R/CPoint.R	2010-08-03 18:23:47 UTC (rev 120)
@@ -47,7 +47,8 @@
 	 env$deltaX[t,] <- env$X[t+1,] - env$X[t,]
 	
 	assign("h", deltat(yuima at data@zoo.data[[1]]), env=env)
-	
+	assign("time", as.numeric(index(yuima at data@zoo.data[[1]])), env=env) 
+
 	QL1 <- pminusquasilogl(yuima=yuima, param=param1, print=print, env)
 	QL2 <- pminusquasilogl(yuima=yuima, param=param2, print=print, env)
 

Modified: pkg/yuima/R/qmle.R
===================================================================
--- pkg/yuima/R/qmle.R	2010-07-29 04:24:26 UTC (rev 119)
+++ pkg/yuima/R/qmle.R	2010-08-03 18:23:47 UTC (rev 120)
@@ -19,17 +19,19 @@
 	n <- dim(env$X)[1]
 	
 	drift <- matrix(0,n,d.size)
+	tmp.env <- new.env()
+	assign(yuima at model@time.variable, env$time, env=tmp.env)
+
 	
-	
 	for(i in 1:length(theta)){
-		assign(names(theta)[i],theta[[i]])
+		assign(names(theta)[i],theta[[i]], env=tmp.env)
 	}
 	
 	for(d in 1:d.size){
-		assign(modelstate[d], env$X[,d])
+		assign(modelstate[d], env$X[,d], env=tmp.env)
 	}
 	for(d in 1:d.size){
-		drift[,d] <- eval(DRIFT[d])
+		drift[,d] <- eval(DRIFT[d], env=tmp.env)
 	}
 
 	return(drift)  
@@ -43,19 +45,20 @@
 	DIFFUSION <- yuima at model@diffusion
 #	n <- length(yuima)[1]
 	n <- dim(env$X)[1]
-
+    tmp.env <- new.env()
+	assign(yuima at model@time.variable, env$time, env=tmp.env)
 	diff <- array(0, dim=c(d.size, r.size, n))
 	for(i in 1:length(theta)){
-		assign(names(theta)[i],theta[[i]])
+		assign(names(theta)[i],theta[[i]],env=tmp.env)
 	}
 
 	for(d in 1:d.size){
-		assign(modelstate[d], env$X[,d])
+		assign(modelstate[d], env$X[,d], env=tmp.env)
 	}
 
 	for(r in 1:r.size){
 		for(d in 1:d.size){
-			diff[d, r, ] <- eval(DIFFUSION[[d]][r])
+			diff[d, r, ] <- eval(DIFFUSION[[d]][r], env=tmp.env)
 		}
 	}
 	return(diff)
@@ -134,9 +137,7 @@
 		yuima.stop("some named arguments in 'start' are not arguments to the supplied yuima model")
     start <- start[order(oo)]
     nm <- names(start)
-	
-	 
-	 
+		 
 	idx.diff <- match(diff.par, nm)
 	idx.drift <- match(drift.par, nm)
 	idx.fixed <- match(fixed.par, nm)
@@ -170,6 +171,7 @@
 	env <- new.env()
 	assign("X",  as.matrix(onezoo(yuima)), env=env)
 	assign("deltaX",  matrix(0, n-1, d.size), env=env)
+	assign("time", as.numeric(index(yuima at data@zoo.data[[1]])), env=env) 
 	for(t in 1:(n-1))
 	 env$deltaX[t,] <- env$X[t+1,] - env$X[t,]
 
@@ -200,7 +202,6 @@
 	 rownames(HESS) <- nm
 	 HaveDriftHess <- FALSE
 	 HaveDiffHess <- FALSE
-	 
 	 if(length(start)){
 		if(JointOptim){ ### joint optimization
 			if(length(start)>1){ # multidimensional optim
@@ -236,7 +237,6 @@
 			mydots$fn <- as.name("f")
 			mydots$start <- NULL
 			mydots$par <- unlist(new.start)
-#		print(mydots)
 			mydots$hessian <- FALSE
 			mydots$upper <- unlist( upper[ nm[idx.diff] ])
 			mydots$lower <- unlist( lower[ nm[idx.diff] ])
@@ -248,7 +248,7 @@
 			 mydots$par <- NULL
 			 mydots$hessian <- NULL	
 			 mydots$method <- NULL	
-			 mydots$interval <- as.numeric(c(lower[diff.par],upper[diff.par])) 
+			 mydots$interval <- as.numeric(c(unlist(lower[diff.par]),unlist(upper[diff.par]))) 
 			 mydots$lower <- NULL	
 			 mydots$upper <- NULL	
 			 opt1 <- do.call(optimize, args=mydots)
@@ -405,7 +405,8 @@
 	env$deltaX[t,] <- env$X[t+1,] - env$X[t,]
 	
 	assign("h", deltat(yuima at data@zoo.data[[1]]), env=env)
-	
+	assign("time", as.numeric(index(yuima at data@zoo.data[[1]])), env=env) 
+
 	-minusquasilogl(yuima=yuima, param=param, print=print, env)
 }
 



More information about the Yuima-commits mailing list