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

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Mon Nov 27 15:42:37 CET 2017


Author: lorenzo
Date: 2017-11-27 15:42:36 +0100 (Mon, 27 Nov 2017)
New Revision: 632

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


Modified: pkg/yuima/NAMESPACE
===================================================================
--- pkg/yuima/NAMESPACE	2017-11-24 16:18:46 UTC (rev 631)
+++ pkg/yuima/NAMESPACE	2017-11-27 14:42:36 UTC (rev 632)
@@ -1,253 +1,255 @@
-import("methods")
-
-##importFrom("stats", "end", "time", "start")
-importFrom("graphics", "plot")
-import("zoo")
-importFrom(stats, confint)
-import("stats4")
-import("expm")
-import("mvtnorm")
-import("cubature")
-
-importFrom(utils, toLatex)
-
-importFrom("graphics", "lines")
-importFrom("stats", "qchisq")
-importFrom("utils", "relist")
-
-importFrom(boot, boot) # added by YK on Sep. 9, 2017 
-#08/07/2016
-#exportPattern("^[[:alpha:]]+") # NEVER DO THIS AGAIN PLEASE!
-#cimport(RcppArmadillo)
-importFrom(Rcpp, evalCpp)
-#import(RcppArmadillo)
-# 03/07/2015
-importFrom(stats, time)
-importFrom(stats, ts)
-importFrom(stats, rnorm)
-importFrom(stats, na.omit)
-importFrom(stats, dgamma)
-importFrom(stats, optimHess)
-importFrom(stats, filter)
-importFrom(utils, tail)
-importFrom(utils, head)
-importFrom(stats, acf)
-importFrom(stats, fft)
-importFrom(stats, rexp)
-importFrom(stats, approx)
-importFrom(stats, arima0)
-importFrom(stats, frequency)
-importFrom(stats, D)
-importFrom(stats, integrate)
-importFrom(stats, rpois)
-importFrom(stats, runif)
-importFrom(stats, optim)
-importFrom(stats, optimize)
-importFrom(stats, deltat)
-importFrom(stats, pchisq)
-importFrom(stats, symnum)
-importFrom(stats, rchisq)
-importFrom(stats, rgamma)
-importFrom(stats, diffinv)
-importFrom(stats, pnorm)
-importFrom(stats, approxfun)
-importFrom(stats, qnorm)
-importFrom(stats, rbinom)
-importFrom(stats, constrOptim)
-importFrom(stats, dnorm)
-importFrom(stats, deriv)
-importFrom(graphics, points)
-importFrom(stats, end)
-importFrom(stats, start)
-importFrom(utils, str)
-importFrom(stats, sd)
-
-
-exportClasses("yuima",
-"yuima.data",
-"yuima.law",
-"yuima.sampling",
-"yuima.characteristic",
-"yuima.model",
-"model.parameter",
-"yuima.carma",
-"carma.info",
-"yuima.carma.qmle",
-"yuima.poisson",
-"yuima.qmle",
-"yuima.CP.qmle",
-"cogarch.info",
-"yuima.cogarch",
-"yuima.Map",
-"info.Map",
-"param.Map",
-"yuima.multimodel",
-"param.Integral",
-"variable.Integral",
-"Integrand",
-"Integral.sde",
-"yuima.Integral",
-"info.Ppr",
-"yuima.Ppr",
-"yuima.Hawkes"
-)
-
-exportMethods(
-"dim",
-"length",
-## "start",
-"plot",
-## "time",
-## "end",
-"simulate",
-"cce",
-"llag",
-"poisson.random.sampling",
-"get.zoo.data",
-"initialize",
-##              "ql",
-##              "rql",
-##              "ml.ql",
-"adaBayes",
-"lseBayes",
-"limiting.gamma",
-"getF",
-"getf",
-"getxinit",
-"gete",
-"simFunctional",
-"F0",
-"Fnorm",
-"asymptotic_term",
-#"cbind.yuima",
-"rand",
-"dens",
-"cdf",
-"quant",
-"char"
-#"rbind.yuima"
-)
-
-## function which we want to expose to the user
-## all other functions are used internally by the
-## package
-export(ybook)
-export(setYuima)
-export(setModel) ## builds sde model
-export(setData)
-export(setSampling)
-export(setCharacteristic)
-export(setCarma)
-export(setPoisson)
-export(setPpr)
-export(setHawkes)
-export(dconst)
-export(rconst)
-export(setLaw)
-export(setCogarch)
-export(setMap)
-#export(setMultiModel)
-export(setIntegral)
-
-export(dim)
-export(length)
-#export(start)
-export(plot)
-#export(time)
-#export(end)
-
-export(simulate) # simulates couple of processes
-export(subsampling)
-export(cce)
-export(llag)
-export(poisson.random.sampling)
-export(noisy.sampling)
-export(mpv)
-export(bns.test)
-export(hyavar) # asymptotic variance estimator for the Hayashi-Yoshida estimator
-export(lmm) # Oct. 10, 2015: local methods of moment estimator
-export(mllag) # Oct. 10, 2015: multiple lead-lag detector
-export(llag.test) # Sep. 9, 2017: testing the absence of lead-lag effects 
-
-export(get.zoo.data)
-
-##export(ql,rql,ml.ql)
-##export(rql)
-export(adaBayes)
-export(lseBayes)
-export(rIG, rNIG, rbgamma, rvgamma, rstable,rpts,rnts, rGIG, rGH) ## random number generators in rng.R
-export(dIG, dNIG, dbgamma, dvgamma, dGIG, dGH) ## pdfs in rng.R
-export(limiting.gamma)
-export(lambdaFromData)
-
-
-export(setFunctional)
-export(getF)
-export(getf)
-export(getxinit)
-export(gete)
-
-export(simFunctional)
-export(F0)
-export(Fnorm)
-export(asymptotic_term)
-
-##export(LSE)
-export(lse)
-
-export(qmle)
-export(quasilogl)
-export(phi.test)
-export(lasso)
-export(CPoint)
-export(qmleR)
-export(qmleL)
-export(qmleLevy)
-export(IC)
-
-
-export(Intensity.PPR)
-
-
-export(CarmaNoise) # Estimates the Levy in carma model
-export(gmm) # Estimation COGARCH(P,Q) using Method Of Moments
-export(cogarchNoise)
-export(Diagnostic.Cogarch)
-export(Diagnostic.Carma)
-
-# Methods
-export(rand)# random number generator of a Levy process specified by user
-export(dens)
-export(cdf)
-export(quant)
-export(char)
-
-
-export(qgv)
-export(mmfrac)
-
-#export(cbind.yuima)
-#export(rbind.yuima)
-S3method(print, phitest)
-S3method(print, qgv)
-S3method(print, mmfrac)
-S3method(print, yuima.lasso)
-S3method(print, yuima.llag) # Oct. 10, 2015
-S3method(print, yuima.mllag) # Oct. 10, 2015
-S3method(print, yuima.specv) # Oct. 10, 2015
-
-
-S3method(toLatex, yuima)
-S3method(toLatex, yuima.model)
-S3method(toLatex, yuima.carma)
-S3method(toLatex, yuima.cogarch)
-S3method(rbind, yuima.model)
-S3method(cbind, yuima)
-
-S3method(plot, yuima.llag) # Oct. 10, 2015
-S3method(plot, yuima.mllag) # Oct. 10, 2015
-
-useDynLib(yuima) #,.registration = TRUE)
-
-
-
+import("methods")
+
+##importFrom("stats", "end", "time", "start")
+importFrom("graphics", "plot")
+import("zoo")
+importFrom(stats, confint)
+import("stats4")
+import("expm")
+import("mvtnorm")
+import("cubature")
+
+importFrom(utils, toLatex)
+
+importFrom("graphics", "lines")
+importFrom("stats", "qchisq")
+importFrom("utils", "relist")
+
+importFrom(boot, boot) # added by YK on Sep. 9, 2017 
+#08/07/2016
+#exportPattern("^[[:alpha:]]+") # NEVER DO THIS AGAIN PLEASE!
+#cimport(RcppArmadillo)
+importFrom(Rcpp, evalCpp)
+#import(RcppArmadillo)
+# 03/07/2015
+importFrom(stats, time)
+importFrom(stats, ts)
+importFrom(stats, rnorm)
+importFrom(stats, na.omit)
+importFrom(stats, dgamma)
+importFrom(stats, optimHess)
+importFrom(stats, filter)
+importFrom(utils, tail)
+importFrom(utils, head)
+importFrom(stats, acf)
+importFrom(stats, fft)
+importFrom(stats, rexp)
+importFrom(stats, approx)
+importFrom(stats, arima0)
+importFrom(stats, frequency)
+importFrom(stats, D)
+importFrom(stats, integrate)
+importFrom(stats, rpois)
+importFrom(stats, runif)
+importFrom(stats, optim)
+importFrom(stats, optimize)
+importFrom(stats, deltat)
+importFrom(stats, pchisq)
+importFrom(stats, symnum)
+importFrom(stats, rchisq)
+importFrom(stats, rgamma)
+importFrom(stats, diffinv)
+importFrom(stats, pnorm)
+importFrom(stats, approxfun)
+importFrom(stats, qnorm)
+importFrom(stats, rbinom)
+importFrom(stats, constrOptim)
+importFrom(stats, dnorm)
+importFrom(stats, deriv)
+importFrom(graphics, points)
+importFrom(stats, end)
+importFrom(stats, start)
+importFrom(utils, str)
+importFrom(stats, sd)
+
+
+exportClasses("yuima",
+"yuima.data",
+"yuima.law",
+"yuima.sampling",
+"yuima.characteristic",
+"yuima.model",
+"model.parameter",
+"yuima.carma",
+"carma.info",
+"yuima.carma.qmle",
+"yuima.poisson",
+"yuima.qmle",
+"yuima.CP.qmle",
+"cogarch.info",
+"yuima.cogarch",
+"yuima.Map",
+"info.Map",
+"param.Map",
+"yuima.multimodel",
+"param.Integral",
+"variable.Integral",
+"Integrand",
+"Integral.sde",
+"yuima.Integral",
+"info.Ppr",
+"yuima.Ppr",
+"yuima.Hawkes"
+)
+
+exportMethods(
+"dim",
+"length",
+## "start",
+"plot",
+## "time",
+## "end",
+"simulate",
+"cce",
+"llag",
+"poisson.random.sampling",
+"get.zoo.data",
+"initialize",
+##              "ql",
+##              "rql",
+##              "ml.ql",
+"adaBayes",
+"lseBayes",
+"limiting.gamma",
+"getF",
+"getf",
+"getxinit",
+"gete",
+"simFunctional",
+"F0",
+"Fnorm",
+"asymptotic_term",
+#"cbind.yuima",
+"rand",
+"dens",
+"cdf",
+"quant",
+"char"
+#"rbind.yuima"
+)
+
+## function which we want to expose to the user
+## all other functions are used internally by the
+## package
+export(ybook)
+export(setYuima)
+export(setModel) ## builds sde model
+export(setData)
+export(setSampling)
+export(setCharacteristic)
+export(setCarma)
+export(setPoisson)
+export(setPpr)
+export(setHawkes)
+export(dconst)
+export(rconst)
+export(setLaw)
+export(setCogarch)
+export(setMap)
+#export(setMultiModel)
+export(setIntegral)
+
+export(dim)
+export(length)
+#export(start)
+export(plot)
+#export(time)
+#export(end)
+
+export(simulate) # simulates couple of processes
+export(subsampling)
+export(cce)
+export(llag)
+export(poisson.random.sampling)
+export(noisy.sampling)
+export(mpv)
+export(bns.test)
+export(hyavar) # asymptotic variance estimator for the Hayashi-Yoshida estimator
+export(lmm) # Oct. 10, 2015: local methods of moment estimator
+export(mllag) # Oct. 10, 2015: multiple lead-lag detector
+export(llag.test) # Sep. 9, 2017: testing the absence of lead-lag effects 
+
+export(get.zoo.data)
+
+##export(ql,rql,ml.ql)
+##export(rql)
+export(adaBayes)
+export(lseBayes)
+export(rIG, rNIG, rbgamma, rvgamma, rstable,rpts,rnts, rGIG, rGH) ## random number generators in rng.R
+export(dIG, dNIG, dbgamma, dvgamma, dGIG, dGH) ## pdfs in rng.R
+export(limiting.gamma)
+export(lambdaFromData)
+
+
+export(setFunctional)
+export(getF)
+export(getf)
+export(getxinit)
+export(gete)
+
+export(simFunctional)
+export(F0)
+export(Fnorm)
+export(asymptotic_term)
+
+##export(LSE)
+export(lse)
+
+export(qmle)
+export(quasilogl)
+export(phi.test)
+export(lasso)
+export(CPoint)
+export(qmleR)
+export(qmleL)
+export(qmleLevy)
+export(IC)
+
+
+export(Intensity.PPR)
+
+
+export(CarmaNoise) # Estimates the Levy in carma model
+export(gmm) # Estimation COGARCH(P,Q) using Method Of Moments
+export(cogarchNoise)
+export(Diagnostic.Cogarch)
+export(Diagnostic.Carma)
+
+# Methods
+export(rand)# random number generator of a Levy process specified by user
+export(dens)
+export(cdf)
+export(quant)
+export(char)
+
+
+export(qgv)
+export(mmfrac)
+
+#export(cbind.yuima)
+#export(rbind.yuima)
+S3method(print, phitest)
+S3method(print, qgv)
+S3method(print, mmfrac)
+S3method(print, yuima.lasso)
+S3method(print, yuima.llag) # Oct. 10, 2015
+S3method(print, yuima.mllag) # Oct. 10, 2015
+S3method(print, yuima.specv) # Oct. 10, 2015
+
+
+S3method(toLatex, yuima)
+S3method(toLatex, yuima.model)
+S3method(toLatex, yuima.carma)
+S3method(toLatex, yuima.cogarch)
+S3method(rbind, yuima.model)
+S3method(cbind, yuima)
+
+S3method(plot, yuima.llag) # Oct. 10, 2015
+S3method(plot, yuima.mllag) # Oct. 10, 2015
+
+useDynLib(yuima)
+
+#,.registration = TRUE)
+
+
+

