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

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Sat Jul 24 00:02:38 CEST 2010


Author: hinohide
Date: 2010-07-24 00:02:37 +0200 (Sat, 24 Jul 2010)
New Revision: 118

Modified:
   pkg/yuima/DESCRIPTION
   pkg/yuima/NEWS
   pkg/yuima/R/asymptotic_term.R
   pkg/yuima/R/simFunctional.R
   pkg/yuima/man/asymptotic_term.Rd
   pkg/yuima/man/simFunctional.Rd
Log:
modified files related to asymptotic_term

Modified: pkg/yuima/DESCRIPTION
===================================================================
--- pkg/yuima/DESCRIPTION	2010-07-23 13:04:02 UTC (rev 117)
+++ pkg/yuima/DESCRIPTION	2010-07-23 22:02:37 UTC (rev 118)
@@ -1,8 +1,8 @@
 Package: yuima
 Type: Package
 Title: The YUIMA Project package (unstable version)
-Version: 0.1.09
-Date: 2010-07-23
+Version: 0.1.10
+Date: 2010-07-24
 Depends: methods, zoo, stats4, utils
 Suggests: cubature, mvtnorm
 Author: YUIMA Project Team.

Modified: pkg/yuima/NEWS
===================================================================
--- pkg/yuima/NEWS	2010-07-23 13:04:02 UTC (rev 117)
+++ pkg/yuima/NEWS	2010-07-23 22:02:37 UTC (rev 118)
@@ -1,3 +1,7 @@
+Changes in Version 0.1.10
+
+  o added an argument "expand.var" for functions related to asymptotic_term to specify the small variable "epsilon"
+
 Changes in Version 0.1.09
 
   o fixed toLatex() output for diffusion matrix

Modified: pkg/yuima/R/asymptotic_term.R
===================================================================
--- pkg/yuima/R/asymptotic_term.R	2010-07-23 13:04:02 UTC (rev 117)
+++ pkg/yuima/R/asymptotic_term.R	2010-07-23 22:02:37 UTC (rev 118)
@@ -2,11 +2,11 @@
 
 
 setGeneric("asymptotic_term",
-           function(yuima,block=100, rho, g)
+           function(yuima,block=100, rho, g, expand.var="e")
            standardGeneric("asymptotic_term")
            )
 
