Skip to content

Commit

Permalink
version 1.6.4
Browse files Browse the repository at this point in the history
  • Loading branch information
siacus authored and cran-robot committed Apr 29, 2017
1 parent 7809af5 commit 994534d
Show file tree
Hide file tree
Showing 17 changed files with 937 additions and 41 deletions.
8 changes: 4 additions & 4 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: yuima
Type: Package
Title: The YUIMA Project Package for SDEs
Version: 1.5.9
Version: 1.6.4
Depends: R(>= 2.10.0), methods, zoo, stats4, utils, expm, cubature,
mvtnorm
Imports: Rcpp (>= 0.12.1)
Expand All @@ -10,8 +10,8 @@ Maintainer: Stefano M. Iacus <stefano.iacus@unimi.it>
Description: Simulation and Inference for SDEs and Other Stochastic Processes.
License: GPL-2
URL: http://www.yuima-project.com
LinkingTo: Rcpp
LinkingTo: Rcpp, RcppArmadillo
NeedsCompilation: yes
Packaged: 2017-02-16 08:13:22 UTC; jago
Packaged: 2017-04-29 16:35:21 UTC; jago
Repository: CRAN
Date/Publication: 2017-02-16 10:56:19
Date/Publication: 2017-04-29 17:22:22 UTC
24 changes: 16 additions & 8 deletions MD5
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
94d55d512a9ba36caa9b7df079bae19f *COPYING
e28fbc668d8593e561e42567310b1c02 *DESCRIPTION
78555ea59ce1b92bdac35fbc65bd1644 *NAMESPACE
7e736091160e525dc7409179a5a423b3 *NEWS
6ff6771b74704fbc1dbc18609adcde46 *DESCRIPTION
f290fae7e2189d079adc58b354583335 *NAMESPACE
52d732c1f3eca935acf88ec0f5995de6 *NEWS
778e4b1f228bb32472ce4604c098b304 *R/AllClasses.R
eee3644e6d8be56074eb21822d3210f8 *R/AuxMethodforPPR.R
96f6fe0474453484c238f0970e8038b3 *R/CPoint.R
Expand All @@ -11,11 +11,12 @@ dd610167315ee57f6b5921a5da017867 *R/CarmaNoise.R
6176779119bb0e1a7260ead2443e9dff *R/DiagnosticCarma.R
2e0bac6f55b108d4008cea8270d6d68f *R/DiagnosticCogarch.R
01a3e835c0cfd35dce4d34d6763b5fa8 *R/FunctionAndOperators.R
710e193dcd36ab4085d2b3791424c34b *R/IC.R
9f604491f19766f60c180f2dacb746b6 *R/MM.COGARCH.R
6572d692fccc1407df5b668b5bf583a8 *R/MethodForLaw.R
c0d1c8b86b588b042c4c112a9aa239ca *R/NewClasses.R
83d94c78f7c73bc1a3afef43130179b0 *R/PointProcessClasses.R
03e030f1075484e5246b1b4fbba5831e *R/PseudoLogLikCOGARCH.R
ee7171a81ca0402397480d118eeace23 *R/PseudoLogLikCOGARCH.R
2769a941be91fee725f0ab579925eb4a *R/RcppExports.R
732dcc9e15b9c0a4ce729a7825c4f3cf *R/WoodChanfGn.R
ac2ace50f9d723532f8e95b44f62fd8c *R/adaBayes.R
Expand All @@ -24,7 +25,7 @@ ce7188b6122aed3cc988f68aa4425098 *R/asymptotic_term_third.R
c84cc727acac73a45493ff22b55a78a4 *R/asymptotic_term_third_function.R
3878b53ad6b45165671e6992e19bcced *R/bns.test.R
cdaae861c947a38f8189cfc12d18c5db *R/cce.R
062cfafa31f5862ca35e7866e1c88254 *R/cogarchNoise.R
c7a3bb80e0a4c609c1b096fd4b067eed *R/cogarchNoise.R
81109b8c6aa4eed3435772af607b114e *R/hyavar.R
b08e054f9de744817c7e310b6d4df4a4 *R/lambdaPPR.R
febfb56c6f3c5e1d41854337c9ec5e00 *R/lasso.R
Expand All @@ -40,6 +41,7 @@ e920d4330c561d82faa6695675da2d3b *R/phi.test.R
197ae3a057ce2b8309af7c30a30f3337 *R/poisson.random.sampling.R
dccb8679a411fb8e915736c8510f710e *R/qgv.R
4220357495c23d10e716bf6e0999b7fb *R/qmle.R
55fbbcc961ed77a544a4fe0ae02f7c0c *R/qmleLevy.R
7658b39c1b3cedd74ad3e11b558edd71 *R/rng.R
1f567847cf9c65fa085f2f9a50d3e8e6 *R/sampling2grid.R
738c1edcc284afdb385274d952665fbf *R/setCarma.R
Expand All @@ -48,7 +50,7 @@ dccb8679a411fb8e915736c8510f710e *R/qgv.R
4b8647a2c018ae59b0a464f031e7c8b2 *R/setMultiModel.R
fcecca27a76849cd88191dfa8599b2b6 *R/setPoisson.R
f73eb5a08ae59d0f87a1248030d7b099 *R/setPpr.R
337c910cd0f8ef9c53b543f3a3ebdfa5 *R/sim.euler.R
de57a59b21c7db830040d91722bd3206 *R/sim.euler.R
d6d8dbbbeb5b8950787d890e953d38ed *R/sim.euler.space.discretized.R
357799e4682e2422e3373bb4390ff035 *R/simCP.R
8085cc8546d7bc91626fbf170354256e *R/simFunctional.R
Expand Down Expand Up @@ -83,6 +85,7 @@ b8ef9ee6ce88d58b1a10067e58f3d277 *inst/ybook/chapter5.R
2ff567959c3646587b4eea7855f3fd40 *man/CarmaNoise.Rd
7d14ee06f14e3f17a0b0f338d58840e5 *man/Diagnostic.Carma.Rd
36a70b3f4695317597d6e0a5ead614f9 *man/Diagnostic.Cogarch.Rd
7efca8f83dbda1691d7d6197bb9468d8 *man/IC.Rd
373a5beea48671dc52cc980da3c9f39f *man/Integral.sde.rd
8b6a11819c8fd0ba2551e37e69ab7a66 *man/Integrand.rd
764949aab3e1513b7108fa9413fb8937 *man/Intensity.PPR.Rd
Expand Down Expand Up @@ -118,6 +121,7 @@ db5127cc4b6ee0cd2ab9f40e52341477 *man/mpv.Rd
7566b9ac61bee8350513827f37448cb7 *man/poisson.random.sampling.Rd
b3165cb5569c8200e1951475a788de29 *man/qgv.Rd
9511ad690c71917c7fbf7049596de694 *man/qmle.Rd
c5734b1c0120ebc880ae465863265e12 *man/qmleLevy.Rd
361abb4eb2b5e1fac3c9513b27e7623e *man/rconst.Rd
386e6bbfb1e1bf243594546a42d7cd41 *man/rng.Rd
dcf545cfcafb3d4db450cb64d0ee46ad *man/setCarma.Rd
Expand Down Expand Up @@ -158,13 +162,17 @@ d8c0fc095d6a7d24a6a5cfd9c2e38586 *man/yuima.model-class.Rd
6a72501f7453e18ee6987dede63ffe53 *man/yuima.multimodel.Rd
068fee21cdb050ca6f46be8739cc25b7 *man/yuima.poisson-class.Rd
ffbff0dc3f384712fe20d939c8c9bd84 *man/yuima.sampling-class.Rd
2a6f9e9e044a78154d3cfda5936d6f48 *src/Makevars
8d46d69896a1f1d31ed76035a0e49d67 *src/Makevars.win
4029dd40a1d3e9acca6da00af9d351f5 *src/MpCN.cpp
2b1a38d3f511eca643f8bb068606f767 *src/Mt.h
e33f564d55ac991fbd073d0a9da4a5b2 *src/PseudoLoglikCOGARCH.c
d526b452d20f043cf4f3e85be8345a32 *src/PseudoLoglikCOGARCH.c
12a71e207c71fa492b51fd16381a427f *src/RcppExports.cpp
9bf5144dbaa6f7c01b99307463cdee07 *src/carmafilter.c
35dad51d480042ba175c1461f7c44f84 *src/cce_functions.c
29c7df46a58ed220949e409258657b83 *src/euler.c
9a0949594da84284dc11344b72c63950 *src/euler.c
4c06820c7b26b2f4dae030676c8343f1 *src/minusquasilogl_W1andW2.cpp
fee76cbf3ef99e0b1108c34f536ae0a8 *src/pseudoLogLikCogarchIrregularGrid.cpp
e6bb05e4b4e54b75f046f52469949dd0 *src/qmlecpp.cpp
e07e760a18ac1c05273de1e2aac2b51d *src/rng.c
d60b70b60187234e36718ed54803f109 *src/yuima_init.c
9 changes: 7 additions & 2 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@ 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)
Expand Down Expand Up @@ -199,6 +200,9 @@ export(lasso)
export(CPoint)
export(qmleR)
export(qmleL)
export(qmleLevy)
export(IC)


