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

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Fri Nov 24 17:18:47 CET 2017


Author: lorenzo
Date: 2017-11-24 17:18:46 +0100 (Fri, 24 Nov 2017)
New Revision: 631

Modified:
   pkg/yuima/DESCRIPTION
   pkg/yuima/R/AuxMethodforPPR.R
   pkg/yuima/R/lambdaPPR.R
   pkg/yuima/R/simulateForPpr.R
Log:
Updated Ppr

Modified: pkg/yuima/DESCRIPTION
===================================================================
--- pkg/yuima/DESCRIPTION	2017-11-22 11:39:56 UTC (rev 630)
+++ pkg/yuima/DESCRIPTION	2017-11-24 16:18:46 UTC (rev 631)
@@ -1,15 +1,15 @@
-Package: yuima
-Type: Package
-Title: The YUIMA Project Package for SDEs
-Version: 1.7.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
-Maintainer: Stefano M. Iacus <stefano.iacus at unimi.it>
-Description: Simulation and Inference for SDEs and Other Stochastic Processes.
-License: GPL-2
-URL: http://www.yuima-project.com
-LinkingTo: Rcpp, RcppArmadillo
-
-
-
+Package: yuima
+Type: Package
+Title: The YUIMA Project Package for SDEs
+Version: 1.7.4
+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
+Maintainer: Stefano M. Iacus <stefano.iacus at unimi.it>
+Description: Simulation and Inference for SDEs and Other Stochastic Processes.
+License: GPL-2
+URL: http://www.yuima-project.com
+LinkingTo: Rcpp, RcppArmadillo
+
+
+

Modified: pkg/yuima/R/AuxMethodforPPR.R
===================================================================
--- pkg/yuima/R/AuxMethodforPPR.R	2017-11-22 11:39:56 UTC (rev 630)
+++ pkg/yuima/R/AuxMethodforPPR.R	2017-11-24 16:18:46 UTC (rev 631)
@@ -16,8 +16,13 @@
   # if(is.nan(Integr1)){
   #   Integr1 <- -10^6
   # }
-  cond2 <- diff(as.numeric(my.envd3$YUIMA.PPR at data@original.data))
-  Integr2<- sum(log(IntLambda[-1][cond2!=0]),na.rm=TRUE)
+  if(length(my.envd3$YUIMA.PPR at Ppr@counting.var)>0){
+    cond1 <- my.envd3$YUIMA.PPR at model@solve.variable %in% my.envd3$YUIMA.PPR at Ppr@counting.var
+    cond2 <- diff(as.numeric(my.envd3$YUIMA.PPR at data@original.data[,cond1]))
+    Integr2<- sum(log(IntLambda[-1][cond2!=0]),na.rm=TRUE)
+  }else{
+    yuima.stop("Spal")
+  }
   # if(is.nan(Integr2)){
   #   Integr2 <- -10^6
   # }
@@ -86,7 +91,7 @@
 
     #CountingVariable
     for(i in c(1:length(yuimaPPr at Ppr@counting.var))){
-      cond <- yuimaPPr at Ppr@counting.var[i] %in% yuimaPPr at model@solve.variable
+      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)
     }
@@ -116,9 +121,11 @@
     assign("t.time",yuimaPPr at Kernel@variable.Integral at upper.var,envir=my.envd1)
 
     # Covariates
-    if(length(yuimaPPr at Ppr@covariates)>1){
+    if(length(yuimaPPr at Ppr@covariates)>0){
       # Covariates should be identified at jump time
-      return(NULL)
+      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)
     }
 
   }
@@ -130,7 +137,7 @@
 
     #CountingVariable
     for(i in c(1:length(yuimaPPr at Ppr@counting.var))){
-      cond <- yuimaPPr at Ppr@counting.var[i] %in% yuimaPPr at model@solve.variable
+      cond <- yuimaPPr at model@solve.variable %in% yuimaPPr at Ppr@counting.var[i]
       dummyData <-yuimaPPr at data@original.data[,cond]
       assign(yuimaPPr at Ppr@counting.var[i], dummyData,envir=my.envd1)
     }
@@ -145,10 +152,17 @@
   # construction my.envd3
 
   #Covariate
-
+  dimCov<-length(yuimaPPr at Ppr@covariates)
+  if(dimCov>0){
+    for(i in c(1:dimCov)){
+      cond <- yuimaPPr at model@solve.variable %in% yuimaPPr at Ppr@covariates[i] 
+      dummyData <- yuimaPPr at data@original.data[,cond]
+      assign(yuimaPPr at Ppr@covariates[i], dummyData,envir=my.envd3)
+    }
+  }
   #CountingVariable
   for(i in c(1:length(yuimaPPr at Ppr@counting.var))){
-    cond <- yuimaPPr at Ppr@counting.var[i] %in% yuimaPPr at model@solve.variable
+    cond <- yuimaPPr at model@solve.variable %in% yuimaPPr at Ppr@counting.var[i]
     dummyData <-cumsum(c(as.numeric(yuimaPPr at data@original.data[1,cond]!=0),as.numeric(diff(yuimaPPr at data@original.data[,cond])!=0)))
     assign(yuimaPPr at Ppr@counting.var[i], dummyData,envir=my.envd3)
   }