Modified: pkg/yuima/R/AuxMethodforPPR.R
===================================================================
--- pkg/yuima/R/AuxMethodforPPR.R	2017-11-24 16:18:46 UTC (rev 631)
+++ pkg/yuima/R/AuxMethodforPPR.R	2017-11-27 14:42:36 UTC (rev 632)
@@ -12,14 +12,18 @@
   # IntLambda<-InternalConstractionIntensity(param,my.envd1,
   #                                          my.envd2,my.envd3)
   Index<-my.envd3$gridTime
-  Integr1 <- -sum(IntLambda[-length(IntLambda)]*diff(Index),na.rm=TRUE)
+  Integr1a <- -sum(IntLambda[-length(IntLambda)]*diff(Index),na.rm=TRUE)
+  Integr1b <- -sum(IntLambda[-1]*diff(Index),na.rm=TRUE)
+  Integr1 <- (Integr1a+Integr1b)/2
   # if(is.nan(Integr1)){
   #   Integr1 <- -10^6
   # }
   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)
+    #Integr2a<- sum(log(IntLambda[-1][cond2!=0]),na.rm=TRUE)
+    Integr2 <- sum(log(IntLambda[cond2!=0]),na.rm=TRUE)
+    #Integr2 <- (Integr2a+Integr2b)/2
   }else{
     yuima.stop("Spal")
   }
