[Yuima-commits] r627 - in pkg/yuima: . R man src

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Sat Sep 9 19:10:27 CEST 2017


Author: kyuta
Date: 2017-09-09 19:10:27 +0200 (Sat, 09 Sep 2017)
New Revision: 627

Added:
   pkg/yuima/R/llag.test.R
   pkg/yuima/man/llag.test.Rd
Modified:
   pkg/yuima/DESCRIPTION
   pkg/yuima/NAMESPACE
   pkg/yuima/NEWS
   pkg/yuima/R/llag.R
   pkg/yuima/man/bns.test.Rd
   pkg/yuima/man/cce.Rd
   pkg/yuima/man/hyavar.Rd
   pkg/yuima/man/llag.Rd
   pkg/yuima/man/mllag.Rd
   pkg/yuima/src/cce_functions.c
   pkg/yuima/src/yuima_init.c
Log:
add llag.test and modify other files

Modified: pkg/yuima/DESCRIPTION
===================================================================
--- pkg/yuima/DESCRIPTION	2017-09-08 08:51:04 UTC (rev 626)
+++ pkg/yuima/DESCRIPTION	2017-09-09 17:10:27 UTC (rev 627)
@@ -1,15 +1,15 @@
-Package: yuima
-Type: Package
-Title: The YUIMA Project Package for SDEs
-Version: 1.7.1
-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 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.2
+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/NAMESPACE
===================================================================
--- pkg/yuima/NAMESPACE	2017-09-08 08:51:04 UTC (rev 626)
+++ pkg/yuima/NAMESPACE	2017-09-09 17:10:27 UTC (rev 627)
@@ -1,251 +1,253 @@
-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")
-
-#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(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/NEWS
===================================================================
--- pkg/yuima/NEWS	2017-09-08 08:51:04 UTC (rev 626)
+++ pkg/yuima/NEWS	2017-09-09 17:10:27 UTC (rev 627)
@@ -49,4 +49,7 @@
 2017/03/27: added IC.R and qmleLevy.R
 2017/04/12: fix a bug in sim.euler.R
                   (re-)added euler.c 
-2017/04/27: modified qmleLevy.R, qmleLevy.Rd, IC.Rd
\ No newline at end of file
+2017/04/27: modified qmleLevy.R, qmleLevy.Rd, IC.Rd
+2017/09/09: boot package is imported
+            added llag.test.R, llag.test.Rd
+            modified llag.R, bns.test.Rd, llag.Rd, mllag.Rd, hyavar.Rd, cce.Rd, cce_functions.c
\ No newline at end of file

