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

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Thu Jul 12 13:21:33 CEST 2018


Author: lorenzo
Date: 2018-07-12 13:21:33 +0200 (Thu, 12 Jul 2018)
New Revision: 669

Modified:
   pkg/yuima/R/AuxMethodforPPR.R
Log:


Modified: pkg/yuima/R/AuxMethodforPPR.R
===================================================================
--- pkg/yuima/R/AuxMethodforPPR.R	2018-07-12 10:35:24 UTC (rev 668)
+++ pkg/yuima/R/AuxMethodforPPR.R	2018-07-12 11:21:33 UTC (rev 669)
@@ -82,21 +82,22 @@
   dimIntegr <- length(yuimaPPR at Kernel@Integrand at IntegrandList)
   Integrand2 <- character(length=dimIntegr)
   for(i in c(1:dimIntegr)){
-    Integrand1 <- as.character(yuimaPPR at Kernel@Integrand at IntegrandList[[i]])
-    timeCond <- paste0(" * (",yuimaPPR at Kernel@variable.Integral at var.time," < ",yuimaPPR at Kernel@variable.Integral at upper.var,")")
-    Integrand2[i] <-paste0(Integrand1,timeCond)
+    #Integrand1 <- as.character(yuimaPPR at Kernel@Integrand at IntegrandList[[i]])
+    #timeCond <- paste0(" * (",yuimaPPR at Kernel@variable.Integral at var.time," < ",yuimaPPR at Kernel@variable.Integral at upper.var,")")
+    #Integrand2[i] <-paste0(Integrand1,timeCond)
+    Integrand2[i] <- as.character(yuimaPPR at Kernel@Integrand at IntegrandList[[i]])
   }
 
   Integrand2<- matrix(Integrand2,yuimaPPR at Kernel@Integrand at dimIntegrand[1],yuimaPPR at Kernel@Integrand at dimIntegrand[2])
 
 
-  for(j in c(1:yuimaPPR at Kernel@Integrand at dimIntegrand[2])){
-    Integrand2[,j]<-paste0(Integrand2[,j]," * d",yuimaPPR at Kernel@variable.Integral at var.dx[j])
-  }
+  # for(j in c(1:yuimaPPR at Kernel@Integrand at dimIntegrand[2])){
+  #   Integrand2[,j]<-paste0(Integrand2[,j]," * d",yuimaPPR at Kernel@variable.Integral at var.dx[j])
+  # }
   colnames(Integrand2) <- paste0("d",yuimaPPR at Kernel@variable.Integral at var.dx)
   NamesIntegrandExpr <- as.character(matrix(colnames(Integrand2), dim(Integrand2)[1],dim(Integrand2)[2], byrow = TRUE))
   # Integrand2expr<- parse(text=Integrand2)
-  
+
   if(yuimaPPR at Kernel@Integrand at dimIntegrand[1]==1){
     Integrand2expr<- parse(text=Integrand2)
   }else{
@@ -151,9 +152,15 @@
         dummyData2 <- diff(unique(cumsum(dummyData)))
         #dummyData3 <- zoo(dummyData2,order.by = dummyJumpTime)
         dummyData3 <- rep(1,length(dummyData2))
-        JumpTime <- dummyJumpTime
-        assign(paste0("d",yuimaPPR at Kernel@variable.Integral at var.dx[i]), dummyData3 ,envir=my.envd1)
-        assign(paste0("JumpTime.d",yuimaPPR at Kernel@variable.Integral at var.dx[i]), dummyJumpTime ,envir=my.envd1)
+        #JumpTime <- dummyJumpTime
+        Jump <- lapply(X=as.numeric(gridTime), FUN = function(X,JumpT,Jump){Jump[JumpT<X]},
+                       JumpT = dummyJumpTime, Jump = as.numeric(dummyData3!=0))
+        assign(paste0("d",yuimaPPR at Kernel@variable.Integral at var.dx[i]), 
+               Jump ,
+               envir=my.envd1)
+        dummyJumpTimeNew <- lapply(X=as.numeric(gridTime), FUN = function(X,JumpT){JumpT[JumpT<X]},
+                                   JumpT = dummyJumpTime)
+        assign(paste0("JumpTime.d",yuimaPPR at Kernel@variable.Integral at var.dx[i]), dummyJumpTimeNew ,envir=my.envd1)
       }
     }
     assign("namedX",namedX, envir = my.envd1)
@@ -162,21 +169,45 @@
     assign("t.time",yuimaPPR at Kernel@variable.Integral at upper.var,envir=my.envd1)
     
     #CountingVariable
