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

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Tue Jan 17 10:37:44 CET 2017


Author: lorenzo
Date: 2017-01-17 10:37:44 +0100 (Tue, 17 Jan 2017)
New Revision: 569

Modified:
   pkg/yuima/DESCRIPTION
   pkg/yuima/R/AuxMethodforPPR.R
   pkg/yuima/R/simulateForPpr.R
Log:
fixed bugs PPR

Modified: pkg/yuima/DESCRIPTION
===================================================================
--- pkg/yuima/DESCRIPTION	2017-01-17 06:09:34 UTC (rev 568)
+++ pkg/yuima/DESCRIPTION	2017-01-17 09:37:44 UTC (rev 569)
@@ -1,14 +1,14 @@
-Package: yuima
-Type: Package
-Title: The YUIMA Project Package for SDEs
-Version: 1.4.6
-Depends: R(>= 2.10.0), methods, zoo, stats4, utils, expm, cubature, mvtnorm
-Imports: Rcpp (>= 0.12.1)
-Author: YUIMA Project Team
-Maintainer: Stefano M. Iacus <stefano.iacus at unimi.it>
-Description: Simulation and Inference for Stochastic Differential Equations.
-License: GPL-2
-URL: http://R-Forge.R-project.org/projects/yuima/
-LinkingTo: Rcpp
-
-
+Package: yuima
+Type: Package
+Title: The YUIMA Project Package for SDEs
+Version: 1.4.7
+Depends: R(>= 2.10.0), methods, zoo, stats4, utils, expm, cubature, mvtnorm
+Imports: Rcpp (>= 0.12.1)
+Author: YUIMA Project Team
+Maintainer: Stefano M. Iacus <stefano.iacus at unimi.it>
+Description: Simulation and Inference for Stochastic Differential Equations.
+License: GPL-2
+URL: http://R-Forge.R-project.org/projects/yuima/
+LinkingTo: Rcpp
+
+

Modified: pkg/yuima/R/AuxMethodforPPR.R
===================================================================
--- pkg/yuima/R/AuxMethodforPPR.R	2017-01-17 06:09:34 UTC (rev 568)
+++ pkg/yuima/R/AuxMethodforPPR.R	2017-01-17 09:37:44 UTC (rev 569)
@@ -249,14 +249,32 @@
   }
   dn <- dim(lambda)
   if(dn[1]==1){
-    # logLiklihood2 <- -sum(lambda[,-1]*diff(time)[1])
-    # logLiklihood1 <- sum(log(lambda[,-1])*lastEnv$Integrator)
     logLiklihood2 <- -sum(lambda*diff(time)[1])
-    # CountProc <- diff(as.numeric(lastEnv$CountVar))!=0
     logLiklihood1 <- sum(log(lambda)*lastEnv$CountVar)
 
+    # logLiklihood2 <- -sum(lambda*diff(time))
+    # dummyLamb <- lambda[lastEnv$CountVar]
+    # #logLiklihood1 <- sum(log(dummyLamb[-length(dummyLamb)]))
+    # logLiklihood1 <- sum(log(dummyLamb))
 
+
+    # newlamb <- unique(as.numeric(lambda))
+    #
+    # cond <- as.numeric(lastEnv$CountVar)!=0
+    # timeJ <- time[-1][cond]
+    # timeJ1 <- unique(c(0,timeJ,lastEnv$t[1]))
+    # logLiklihood2 <- -sum(newlamb*diff(timeJ1))
+    # InternCount<-c(0:length(timeJ))
+    # if((length(timeJ)+2)==length(timeJ1)){
+    #   InternCount <- c(InternCount,tail(InternCount, n=1L))
+    # }
+    #
+    # logLiklihood1 <- sum(log(newlamb)*diff(InternCount))
+
+
   }else{
+    #### NO Rewrite
+
     # logLiklihood2 <- -rowSums(lambda[,-1]*diff(time)[1])
     # logLiklihood1 <- rowSums(log(lambda[,-1])*lastEnv$Integrator)
     logLiklihood2 <- -rowSums(lambda*diff(time)[1])

Modified: pkg/yuima/R/simulateForPpr.R
===================================================================
--- pkg/yuima/R/simulateForPpr.R	2017-01-17 06:09:34 UTC (rev 568)
+++ pkg/yuima/R/simulateForPpr.R	2017-01-17 09:37:44 UTC (rev 569)
@@ -45,8 +45,7 @@
           }
 )
 