Modified: pkg/yuima/R/lambdaPPR.R
===================================================================
--- pkg/yuima/R/lambdaPPR.R	2017-11-22 11:39:56 UTC (rev 630)
+++ pkg/yuima/R/lambdaPPR.R	2017-11-24 16:18:46 UTC (rev 631)
@@ -102,7 +102,7 @@
         cond <- paste0("JumpTime.",NameCol[i]) %in% my.envd1$namedJumpTimeX
         assign(my.envd1$var.time,my.envd1[[my.envd1$namedJumpTimeX[cond]]],envir=my.envd1)
 
-        IntegralKernelDum<- sum(eval(Integrand2expr[cond], envir=my.envd1))
+        IntegralKernelDum<- sum(eval(Integrand2expr[cond], envir=my.envd1),na.rm = TRUE)
         IntegralKernel<-IntegralKernel+IntegralKernelDum
         #       cat("\n", IntegralKernel)
       }
@@ -240,12 +240,13 @@
         namedX<-c(namedX,paste0("d",yuimaPPr at Kernel@variable.Integral at var.dx[i]))
         namedJumpTimeX <-c(namedJumpTimeX,paste0("JumpTime.d",yuimaPPr at Kernel@variable.Integral at var.dx[i]))
         dummyData <- diff(as.numeric(yuimaPPr at data@original.data[,cond]))# We consider only Jump
-        dummyJumpTime <- gridTime[-1][dummyData>0]
+        #dummyJumpTime <- gridTime[-1][dummyData>0]
+        dummyJumpTime <- gridTime[-1][dummyData!=0]
         dummyData2 <- diff(unique(cumsum(dummyData)))
         #dummyData3 <- zoo(dummyData2,order.by = dummyJumpTime)
         dummyData3 <- dummyData2
         JumpTime <- dummyJumpTime
-        assign(paste0("d",yuimaPPr at Kernel@variable.Integral at var.dx[i]), dummyData3 ,envir=my.envd1)
+        assign(paste0("d",yuimaPPr at Kernel@variable.Integral at var.dx[i]), as.numeric(dummyData3!=0) ,envir=my.envd1)
         assign(paste0("JumpTime.d",yuimaPPr at Kernel@variable.Integral at var.dx[i]), dummyJumpTime ,envir=my.envd1)
       }
     }
@@ -284,6 +285,14 @@
   # construction my.envd3
 
   #Covariate
+  dimCov <- length(yuimaPPr at Ppr@covariates)
+  if(dimCov>0){
+    for(j in c(1:dimCov)){
+      cond <- yuimaPPr at Ppr@covariates[j] %in% yuimaPPr at model@solve.variable
+      dummyData <-yuimaPPr at data@original.data[,cond]
+      assign(yuimaPPr at Ppr@covariates[j], dummyData,envir=my.envd3)  
+    }
+  }
 
   #CountingVariable
   for(i in c(1:length(yuimaPPr at Ppr@counting.var))){

Modified: pkg/yuima/R/simulateForPpr.R
===================================================================
--- pkg/yuima/R/simulateForPpr.R	2017-11-22 11:39:56 UTC (rev 630)
+++ pkg/yuima/R/simulateForPpr.R	2017-11-24 16:18:46 UTC (rev 631)
@@ -57,6 +57,7 @@
   Int.Intens <- list()
   for(i in c(1:numb.Int)){
     dum.g <- as.character(g.Fun[i])
+    dum.g <- paste("tail(",dum.g,", n=1L)")
     dum.Ker <- as.character(Kern.Fun at Integrand@IntegrandList[[i]])
     dif.dx <- paste("d",Kern.Fun at variable.Integral@var.dx, sep="")
     dum.Ker <- paste(dum.Ker,dif.dx, sep = "*")
@@ -274,6 +275,15 @@
             envir = my.env)
         }
 
+        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)
+          }
+        }
+        
         compErrHazR2 <- function(simMod, Kern,
                                  capitalTime, Model, my.env, ExprHaz,
                                  Time, dN){
@@ -328,18 +338,36 @@
               if(i>=dimGrid){
                 noExit <- FALSE
               }
+              if(i<=dim(simMod at data@original.data)[1]){  
+              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:i,object at Ppr@covariates[j]]),
+                           envir = my.env)
+                  }
+                }  
+            
 
-              cat("\n ", cond>0, i, grid[i])
+              
+              cat("\n ", i, grid[i])
+              }
             }
-            jumpT<-c(jumpT,grid[i])
-            dN<-c(dN,1)
-            allhaz <- c(allhaz,HazardRate)
-            allcond <- c(allcond,cond)
-            cond <- const
-            allconst <- c(allconst, const)
-            const <- -log(runif(1))
-            while(const<delta){
+            if(i<=dim(simMod at data@original.data)[1]){ 
+              jumpT<-c(jumpT,grid[i])
+              # if(i==7001){
+              #   cat("\n",noExit)
+              # }
+              dN<-c(dN,1)
+              allhaz <- c(allhaz,HazardRate)
+              allcond <- c(allcond,cond)
+              cond <- const
+              allconst <- c(allconst, const)
               const <- -log(runif(1))
+              while(const<delta){
+                const <- -log(runif(1))
+              }
             }
           }
           return(list(jumpT=jumpT,allcond=allcond,allconst=allconst, allhaz=allhaz))



More information about the Yuima-commits mailing list