Modified: pkg/yuima/R/llag.R
===================================================================
--- pkg/yuima/R/llag.R	2017-09-08 08:51:04 UTC (rev 626)
+++ pkg/yuima/R/llag.R	2017-09-09 17:10:27 UTC (rev 627)
@@ -193,21 +193,21 @@
 ## main body
 setGeneric( "llag", function(x, from = -Inf, to = Inf, division = FALSE, 
                              verbose = (ci || ccor), grid, psd = TRUE, plot = ci,
-                             ccor = ci, ci = FALSE, alpha = 0.01, fisher = TRUE, bw) standardGeneric("llag") )
+                             ccor = ci, ci = FALSE, alpha = 0.01, fisher = TRUE, bw, tol = 1e-6) standardGeneric("llag") )
 
 ## yuima-method
 setMethod("llag", "yuima", function(x, from, to, division, verbose, grid, psd, plot, 
-                                         ccor, ci, alpha, fisher, bw)
-  llag(x at data, from, to, division, verbose, grid, psd, plot, ccor, ci, alpha, fisher, bw))
+                                         ccor, ci, alpha, fisher, bw, tol)
+  llag(x at data, from, to, division, verbose, grid, psd, plot, ccor, ci, alpha, fisher, bw, tol))
 
 ## yuima.data-method
 setMethod("llag", "yuima.data", function(x, from, to, division, verbose, grid, psd, plot, 
-                                         ccor, ci, alpha, fisher, bw)
-  llag(x at zoo.data, from, to, division, verbose, grid, psd, plot, ccor, ci, alpha, fisher, bw))
+                                         ccor, ci, alpha, fisher, bw, tol)
+  llag(x at zoo.data, from, to, division, verbose, grid, psd, plot, ccor, ci, alpha, fisher, bw, tol))
 
 ## list-method
 setMethod("llag", "list", function(x, from, to, division, verbose, grid, psd, plot, 
-                                   ccor, ci, alpha, fisher, bw) {
+                                   ccor, ci, alpha, fisher, bw, tol) {
   
   d <- length(x)
   d.size <- d*(d-1)/2
@@ -222,7 +222,7 @@
     grid <- make.grid(d, d.size, x, from, to, division)
   
   # Set the tolerance to avoid numerical erros in comparison
-  tol <- 1e-6
+  #tol <- 1e-6
   
   for(i in 1:d){
     
@@ -280,19 +280,20 @@
         
         names(crosscor)[num] <- paste("(",i,",",j,")", sep = "")
         
-        tmp <- .C("HYcrosscorr",
+        tmp <- .C("HYcrosscorr2",
                   as.integer(length(G[[num]])),
                   as.integer(length(time1)),
                   as.integer(length(time2)),
                   as.double(G[[num]]),
                   as.double(time1),
                   as.double(time2),
-                  double(length(time2)),
+                  #double(length(time2)),
                   as.double(ser.diffX[[i]]),
                   as.double(ser.diffX[[j]]),
                   as.double(vol[i]),
                   as.double(vol[j]),
-                  value=double(length(G[[num]])))$value
+                  value=double(length(G[[num]])),
+                  PACKAGE = "yuima")$value
         
         idx[num] <- which.max(abs(tmp))
         mlag <- -grid[[num]][idx[num]] # make the first timing of max or min
@@ -327,17 +328,18 @@
         
         names(crosscor)[num] <- paste("(",i,",",j,")", sep = "")
         
-        tmp <- .C("HYcrosscov",
+        tmp <- .C("HYcrosscov2",
                   as.integer(length(G[[num]])),
                   as.integer(length(time1)),
                   as.integer(length(time2)),
                   as.double(G[[num]]),
                   as.double(time1),
                   as.double(time2),
-                  double(length(time2)),
+                  #double(length(time2)),
                   as.double(ser.diffX[[i]]),
                   as.double(ser.diffX[[j]]),
-                  value=double(length(G[[num]])))$value
+                  value=double(length(G[[num]])),
+                  PACKAGE = "yuima")$value
         
         idx[num] <- which.max(abs(tmp))
         mlag <- -grid[[num]][idx[num]] # make the first timing of max or min
@@ -485,7 +487,8 @@
 }
 
 # plot method for yuima.llag-class
-plot.yuima.llag <- function(x, alpha = 0.01, fisher = TRUE, ...){
+plot.yuima.llag <- function(x, alpha = 0.01, fisher = TRUE, 
+                            main = NULL, xlab = NULL, ylab = NULL, ...){
   
   if(is.null(x$ccor)){
     warning("cross-correlation functions were not returned by llag. Set verbose = TRUE and ccor = TRUE to return them.",
@@ -493,6 +496,9 @@
     return(NULL)
   }else{
     
+    if(is.null(xlab)) xlab <- expression(theta)
+    if(is.null(ylab)) ylab <- expression(U(theta))
+    
     d <- nrow(x$LLR)
     
     if(is.null(x$avar)){
@@ -501,9 +507,13 @@
           
           num <- d*(i-1) - (i-1)*i/2 + (j-i)
           
-          plot(x$ccor[[num]],
-               main=paste(i,"vs",j,"(positive",expression(theta),"means",i,"leads",j,")"),
-               xlab=expression(theta),ylab=expression(U(theta)))
+          if(is.null(main)){
+            plot(x$ccor[[num]],
+                 main=paste(i,"vs",j,"(positive",expression(theta),"means",i,"leads",j,")"),
+                 xlab=xlab,ylab=ylab)
+          }else{
+            plot(x$ccor[[num]],main=main,xlab=xlab,ylab=ylab)
+          }
           
         }
       }
@@ -526,11 +536,16 @@
           
           y.max <- max(abs(as.numeric(x$ccor[[num]])),as.numeric(CI))
           
-          plot(x$ccor[[num]],
-               main=paste(i,"vs",j,"(positive",expression(theta),"means",i,"leads",j,")"),
-               xlab=expression(theta),ylab=expression(U(theta)),
-               ylim=c(-y.max,y.max))
+          if(is.null(main)){
+            plot(x$ccor[[num]],
+                 main=paste(i,"vs",j,"(positive",expression(theta),"means",i,"leads",j,")"),
+                 xlab=xlab,ylab=ylab,ylim=c(-y.max,y.max))
+          }else{
+            plot(x$ccor[[num]],main = main,xlab=xlab,ylab=ylab,
+                 ylim=c(-y.max,y.max))
+          }
           
+          
           lines(CI,lty=2,col="blue")
           lines(-CI,lty=2,col="blue")
           

Added: pkg/yuima/R/llag.test.R
===================================================================
--- pkg/yuima/R/llag.test.R	                        (rev 0)
+++ pkg/yuima/R/llag.test.R	2017-09-09 17:10:27 UTC (rev 627)
@@ -0,0 +1,122 @@
+
+llag.test <- function(x, from = -Inf, to = Inf, division = FALSE, 
+                      grid, R = 999, parallel = "no", 
+                      ncpus = getOption("boot.ncpus", 1L), 
+                      cl = NULL, tol = 1e-6){
+  
+  x <- get.zoo.data(x)
+  
+  d <- length(x)
+  d.size <- d*(d-1)/2
+  
+  # allocate memory
+  ser.times <- vector(d, mode="list") # time index in 'x'
+  ser.diffX <- vector(d, mode="list") # difference of data
+  vol <- double(d)
+  
+  # treatment of the grid (2016-07-04: we implement this before the NA treatment)
+  if(missing(grid)) 
+    grid <- make.grid(d, d.size, x, from, to, division)
+  
+  # Set the tolerance to avoid numerical erros in comparison
+  #tol <- 1e-6
+  
+  for(i in 1:d){
+    
+    # NA data must be skipped
+    idt <- which(is.na(x[[i]]))
+    if(length(idt>0)){
+      x[[i]] <- x[[i]][-idt]
+    }
+    if(length(x[[i]])<2) {
+      stop("length of data (w/o NA) must be more than 1")
+    }
+    
+    # set data and time index
+    ser.times[[i]] <- as.numeric(time(x[[i]]))/tol
+    # set difference of the data 
+    ser.diffX[[i]] <- diff( as.numeric(x[[i]]) )
+    vol[i] <- sum(ser.diffX[[i]]^2)
+  }
+  
+  pval <- matrix(0,d,d)
+  mcov <- diag(vol)
+  mcor <- diag(d)
+  
+  rownames(pval) <- names(x)
+  rownames(mcov) <- names(x)
+  rownames(mcor) <- names(x)
+  colnames(pval) <- names(x)
+  colnames(mcov) <- names(x)
+  colnames(mcor) <- names(x)
+  
+  # treatment of the grid
+  #if(missing(grid)) 
+  #  grid <- make.grid(d, d.size, x, from, to, division)
+  
+  if(is.list(grid)){
+    G <- relist(unlist(grid)/tol, grid)
+  }else{
+    if(is.numeric(grid)){
+      G <- data.frame(matrix(grid/tol,length(grid),d.size))
+      grid <- data.frame(matrix(grid,length(grid),d.size))
+    }else{
+      print("llag:invalid grid")
+      return(NULL)
+    }
+  }
+  
+  # core part
+  for(i in 1:(d-1)){
+    for(j in (i+1):d){
+      
+      time1 <- ser.times[[i]]
+      time2 <- ser.times[[j]] 
+      
+      num <- d*(i-1) - (i-1)*i/2 + (j-i)
+      
+      hry <- function(data){
+        
+        dx <- data$dx
+        dy <- data$dy
+        
+        U <- .C("HYcrosscov2",
+                as.integer(length(G[[num]])),
+                as.integer(length(time1)),
+                as.integer(length(time2)),
+                as.double(G[[num]]),
+                as.double(time1),
+                as.double(time2),
+                #double(length(time2)),
+                as.double(dx),
+                as.double(dy),
+                value=double(length(G[[num]])),
+                PACKAGE = "yuima")$value
+        
+        return(max(abs(U)))
+      }
+      
+      ran.gen <- function(data, mle){
+        dx <- data$dx
+        dy <- data$dy
+        list(dx = (2*rbinom(length(dx),1,0.5)-1) * dx, 
+             dy = (2*rbinom(length(dy),1,0.5)-1) * dy)
+      }
+      
+      out <- boot(list(dx = ser.diffX[[i]], dy = ser.diffX[[j]]),
+                  hry, R, sim = "parametric", ran.gen = ran.gen,
+                  parallel = parallel, ncpus = ncpus, cl = cl)
+      
+      pval[i,j] <- mean(out$t > out$t0)
+      mcov[i,j] <- out$t0
+      mcor[i,j] <- out$t0/sqrt(vol[i]*vol[j])
+      
+      pval[j,i] <- pval[i,j]
+      mcov[j,i] <- mcov[i,j]
+      mcor[j,i] <- mcor[i,j]
+      
+    }
+  }
+  
+  return(list(p.values = pval, max.cov = mcov, max.corr = mcor))
+}

Modified: pkg/yuima/man/bns.test.Rd
===================================================================
--- pkg/yuima/man/bns.test.Rd	2017-09-08 08:51:04 UTC (rev 626)
+++ pkg/yuima/man/bns.test.Rd	2017-09-09 17:10:27 UTC (rev 627)
@@ -1,124 +1,124 @@
-\name{bns.test}
-\alias{bns.test}
-\alias{bns.test,yuima-method}
-\alias{bns.test,yuima.data-method}
-\alias{bns.test,list-method}
-%- Also NEED an '\alias' for EACH other topic documented here.
-\title{
-%%  ~~function to do ... ~~
-Barndorff-Nielsen and Shephard's Test for the Presence of Jumps Using Bipower Variation
-}
-\description{
-%%  ~~ A concise (1-5 lines) description of what the function does. ~~
-Tests the presence of jumps using the statistic proposed in Barndorff-Nielsen and Shephard (2004,2006) for each components.
-}
-\usage{
-bns.test(yuima, r = rep(1, 4), type = "standard", adj = TRUE)
-}
-%- maybe also 'usage' for other objects documented here.
-\arguments{
-  \item{yuima}{
-%%     ~~Describe \code{yuima} here~~
-an object of  \code{\link{yuima-class}} or \code{\link{yuima.data-class}}.
-}
-  \item{r}{
-%%     ~~Describe \code{r} here~~
-a vector of non-negative numbers or a list of vectors of non-negative numbers. Theoretically, it is necessary that \code{sum(r)=4} and \code{max(r)<2}.
-}
-  \item{type}{
-%%     ~~Describe \code{type} here~~
-type of the test statistic to use. \code{standard} is default.
-}
-  \item{adj}{
-%%     ~~Describe \code{adj} here~~
-logical; if \code{TRUE}, the maximum adjustment suggested in Barndorff-Nielsen and Shephard (2004) is applied to the test statistic when \code{type} is equal to either \dQuote{\code{log}} or \dQuote{\code{ratio}}.
-}
-}
-\details{
-%%  ~~ If necessary, more details than the description above ~~
-For the \code{i}-th component, the test statistic is equal to the \code{i}-th component of \code{sqrt(n)*(mpv(yuima,2)-mpv(yuima,c(1,1)))/sqrt(vartheta*mpv(yuima,r))} when \code{type="standard"}, \code{sqrt(n)*log(mpv(yuima,2)/mpv(yuima,c(1,1)))/sqrt(vartheta*mpv(yuima,r)/mpv(yuima,c(1,1))^2)} when \code{type="log"} and \code{sqrt(n)*(1-mpv(yuima,c(1,1))/mpv(yuima,2))/sqrt(vartheta*mpv(yuima,r)/mpv(yuima,c(1,1))^2)} when \code{type="ratio"}. Here, \code{n} is equal to the length of the \code{i}-th component of the \code{zoo.data} of \code{yuima} minus 1 and \code{vartheta} is \code{pi^2/4+pi-5}. When \code{adj=TRUE}, \code{mpv(yuima,r)[i]/mpv(yuima,c(1,1))^2)[i]} is replaced with 1 if it is less than 1.
-}
-\value{
-%%  ~Describe the value returned
-%%  If it is a LIST, use
-%%  \item{comp1 }{Description of 'comp1'}
-%%  \item{comp2 }{Description of 'comp2'}
-%% ...
-A list with the same length as the \code{zoo.data} of \code{yuima}. Each components of the list has class \dQuote{\code{htest}} and contains the following components:
-\item{statistic}{the value of the test statistic of the corresponding component of the \code{zoo.data} of \code{yuima}.}
-\item{p.value}{an approximate p-value for the test of the corresponding component.}
-\item{method}{the character string \dQuote{\code{Barndorff-Nielsen and Shephard jump test}}.}
-\item{data.name}{the character string \dQuote{\code{xi}}, where \code{i} is the number of the component.}
-}
-\references{
-%% ~put references to the literature/web site here ~
-Barndorff-Nielsen, O. E. and Shephard, N. (2004)
-  Power and bipower variation with stochastic volatility and jumps,
-  \emph{Journal of Financial Econometrics}, \bold{2}, no. 1, 1--37.
-  
-Barndorff-Nielsen, O. E. and Shephard, N. (2006)
-  Econometrics of testing for jumps in financial economics using bipower variation,
-  \emph{Journal of Financial Econometrics}, \bold{4}, no. 1, 1--30.
-  
-Huang, X. and Tauchen, G. (2005)
-  The relative contribution of jumps to total price variance,
-  \emph{Journal of Financial Econometrics}, \bold{3}, no. 4, 456--499.
-}
-\author{
-%%  ~~who you are~~
-The YUIMA Project Team
-}
-\note{
-%%  ~~further notes~~
-Theoretically, this test may be invalid if sampling is irregular.
-}
-
-%% ~Make other sections like Warning with \section{Warning }{....} ~
-
-\seealso{
-%% ~~objects to See Also as \code{\link{help}}, ~~~
-\code{\link{mpv}}
-}
-\examples{
-
-set.seed(123)
-
-# One-dimensional case
-## Model: dXt=t*dWt+t*dzt, 
-## where zt is a compound Poisson process with intensity 5 and jump sizes distribution N(0,0.1).
-
-model <- setModel(drift=0,diffusion="t",jump.coeff="t",measure.type="CP",
-                  measure=list(intensity=5,df=list("dnorm(z,0,sqrt(0.1))")),
-                  time.variable="t")
-
-yuima.samp <- setSampling(Terminal = 1, n = 390) 
-yuima <- setYuima(model = model, sampling = yuima.samp) 
-yuima <- simulate(yuima)
-plot(yuima) # The path seems to involve some jumps
-
-bns.test(yuima) # standard type
-
-bns.test(yuima,type="log") # log type
-
-bns.test(yuima,type="ratio") # ratio type
-
-# Multi-dimensional case
-## Model: dXkt=t*dWk_t (k=1,2,3) (no jump case).
-
-diff.matrix <- diag(3)
-diag(diff.matrix) <- c("t","t","t")
-model <- setModel(drift=c(0,0,0),diffusion=diff.matrix,time.variable="t",
-                  solve.variable=c("x1","x2","x3"))
-
-yuima.samp <- setSampling(Terminal = 1, n = 390) 
-yuima <- setYuima(model = model, sampling = yuima.samp) 
-yuima <- simulate(yuima)
-plot(yuima)
-
-bns.test(yuima)
-
-}
-% Add one or more standard keywords, see file 'KEYWORDS' in the
-% R documentation directory.
-\keyword{ts}
-% __ONLY ONE__ keyword per line
+\name{bns.test}
+\alias{bns.test}
+\alias{bns.test,yuima-method}
+\alias{bns.test,yuima.data-method}
+\alias{bns.test,list-method}
+%- Also NEED an '\alias' for EACH other topic documented here.
+\title{
+%%  ~~function to do ... ~~
+Barndorff-Nielsen and Shephard's Test for the Presence of Jumps Using Bipower Variation
+}
+\description{
+%%  ~~ A concise (1-5 lines) description of what the function does. ~~
+Tests the presence of jumps using the statistic proposed in Barndorff-Nielsen and Shephard (2004,2006) for each component.
+}
+\usage{
+bns.test(yuima, r = rep(1, 4), type = "standard", adj = TRUE)
+}
+%- maybe also 'usage' for other objects documented here.
+\arguments{
+  \item{yuima}{
+%%     ~~Describe \code{yuima} here~~
+an object of  \code{\link{yuima-class}} or \code{\link{yuima.data-class}}.
+}
+  \item{r}{
+%%     ~~Describe \code{r} here~~
+a vector of non-negative numbers or a list of vectors of non-negative numbers. Theoretically, it is necessary that \code{sum(r)=4} and \code{max(r)<2}.
+}
+  \item{type}{
+%%     ~~Describe \code{type} here~~
+type of the test statistic to use. \code{standard} is default.
+}
+  \item{adj}{
+%%     ~~Describe \code{adj} here~~
+logical; if \code{TRUE}, the maximum adjustment suggested in Barndorff-Nielsen and Shephard (2004) is applied to the test statistic when \code{type} is equal to either \dQuote{\code{log}} or \dQuote{\code{ratio}}.
+}
+}
+\details{
+%%  ~~ If necessary, more details than the description above ~~
+For the \code{i}-th component, the test statistic is equal to the \code{i}-th component of \code{sqrt(n)*(mpv(yuima,2)-mpv(yuima,c(1,1)))/sqrt(vartheta*mpv(yuima,r))} when \code{type="standard"}, \code{sqrt(n)*log(mpv(yuima,2)/mpv(yuima,c(1,1)))/sqrt(vartheta*mpv(yuima,r)/mpv(yuima,c(1,1))^2)} when \code{type="log"} and \code{sqrt(n)*(1-mpv(yuima,c(1,1))/mpv(yuima,2))/sqrt(vartheta*mpv(yuima,r)/mpv(yuima,c(1,1))^2)} when \code{type="ratio"}. Here, \code{n} is equal to the length of the \code{i}-th component of the \code{zoo.data} of \code{yuima} minus 1 and \code{vartheta} is \code{pi^2/4+pi-5}. When \code{adj=TRUE}, \code{mpv(yuima,r)[i]/mpv(yuima,c(1,1))^2)[i]} is replaced with 1 if it is less than 1.
+}
+\value{
+%%  ~Describe the value returned
+%%  If it is a LIST, use
+%%  \item{comp1 }{Description of 'comp1'}
+%%  \item{comp2 }{Description of 'comp2'}
+%% ...
+A list with the same length as the \code{zoo.data} of \code{yuima}. Each components of the list has class \dQuote{\code{htest}} and contains the following components:
+\item{statistic}{the value of the test statistic of the corresponding component of the \code{zoo.data} of \code{yuima}.}
+\item{p.value}{an approximate p-value for the test of the corresponding component.}
+\item{method}{the character string \dQuote{\code{Barndorff-Nielsen and Shephard jump test}}.}
+\item{data.name}{the character string \dQuote{\code{xi}}, where \code{i} is the number of the component.}
+}
+\references{
+%% ~put references to the literature/web site here ~
+Barndorff-Nielsen, O. E. and Shephard, N. (2004)
+  Power and bipower variation with stochastic volatility and jumps,
+  \emph{Journal of Financial Econometrics}, \bold{2}, no. 1, 1--37.
+  
+Barndorff-Nielsen, O. E. and Shephard, N. (2006)
+  Econometrics of testing for jumps in financial economics using bipower variation,
+  \emph{Journal of Financial Econometrics}, \bold{4}, no. 1, 1--30.
+  
+Huang, X. and Tauchen, G. (2005)
+  The relative contribution of jumps to total price variance,
+  \emph{Journal of Financial Econometrics}, \bold{3}, no. 4, 456--499.
+}
+\author{
+%%  ~~who you are~~
+The YUIMA Project Team
+}
+\note{
+%%  ~~further notes~~
+Theoretically, this test may be invalid if sampling is irregular.
+}
+
+%% ~Make other sections like Warning with \section{Warning }{....} ~
+
+\seealso{
+%% ~~objects to See Also as \code{\link{help}}, ~~~
+\code{\link{mpv}}
+}
+\examples{
+
+set.seed(123)
+
+# One-dimensional case
+## Model: dXt=t*dWt+t*dzt, 
+## where zt is a compound Poisson process with intensity 5 and jump sizes distribution N(0,0.1).
+
+model <- setModel(drift=0,diffusion="t",jump.coeff="t",measure.type="CP",
+                  measure=list(intensity=5,df=list("dnorm(z,0,sqrt(0.1))")),
+                  time.variable="t")
+
+yuima.samp <- setSampling(Terminal = 1, n = 390) 
+yuima <- setYuima(model = model, sampling = yuima.samp) 
+yuima <- simulate(yuima)
+plot(yuima) # The path seems to involve some jumps
+
+bns.test(yuima) # standard type
+
+bns.test(yuima,type="log") # log type
+
+bns.test(yuima,type="ratio") # ratio type
+
+# Multi-dimensional case
+## Model: dXkt=t*dWk_t (k=1,2,3) (no jump case).
+
+diff.matrix <- diag(3)
+diag(diff.matrix) <- c("t","t","t")
+model <- setModel(drift=c(0,0,0),diffusion=diff.matrix,time.variable="t",
+                  solve.variable=c("x1","x2","x3"))
+
+yuima.samp <- setSampling(Terminal = 1, n = 390) 
+yuima <- setYuima(model = model, sampling = yuima.samp) 
+yuima <- simulate(yuima)
+plot(yuima)
+
+bns.test(yuima)
+
+}
+% Add one or more standard keywords, see file 'KEYWORDS' in the
+% R documentation directory.
+\keyword{ts}
+% __ONLY ONE__ keyword per line

Modified: pkg/yuima/man/cce.Rd
===================================================================
--- pkg/yuima/man/cce.Rd	2017-09-08 08:51:04 UTC (rev 626)
+++ pkg/yuima/man/cce.Rd	2017-09-09 17:10:27 UTC (rev 627)
@@ -264,9 +264,9 @@
   Asymptotic normality of a covariance estimator for nonsynchronously observed diffusion processes, 
   \emph{Annals of the Institute of Statistical Mathematics}, \bold{60}, no. 2, 367--406.
 
-Koike, Y. (2015)
+Koike, Y. (2016)
   Estimation of integrated covariances in the simultaneous presence of nonsynchronicity, microstructure noise and jumps,
-  \emph{Econometric Theory}, doi:10.1017/S0266466614000954.
+  \emph{Econometric Theory}, \bold{32}, 533--611.
   
 Koike, Y. (2014)
   An estimator for the cumulative co-volatility of asynchronously observed semimartingales with jumps,
@@ -280,9 +280,9 @@
   Identifying the Brownian covariation from the co-jumps given discrete observations,
   \emph{Econometric Theory}, \bold{28}, 249--273.
   
-Varneskov, R. T. (2015)
+Varneskov, R. T. (2016)
   Flat-top realized kernel estimation of quadratic covariation with non-synchronous and noisy asset prices,
-  \emph{Journal of Business & Economic Statistics}, doi:10.1080/07350015.2015.1005622.
+  \emph{Journal of Business & Economic Statistics}, \bold{34}, no.1, 1--22.
   
 Zhang, L. (2006)
[TRUNCATED]

To get the complete diff run:
    svnlook diff /svnroot/yuima -r 627


More information about the Yuima-commits mailing list