-constHazIntPr <- function(g.Fun = object at gFun@formula,
-                          Kern.Fun = object at Kernel){
+constHazIntPr <- function(g.Fun , Kern.Fun){
   numb.Int <- length(g.Fun)
   Int.Intens <- list()
   for(i in c(1:numb.Int)){
@@ -295,8 +294,8 @@
             }
             oldprova <- prova
             prova <- SolvePpr(posMid, posLeft, posRight, solveLeft, solveRight,
-                              cost, Kern, simMod, samp, Model, ExprHaz, dN,
-                              LastTime, my.env, Time, IntensityProc)
+                              cost, Kern, simMod, samp, Model, ExprHaz,
+                               my.env, Time, IntensityProc)
             if(length(prova$left)==0){
               globEx <- TRUE
             }else{
@@ -367,8 +366,8 @@
 }
 
 SolvePpr <- function(posMid, posLeft, posRight, solveLeft = NULL, solveRight = NULL,
-                     cost, Kern, simMod, samp, Model, ExprHaz, dN,
-                     LastTime, my.env, Time, IntensityProc){
+                     cost, Kern, simMod, samp, Model, ExprHaz,
+                      my.env, Time, IntensityProc){
 
   if((posMid+1)>=(samp at n+1)){
     mylist <- list(VeryExit = TRUE)
@@ -707,16 +706,23 @@
     dN[con[c(1:length(dN))]] <- as.numeric(simMod at data@original.data[c(FALSE, con[-length(con)]),Kern at variable.Integral@var.dx]
                                                      -simMod at data@original.data[con,Kern at variable.Integral@var.dx])
   }else{}
-  for(i in c(1:TopposInGrid)){
+  #for(i in c(1:TopposInGrid)){
+  #MyPos
+  MyPos <- sum(samp at grid[[1]]<=tail(Time,n=1L))
+  #dummyLambda <- numeric(length=TopposInGrid)
+  assign(Kern at variable.Integral@var.time, Time, envir = my.env)
+  for(i in c(MyPos:TopposInGrid)){
     posInGrid <- i
     LastTime <- samp at grid[[1]][-1][(posInGrid)]
-    LastStime <- samp at grid[[1]][c(1:posInGrid)]
+    #LastStime <- samp at grid[[1]][c(1:posInGrid)]
     assign(Model at time.variable, LastTime, envir = my.env)
-    assign(Kern at variable.Integral@var.time, LastStime, envir = my.env)
-    assign(paste0("d",Kern at variable.Integral@var.dx), dN[c(1:posInGrid)], envir =my.env)
+    #assign(Kern at variable.Integral@var.time, LastStime, envir = my.env)
+    #assign(paste0("d",Kern at variable.Integral@var.dx), dN[c(1:posInGrid)], envir =my.env)
+    assign(paste0("d",Kern at variable.Integral@var.dx), 1, envir =my.env)
     dummyLambda[i] <- eval(ExprHaz[[1]], envir=my.env)
   }
-  solveLambda <- -log(cost)-sum(dummyLambda[c(sum(samp at grid[[1]]<=tail(Time,n=1L)):(TopposInGrid))])*samp at delta
+ # solveLambda <- -log(cost)-sum(dummyLambda[c(sum(samp at grid[[1]]<=tail(Time,n=1L)):(TopposInGrid))])*samp at delta
+  solveLambda <- -log(cost)-sum(dummyLambda[c(MyPos:(TopposInGrid))])*samp at delta
   res <- list(solveLambda = solveLambda, dummyLambda = tail(dummyLambda,n=1L))
   return(res)
 }



More information about the Yuima-commits mailing list