export(Intensity.PPR)

Expand Down Expand Up @@ -240,6 +244,7 @@ S3method(rbind, yuima.model)
S3method(plot, yuima.llag) # Oct. 10, 2015
S3method(plot, yuima.mllag) # Oct. 10, 2015

useDynLib(yuima)
useDynLib(yuima) #,.registration = TRUE)



8 changes: 7 additions & 1 deletion NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,10 @@
2016/07/08: fixed some bugs in llag.R and cce_functions.c
2016/10/04: modified setMultiModel.R, sim.euler.R and yuima.model.R to generate nts and pts process
2016/12/16: added rGIG, rGH, dGIG and dGH in rng.R and the corresponding c language file YU
2017/01/25: modified sim.euler.R and added euler.c to implement the Euler-Maruyama scheme by the C code (only the diffusion case)
2017/01/25: modified sim.euler.R and added euler.c to implement the Euler-Maruyama scheme by the C code (only the diffusion case)
2017/02/23: modified sim.euler.R and removed euler.c due to a memory corruption
fix a bug in sim.euler.R
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
62 changes: 62 additions & 0 deletions R/IC.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
## information criteria

IC <- function(yuima, data, start, lower, upper, joint = FALSE, rcpp = FALSE,...){
if(is(yuima,"yuima") == TRUE){

if(is.matrix(data) == FALSE){
sub.zoo.data <- list(zoo(x = data, order.by = yuima@sampling@grid[[1]]))
names(sub.zoo.data)[1] <- "Series 1"
}else{
sub.zoo.data <- list()
for(i in 1:ncol(data)){
sub.zoo.data <- c(sub.zoo.data, list(zoo(x = data[,i], order.by = yuima@sampling@grid[[1]])))
names(sub.zoo.data)[i] <- paste("Series", i)
}
}
yuima@data@zoo.data <- sub.zoo.data
alpha <- yuima@model@parameter@drift
beta <- yuima@model@parameter@diffusion
Terminal <- yuima@sampling@Terminal
n <- yuima@sampling@n

para.num.init <- match(yuima@model@parameter@all, names(start))
para.num.low <- match(yuima@model@parameter@all, names(lower))
para.num.upp <- match(yuima@model@parameter@all, names(upper))
para.start <- NULL
para.lower <- NULL
para.upper <- NULL
for(j in 1:length(yuima@model@parameter@all)){
para.start <- c(para.start, list(start[[para.num.init[j]]]))
para.lower <- c(para.lower, list(lower[[para.num.low[j]]]))
para.upper <- c(para.upper, list(upper[[para.num.upp[j]]]))
}
names(para.start) <- yuima@model@parameter@all
names(para.lower) <- yuima@model@parameter@all
names(para.upper) <- yuima@model@parameter@all

mle <- qmle(yuima, start = para.start, lower = para.lower, upper = para.upper, method = "L-BFGS-B", joint = joint, rcpp = rcpp)
hess <- list(mle@details$hessian)
hess.diff <- subset(hess[[1]], rownames(hess[[1]])%in%beta, select=beta)
hess.drif <- subset(hess[[1]], rownames(hess[[1]])%in%alpha, select=alpha)

esti <- coef(mle)
names(esti) <- c(beta, alpha)
cic <- summary(mle)@m2logL+2*(length(alpha)+length(beta))
bic <- summary(mle)@m2logL+length(alpha)*log(Terminal[1])+length(beta)*log(n[1])
if(det(hess.diff) > 0 && det(hess.drif) > 0){
qbic <- summary(mle)@m2logL+log(det(hess.diff))+log(det(hess.drif))
}else{
warning(cat("det(hessian of diffusion coefficient)<=0 or det(hessian of drift coefficient)<=0 \n"))
qbic <- summary(mle)@m2logL+length(alpha)*log(Terminal)+length(beta)*log(n)
}

final.res <- list(par = esti, BIC = bic, QBIC = qbic, CIC = cic)
return(final.res)
}else{
yuima.stop("This function is for yuima-class.")
}
}




