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

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Thu May 31 05:16:06 CEST 2018


Author: lorenzo
Date: 2018-05-31 05:16:05 +0200 (Thu, 31 May 2018)
New Revision: 655

Modified:
   pkg/yuima/DESCRIPTION
   pkg/yuima/R/simulateForPpr.R
Log:
Simulate PPR improved

Modified: pkg/yuima/DESCRIPTION
===================================================================
--- pkg/yuima/DESCRIPTION	2018-05-30 14:03:41 UTC (rev 654)
+++ pkg/yuima/DESCRIPTION	2018-05-31 03:16:05 UTC (rev 655)
@@ -1,7 +1,7 @@
 Package: yuima
 Type: Package
 Title: The YUIMA Project Package for SDEs
-Version: 1.8.2
+Version: 1.8.3
 Depends: R(>= 2.10.0), methods, zoo, stats4, utils, expm, cubature, mvtnorm
 Imports: Rcpp (>= 0.12.1), boot (>= 1.3-2)
 Author: YUIMA Project Team

Modified: pkg/yuima/R/simulateForPpr.R
===================================================================
--- pkg/yuima/R/simulateForPpr.R	2018-05-30 14:03:41 UTC (rev 654)
+++ pkg/yuima/R/simulateForPpr.R	2018-05-31 03:16:05 UTC (rev 655)
@@ -92,16 +92,17 @@
       for(i in c(1:length(counting.var))){
         my.countOld <- paste0(counting.var[i] ," ")
         my.countNew <- paste0( counting.var[i] ,
-                              "[ as.character( ",Kern.Fun at variable.Integral@var.time ," ) ]")
+                              "[CondJumpGrid]")
         dum.Ker <- gsub(my.countOld, my.countNew, x = dum.Ker, fixed=TRUE)
         my.countOld <- paste0(counting.var[i] ,"[",Kern.Fun at variable.Integral@upper.var,"]")
-        my.countNew <- paste0( counting.var[i] ,
-                              "[ as.character( ",Kern.Fun at variable.Integral@upper.var ," ) ]")
+        # my.countNew <- paste0( counting.var[i] ,
+        #                       "[ as.character( ",Kern.Fun at variable.Integral@upper.var ," ) ]")
+        my.countNew <- paste0( "tail(",counting.var[i] ,",n=1L) ")
         dum.Ker <- gsub(my.countOld, my.countNew, x = dum.Ker, fixed=TRUE)
         
         my.countOld <- paste0(counting.var[i] ,"[",Kern.Fun at variable.Integral@var.time,"]")
         my.countNew <- paste0(counting.var[i] ,
-                              "[ as.character( ",Kern.Fun at variable.Integral@var.time ," ) ]")
+                              "[CondJumpGrid]")
         dum.Ker <- gsub(my.countOld, my.countNew, x = dum.Ker, fixed=TRUE)
         
       }
@@ -111,17 +112,16 @@
         
         my.countOld <- paste0(covariates[i] ," ")
         my.countNew <- paste0( covariates[i] ,
-                              "[ as.character( ",Kern.Fun at variable.Integral@var.time ," ) ]")
+                              "[CondJumpGrid]")
         dum.Ker <- gsub(my.countOld, my.countNew, x = dum.Ker, fixed=TRUE)
         
         my.countOld <- paste0(covariates[i] ,"[",Kern.Fun at variable.Integral@upper.var,"]")
-        my.countNew <- paste0( covariates[i] ,
-                              "[ as.character( ",Kern.Fun at variable.Integral@upper.var ," ) ]")
+        my.countNew <- paste0("tail(", covariates[i] , " n=1L ) ")
         dum.Ker <- gsub(my.countOld, my.countNew, x = dum.Ker, fixed=TRUE)
         
         my.countOld <- paste0(covariates[i] ,"[",Kern.Fun at variable.Integral@var.time,"]")
         my.countNew <- paste0( covariates[i] ,
-                              "[ as.character( ",Kern.Fun at variable.Integral@var.time ," ) ]")
+                              "[CondJumpGrid]")
         dum.Ker <- gsub(my.countOld, my.countNew, x = dum.Ker, fixed=TRUE)
       }
     }
@@ -210,16 +210,16 @@
           
           if (dimCov>0){
             for(j in c(1:dimCov)){
-              my.covdata <- simMod at data@original.data[1:i,object at PPR@covariates[j]]
-              names(my.covdata) <-simMod at sampling@grid[[1]][1:i]
+              # my.covdata <- simMod at data@original.data[1:i,object at PPR@covariates[j]]
+              # names(my.covdata) <-simMod at sampling@grid[[1]][1:i]
+              # 
+              # assign(object at PPR@covariates[j],
+              #        my.covdata,
+              #        envir = my.env)
               
               assign(object at PPR@covariates[j],
-                     my.covdata,
+                     as.numeric(simMod at data@original.data[1:i,object at PPR@covariates[j]]),
                      envir = my.env)
-              
-              # assign(object at PPR@covariates[j],
-              #        as.numeric(simMod at data@original.data[1:i,object at PPR@covariates[j]]),
-              #        envir = my.env)
             }
           }  
           
@@ -238,7 +238,7 @@
         }else{
           dN <- c(dN,1)
         }
-        names(dN)<-jumpT
+        #names(dN)<-jumpT
         allhaz <- c(allhaz,HazardRate)
         allcond <- c(allcond,cond)
         cond <- const
@@ -265,10 +265,10 @@
       assign(Model at time.variable, capitalTime, envir = my.env)
       assign(paste0("d",Kern at variable.Integral@var.dx), dN, envir =my.env)
       
-      # condPointIngrid <- simMod at sampling@grid[[1]]<=my.env$t
-      # PointIngridInt <- simMod at sampling@grid[[1]][condPointIngrid]
-      # CondJumpGrid <- PointIngridInt %in% my.env$s 
-      # assign("CondJumpGrid", CondJumpGrid, envir = my.env)
+      condPointIngrid <- simMod at sampling@grid[[1]]<=my.env$t
+      PointIngridInt <- simMod at sampling@grid[[1]][condPointIngrid]
+      CondJumpGrid <- PointIngridInt %in% my.env$s
+      assign("CondJumpGrid", CondJumpGrid, envir = my.env)
       
       Lambda <- eval(ExprHaz[[1]], envir=my.env)
       return(Lambda)
@@ -452,15 +452,16 @@
         dimCov <- length(object at PPR@covariates)
         if (dimCov>0){
           for(j in c(1:dimCov)){
-              # assign(object at PPR@covariates[j],
-              #      as.numeric(simMod at data@original.data[1,object at PPR@covariates[j]]),
-              #      envir = my.env)
-            my.covdata <- simMod at data@original.data[1,object at PPR@covariates[j]]
-            names(my.covdata) <-simMod at sampling@grid[[1]][1]
-            
-            assign(object at PPR@covariates[j],
-                   my.covdata,
+              assign(object at PPR@covariates[j],
+                   as.numeric(simMod at data@original.data[1,object at PPR@covariates[j]]),
                    envir = my.env)
+
+            # my.covdata <- simMod at data@original.data[1,object at PPR@covariates[j]]
+            # names(my.covdata) <-simMod at sampling@grid[[1]][1]
+            # 
+            # assign(object at PPR@covariates[j],
+            #        my.covdata,
+            #        envir = my.env)
             
           }
         }



More information about the Yuima-commits mailing list