+    PosListCountingVariable <- NULL
     for(i in c(1:length(yuimaPPR at PPR@counting.var))){
+      # cond <- yuimaPPR at model@solve.variable %in% yuimaPPR at PPR@counting.var[i]
+      # dummyData <-unique(yuimaPPR at data@original.data[,cond])[-1]
+      # assign(yuimaPPR at PPR@counting.var[i], rep(1,length(dummyData)),envir=my.envd1)
       cond <- yuimaPPR at model@solve.variable %in% yuimaPPR at PPR@counting.var[i]
-      dummyData <-unique(yuimaPPR at data@original.data[,cond])[-1]
-      assign(yuimaPPR at PPR@counting.var[i], rep(1,length(dummyData)),envir=my.envd1)
+      #JUMPTIME <- tail(my.envd1$JumpTime.dN,1L)[[1]]
+      JUMPTIME <- tail(my.envd1[[paste0("JumpTime.d",yuimaPPR at Kernel@variable.Integral at var.dx[i])]],1L)[[1]]
+      condTime <- gridTime %in% JUMPTIME 
+      
+      dummyData <- yuimaPPR at data@original.data[condTime,cond]
+      dummyDataA <- lapply(X=as.numeric(gridTime), FUN = function(X,JumpT,Jump){Jump[JumpT<X]},
+                           JumpT = JUMPTIME, Jump = dummyData)
+      dummyList <- paste0("List_",yuimaPPR at PPR@counting.var[i])
+      PosListCountingVariable <- c(PosListCountingVariable,dummyList)
+      assign(dummyList, dummyDataA, envir=my.envd1)
+      assign(yuimaPPR at PPR@counting.var[i], numeric(length=0L), envir=my.envd1)
     }
+    assign("PosListCountingVariable", PosListCountingVariable, envir=my.envd1)
     
-    
     # Covariates
     if(length(yuimaPPR at PPR@covariates)>0){
       # Covariates should be identified at jump time
+      PosListCovariates <- NULL
       for(i in c(1:length(yuimaPPR at PPR@covariates))){
-        cond <- yuimaPPR at model@solve.variable %in% yuimaPPR at PPR@covariates[i]
-        condTime <- gridTime %in% my.envd1$JumpTime.dN
-        assign(yuimaPPR at PPR@covariates[i],yuimaPPR at data@original.data[condTime,cond],envir = my.envd1)
+        # cond <- yuimaPPR at model@solve.variable %in% yuimaPPR at PPR@covariates[i]
+        # condTime <- gridTime %in% my.envd1$JumpTime.dN
+        # assign(yuimaPPR at PPR@covariates[i],yuimaPPR at data@original.data[condTime,cond],envir = my.envd1)
+        cond <- yuimaPPR at model@solve.variable %in% yuimaPPR at PPR@covariates[i]  
+        #dummyData <-yuimaPPR at data@original.data[,cond]
+        dummyData <- yuimaPPR at data@original.data[condTime, cond]
+        dummyDataB <- lapply(X=as.numeric(gridTime), FUN = function(X,JumpT,Jump){Jump[JumpT<X]},
+                             JumpT = JUMPTIME, Jump = dummyData)
+        dummyListCov <- paste0("List_",yuimaPPR at PPR@covariates[i])
+        PosListCovariates <- c(PosListCovariates,dummyListCov)
+        assign(dummyListCov, dummyDataB,envir=my.envd1)
+        assign(yuimaPPR at PPR@covariates[i], numeric(length=0L),envir=my.envd1)
       }
+      assign("PosListCovariates", PosListCovariates,envir=my.envd1)
     }
 
   }
@@ -260,7 +291,13 @@
   assign("Integrand2",Integrand2,envir=my.envd3)
   assign("Integrand2expr",Integrand2expr,envir=my.envd3)
 
-  assign("gridTime",as.numeric(gridTime),envir=my.envd3)
+#  assign("gridTime",as.numeric(gridTime),envir=my.envd3)
+  l1 =as.list(as.numeric(gridTime))
+  l2 = as.list(c(1:length(l1)))
+  l3 = mapply(c, l1, l2, SIMPLIFY=FALSE)
+  
+  assign("gridTime",l3,envir=my.envd3)
+  
   assign("Univariate",Univariate,envir=my.envd3)
   assign("ExistdN",ExistdN,envir=my.envd3)
   assign("ExistdX",ExistdX,envir=my.envd3)



More information about the Yuima-commits mailing list