18 changes: 13 additions & 5 deletions R/PseudoLogLikCOGARCH.R
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ PseudoLogLik.COGARCH <- function(yuima, start, method="BFGS", fixed = list(),
Obs <- as.numeric(as.matrix(Data)[,1])
my.env <- new.env()
param <- unlist(start)

assign("mycog",model,envir=my.env)
meas.par <- model@parameter@measure

if(length(meas.par)==0 && Est.Incr=="IncrPar"){
Expand Down Expand Up @@ -141,7 +141,7 @@ PseudoLogLik.COGARCH <- function(yuima, start, method="BFGS", fixed = list(),
rownames(vcov)[1:length(names_coef)] <- names_coef

if(!is.null(resHessian)){
vcov[c(1:length(names_coef)),c(1:length(names_coef))]<- solve(resHessian)
vcov[c(1:length(names_coef)),c(1:length(names_coef))]<- tryCatch(solve(resHessian),error=function(resHessian){NA})
}

mycoef <- start
Expand Down Expand Up @@ -182,14 +182,22 @@ minusloglik.COGARCH1<-function(param,env){
a1<-param[env$ma.names[1]]

stateMean <- a0/(bq-a1)*as.matrix(c(1,numeric(length=(env$q-1))))

penalty <- 0
CondStat <- Diagnostic.Cogarch(env$mycog,param = as.list(param),display = FALSE)
if(CondStat$stationary=="Try a different S matrix"){
penalty <-penalty + 10^6
}
if(CondStat$positivity==" "){
penalty <- penalty + 10^6
}
#param[env$start.state]<-stateMean
state <- stateMean
# state <- param[env$start.state]
DeltaG2 <- env$Obs
B <- env$B
if(env$q>1){
B[1:(env$q-1),] <- c(matrix(0,(env$p-1),1), diag(env$q-1))
#B[1:(env$q-1),] <- c(matrix(0,(env$p-1),1), diag(env$q-1))
B[1:(env$q-1),] <- cbind(matrix(0,(env$q-1),1), diag(env$q-1))
}
B[env$q,] <- -param[env$ar.names[env$q:1]]
a<-matrix(0,env$q,1)
Expand Down Expand Up @@ -232,7 +240,7 @@ minusloglik.COGARCH1<-function(param,env){
PseudologLik <-.Call("pseudoLoglik_COGARCH1", a0, bq, a1, stateMean, Q=as.integer(env$q),
DeltaG2, Deltat, DeltatB1, a, e,
V, nObs=as.integer(env$nObs-1),
dummyMatr, dummyeB1)
dummyMatr, dummyeB1) - penalty
#cat(sprintf("\n%.5f ", PseudologLik))
#
#
Expand Down
12 changes: 9 additions & 3 deletions R/cogarchNoise.R
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ cogarchNoise<-function(yuima, data=NULL, param, mu=1){
b <- param[ar.name]
cost<- param[loc.par]
Data<-as.matrix(onezoo(observ)[,1])
freq<-round(frequency(onezoo(observ)[,1]))
#freq<-round(frequency(onezoo(observ)[,1]))
freq<- diff(time(onezoo(observ)))
res<-auxcogarch.noise(cost,b,acoeff,mu,Data,freq,model@solve.variable)
return(res)
}
Expand All @@ -81,9 +82,11 @@ auxcogarch.noise<-function(cost,b,acoeff,mu,Data,freq,lab){
# Process_Y1 <- ExpY0
# Process_Y <- as.matrix(50.33)
var_V<-cost + sum(acoeff*Process_Y)
delta <- 1/freq
# delta <- 1/freq
deltatot <- c(0,freq)
for(t in c(2:(length(Data)))){
# Y_t=e^{A\Delta t}Y_{t-\Delta t}+e^{A\left(\Delta t\right)}e\left(\Delta G_{t}\right)^{2}
delta <- deltatot[t]
Process_Y <- cbind(Process_Y, (expm(B*delta)%*%(Process_Y[,t-1]+e*squaredG[t])))
# Process_Y1 <- merge(Process_Y1, (expm(B*delta)%*%(Process_Y1[,t-1]+e*squaredG[t])))
#Process_Y <- cbind(Process_Y, (Process_Y[,t-1]+delta*B%*%Process_Y[,t-1]+e*squaredG[t]))
Expand All @@ -99,7 +102,10 @@ auxcogarch.noise<-function(cost,b,acoeff,mu,Data,freq,lab){
DumRet <- as.numeric(Data[1]+cumsum(DeltaG))
Cog <- cbind(DumRet,CogDum)
colnames(Cog) <- lab
Cogarch <- setData(Cog, delta = delta)
Cog <- zoo(Cog,
order.by = cumsum(deltatot)) # Dataset on true irregular grid

Cogarch <- setData(Cog)
res<-list(incr.L=incr.L, Cogarch=Cogarch)
return(res)
}

0 comments on commit 994534d

Please sign in to comment.