-setMethod("asymptotic_term",signature(yuima="yuima"), function(yuima,block=100, rho, g){
+setMethod("asymptotic_term",signature(yuima="yuima"), function(yuima,block=100, rho, g, expand.var="e"){
 
   if(is.null(yuima at model)) stop("model object is missing!")
   if(is.null(yuima at sampling)) stop("sampling object is missing!")
@@ -14,7 +14,11 @@
     
   f <- getf(yuima at functional)
   F <- getF(yuima at functional)
-  e <- gete(yuima at functional)
+
+  ##:: fix bug 07/23
+  #e <- gete(yuima at functional)
+  assign(expand.var, gete(yuima at functional))
+  
   Terminal <- yuima at sampling@Terminal
   division <- yuima at sampling@n
   xinit <- getxinit(yuima at functional)
@@ -25,10 +29,12 @@
   d.size <- yuima at model@equation.number
   k.size <- length(F)
 
-  X.t0 <- Get.X.t0(yuima)
+  X.t0 <- Get.X.t0(yuima, expand.var=expand.var)
   delta <- deltat(X.t0)
-  pars <- yuima at model@parameter at all[1]  #epsilon
 
+  ##:: fix bug 07/23
+  pars <- expand.var #yuima at model@parameter at all[1]  #epsilon
+
   # function to return symbolic derivatives of myfunc by mystate(multi-state)
   Derivation.vector <- function(myfunc,mystate,dim1,dim2){
     tmp <- vector(dim1*dim2,mode="expression")

Modified: pkg/yuima/R/simFunctional.R
===================================================================
--- pkg/yuima/R/simFunctional.R	2010-07-23 13:04:02 UTC (rev 117)
+++ pkg/yuima/R/simFunctional.R	2010-07-23 22:02:37 UTC (rev 118)
@@ -1,6 +1,9 @@
 # funcF
 # function to calculate F in (13.2)
-funcF <- function(yuima,X,e){ 
+funcF <- function(yuima,X,e,expand.var="e"){
+            ##:: fix bug 07/23
+            assign(expand.var, e)
+  
             division <- yuima at sampling@n  #number of observed time
             F <- getF(yuima at functional)
             d.size <- yuima at model@equation.number
@@ -20,7 +23,10 @@
 
 # funcf
 # function to calculate fa in (13.2)
-funcf <- function(yuima,X,e){ 
+funcf <- function(yuima,X,e, expand.var){
+            ##:: fix bug 07/23
+            assign(expand.var, e)
+  
             division <- yuima at sampling@n  #number of observed time
             F <- getF(yuima at functional)
             f <- getf(yuima at functional)
@@ -47,7 +53,10 @@
 # funcFe.
 # function to calculate Fe in (13.2).
 # core function of 'simFunctional'
-funcFe. <- function(yuima,X,e){
+funcFe. <- function(yuima,X,e,expand.var="e"){
+            ##:: fix bug 07/23
+            assign(expand.var, e) ## expand.var
+            
             F <- getF(yuima at functional)
             r.size <- yuima at model@noise.number
             d.size <- yuima at model@equation.number
@@ -65,8 +74,8 @@
               dw[,r] <- tmp[2:division]-tmp[1:(division-1)] #calculate dWr(t)
             }
             
-            resF <- funcF(yuima,X,e) #calculate F with X,e. size:vector[k.size]
-            resf <- funcf(yuima,X,e) #calculate f with X,e. size:array[k.size,division,r.size+1]
+            resF <- funcF(yuima,X,e,expand.var=expand.var) #calculate F with X,e. size:vector[k.size]
+            resf <- funcf(yuima,X,e,expand.var=expand.var) #calculate f with X,e. size:array[k.size,division,r.size+1]
             
             Fe <- numeric(k.size)
             for(k in 1:k.size){
@@ -77,7 +86,10 @@
 
 # Get.X.t0
 # function to calculate X(t=t0) using runge kutta method
-Get.X.t0 <- function(yuima){
+Get.X.t0 <- function(yuima, expand.var="e"){
+            ##:: fix bug 07/23
+            assign(expand.var,0)  ## epsilon=0
+  
             r.size <- yuima at model@noise.number
             d.size <- yuima at model@equation.number
             k.size <- length(getF(yuima at functional))
@@ -87,8 +99,10 @@
 
             Terminal <- yuima at sampling@Terminal
             division <- yuima at sampling@n
+
+            ##:: fix bug 07/23
+            #pars <- #yuima at model@parameter at all[1]  #epsilon
             
-            pars <- yuima at model@parameter at all[1]  #epsilon
             xinit <- getxinit(yuima at functional)
             ## init
             dt <- Terminal/division
@@ -99,7 +113,11 @@
             k2 <- numeric(d.size)
             k3 <- numeric(d.size)
             k4 <- numeric(d.size)
-            assign(pars,0)  ## epsilon==0
+
+            ##:: fix bug 07/23
+            #assign(pars,0) ## epsilon=0
+
+            
             ## runge kutta
             for(t in 1:division){
               ## k1
@@ -144,11 +162,11 @@
 # simFunctional
 # public function to calculate Fe in (13.2).
 setGeneric("simFunctional",
-           function(yuima)
+           function(yuima, expand.var="e")
            standardGeneric("simFunctional")
            )
 setMethod("simFunctional", signature(yuima="yuima"),
-          function(yuima){
+          function(yuima, expand.var="e"){
 		    Xlen <- length(yuima at data)
 			if(sum(Xlen != mean(Xlen)) != 0) {
 			  yuima.warn("All length must be same yet.")
@@ -160,35 +178,41 @@
             }
             
             e <- gete(yuima at functional)
-            
-            Fe <- funcFe.(yuima,as.matrix(onezoo(yuima)),e)
+
+            ##:: fix bug 07/23
+            Fe <- funcFe.(yuima,as.matrix(onezoo(yuima)),e,expand.var=expand.var)
             return(Fe)
           })
 
 # F0
 # public function to calculate Fe at e=0
 setGeneric("F0",
-           function(yuima)
+           function(yuima, expand.var="e")
            standardGeneric("F0")
            )
 setMethod("F0", signature(yuima="yuima"),
-          function(yuima){
-            
-            X.t0 <- Get.X.t0(yuima)
-            F0 <- funcFe.(yuima, X.t0, 0)
+          function(yuima, expand.var="e"){
+
+            ##:: fix bug 07/23
+            X.t0 <- Get.X.t0(yuima, expand.var=expand.var)
+            F0 <- funcFe.(yuima, X.t0, 0, expand.var=expand.var)
+
             return(F0)
           })
 
 # Fnorm
 # public function to calculate (Fe-F0)/e
 setGeneric("Fnorm",
-           function(yuima)
+           function(yuima, expand.var="e")
            standardGeneric("Fnorm")
            )
 setMethod("Fnorm", signature(yuima="yuima"),
-          function(yuima){
+          function(yuima, expand.var="e"){
             e <- gete(yuima at functional)
-            Fe <- simFunctional(yuima)
-            F0 <- F0(yuima)
+
+            ##:: fix bug 0723
+            Fe <- simFunctional(yuima, expand.var=expand.var)
+            F0 <- F0(yuima, expand.var=expand.var)
+            
             return((Fe-F0)/e)
           })

Modified: pkg/yuima/man/asymptotic_term.Rd
===================================================================
--- pkg/yuima/man/asymptotic_term.Rd	2010-07-23 13:04:02 UTC (rev 117)
+++ pkg/yuima/man/asymptotic_term.Rd	2010-07-23 22:02:37 UTC (rev 118)
@@ -5,13 +5,14 @@
 \title{asymptotic expansion of the expected value of the functional}
 \description{calculate the fisrt and second term of asymptotic expansion of the functional mean.}
 \usage{
-asymptotic_term(yuima, block=100, rho, g)
+asymptotic_term(yuima, block=100, rho, g, expand.var="e")
 }
 \arguments{
   \item{yuima}{an yuima object containing model and functional.}
   \item{block}{the number of trapezoids for integrals.}
   \item{rho}{specify discounting factor in mean integral.}
   \item{g}{arbitrary measurable function for mean integral.}
+  \item{expand.var}{default expand.var="e".}
 }
 \details{
 Calculate the first and second term of asymptotic expansion of the expected value of the functional associated with a sde. The returned value d0 + epsilon * d1 is approximation of the expected value.

Modified: pkg/yuima/man/simFunctional.Rd
===================================================================
--- pkg/yuima/man/simFunctional.Rd	2010-07-23 13:04:02 UTC (rev 117)
+++ pkg/yuima/man/simFunctional.Rd	2010-07-23 22:02:37 UTC (rev 118)
@@ -9,12 +9,13 @@
 \title{Calculate the value of functional}
 \description{Calculate the value of functional associated with sde by Euler scheme.}
 \usage{
-simFunctional(yuima)
-Fnorm(yuima)
-F0(yuima)
+simFunctional(yuima, expand.var="e")
+Fnorm(yuima, expand.var="e")
+F0(yuima, expand.var="e")
 }
 \arguments{
   \item{yuima}{a \code{yuima} object containing model, functional and data.}
+  \item{expand.var}{default expand.var="e".}
 }
 \details{
 Calculate the value of functional of interest. Fnorm returns normalized one, and F0 returns the value for the case small parameter epsilon = 0. In simFunctional and Fnorm, yuima MUST contains the 'data' slot (X in legacy version)



More information about the Yuima-commits mailing list