@@ -28,7 +32,7 @@
   # }
   logLik <- Integr1+Integr2
   cat("\n ",logLik, param)
-  return(-logLik)
+  return(-logLik/sum(cond2))
 }
 
 
@@ -123,9 +127,11 @@
     # Covariates
     if(length(yuimaPPr at Ppr@covariates)>0){
       # Covariates should be identified at jump time
-      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)
+      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)
+      }
     }
 
   }

Modified: pkg/yuima/R/simulateForPpr.R
===================================================================
--- pkg/yuima/R/simulateForPpr.R	2017-11-24 16:18:46 UTC (rev 631)
+++ pkg/yuima/R/simulateForPpr.R	2017-11-27 14:42:36 UTC (rev 632)
@@ -335,10 +335,10 @@
               HazardRate <- HazardRate+incrlambda
               cond <- const-HazardRate
               i<-i+1
-              if(i>=dimGrid){
+              if(i>=(dimGrid-1)){
                 noExit <- FALSE
               }
-              if(i<=dim(simMod at data@original.data)[1]){  
+              if(i<dim(simMod at data@original.data)[1]){  
               dimCov <- length(object at Ppr@covariates)
                 
               if (dimCov>0){
@@ -354,7 +354,7 @@
               cat("\n ", i, grid[i])
               }
             }
-            if(i<=dim(simMod at data@original.data)[1]){ 
+            if(i<dim(simMod at data@original.data)[1]){ 
               jumpT<-c(jumpT,grid[i])
               # if(i==7001){
               #   cat("\n",noExit)



More information about the Yuima-commits mailing list