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

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Tue Feb 17 20:36:14 CET 2015


Author: lorenzo
Date: 2015-02-17 20:36:14 +0100 (Tue, 17 Feb 2015)
New Revision: 361

Added:
   pkg/yuima/man/gmm.rd
Removed:
   pkg/yuima/man/MM.COGARCH.rd
Modified:
   pkg/yuima/DESCRIPTION
   pkg/yuima/NAMESPACE
   pkg/yuima/R/MM.COGARCH.R
   pkg/yuima/R/setCarma.R
   pkg/yuima/R/setCogarch.R
   pkg/yuima/R/simulate.R
   pkg/yuima/man/simulate.Rd
Log:
Added three different simulation schemes for COGARCH(P,Q) with the associated documentation

Modified: pkg/yuima/DESCRIPTION
===================================================================
--- pkg/yuima/DESCRIPTION	2015-02-11 18:28:34 UTC (rev 360)
+++ pkg/yuima/DESCRIPTION	2015-02-17 19:36:14 UTC (rev 361)
@@ -2,7 +2,7 @@
 Type: Package
 Title: The YUIMA Project package for SDEs
 Version: 1.0.56
-Date: 2015-02-11
+Date: 2015-02-17
 Depends: methods, zoo, stats4, utils, expm, cubature, mvtnorm
 Author: YUIMA Project Team
 Maintainer: Stefano M. Iacus <stefano.iacus at unimi.it>

Modified: pkg/yuima/NAMESPACE
===================================================================
--- pkg/yuima/NAMESPACE	2015-02-11 18:28:34 UTC (rev 360)
+++ pkg/yuima/NAMESPACE	2015-02-17 19:36:14 UTC (rev 361)
@@ -123,7 +123,7 @@
 export(qmleL)
 
 export(CarmaNoise) # Estimates the Levy in carma model 
-export(MM.COGARCH) # Estimation COGARCH(P,Q) using Method Of Moments 
+export(gmm) # Estimation COGARCH(P,Q) using Method Of Moments 
  
 
 export(qgv)

Modified: pkg/yuima/R/MM.COGARCH.R
===================================================================
--- pkg/yuima/R/MM.COGARCH.R	2015-02-11 18:28:34 UTC (rev 360)
+++ pkg/yuima/R/MM.COGARCH.R	2015-02-17 19:36:14 UTC (rev 361)
@@ -10,8 +10,8 @@
 
 # The estimation procedure for cogarch(p,q) implemented in this code are based on the 
 # Chadraa phd's thesis
-MM.COGARCH<-function(yuima, data = NULL, start, method="BFGS", fixed = list(), 
-                           lower, upper){
+gmm<-function(yuima, data = NULL, start, method="BFGS", fixed = list(), 
+                           lower, upper, lag.max = NULL){
   print <- FALSE
   call <- match.call()
 # First step we check if all inputs are inserted correctly.
@@ -72,8 +72,12 @@
   ma.name <- paste(info at ma.par,c(1:numb.ma),sep="")
   
   loc.par <- info at loc.par
-  xinit.name <- paste(info at Latent.var, c(1:numb.ar), sep = "")
+  #xinit.name <- paste(info at Latent.var, c(1:numb.ar), sep = "")
 
+  xinit.name0 <- model at parameter@xinit
+  idx <- na.omit(match(c(loc.par, ma.name), xinit.name0))
+  xinit.name <- xinit.name0[-idx]
+
   meas.par <- model at parameter@measure
   
   fixed.name <- names(fixed)
@@ -136,6 +140,9 @@
   env <- new.env()
   n <- length(observ)[1]
   
+  #Lag
+  assign("lag", lag.max, envir=env)
+  
   # Data
   assign("Data",  as.matrix(onezoo(observ)[,1]), envir=env)
   assign("deltaData",  frequency(onezoo(observ)[,1]), envir=env)
@@ -170,8 +177,10 @@
    } 
   ErrTerm(yuima=yuima, param=mycoef, print=print, env)
 }
- out<- optim(start, objectiveFun, method=method)
-# , method = "L-BFGS-B",
+ out<- optim(start, objectiveFun, method = method)
+# ,  
+#              lower = c(0.0001, 0.00001, 0.00001, 0, 0.9), upper = c(1, 1, 1, 1, 1.1))
+
 #              lower=c(0.0001,0.00001,0.00001,0, 0.9,-100,-100),
 #              upper=c(1,1,1,1,1.1,0,0))
 
@@ -188,7 +197,7 @@
   mu_G2 <- mean(G_i^2)
   var_G2 <- mean(G_i^4) - mu_G2^2
   d <- floor(sqrt(length(G_i)))
-  CovQuad <- log(abs(acf(G_i^2,plot=FALSE,lag.max=min(d,10),type=typeacf)$acf[-1]))
+  CovQuad <- log(abs(acf(G_i^2,plot=FALSE,lag.max=min(d,env$lag),type=typeacf)$acf[-1]))
   h <- seq(1, d, by = 1)*r
   cost <- env$loc.idx
   b <- env$ar.idx
@@ -281,7 +290,7 @@
   }
    
   term <- expm(B_tilde*h)
-  invB <- solve(B_tilde)
+  invB <- solve(B_tilde) # In this case we can use the analytical form for Companion Matrix???
   term1 <- invB%*%(IdentM-expm(-B_tilde*r))
   term2 <- (expm(B_tilde*r)-IdentM)
   

Modified: pkg/yuima/R/setCarma.R
===================================================================
--- pkg/yuima/R/setCarma.R	2015-02-11 18:28:34 UTC (rev 360)
+++ pkg/yuima/R/setCarma.R	2015-02-17 19:36:14 UTC (rev 361)
@@ -231,13 +231,26 @@
       if(ma.par==lin.par){
         first_term<-paste(coeff_alpha[fin_alp],V,sep="*")
         diffusion_Carma<-matrix(c(first_term,as.character(matrix(0,(p-1),1)),V),(p+1),1)  
-
-        Model_Carma<-setModel(drift=drift_Carma, 
+        if(Cogarch==FALSE){
+          Model_Carma<-setModel(drift=drift_Carma, 
                                diffusion=diffusion_Carma,
                                hurst=mydots$hurst, 
                                state.variable=c(Carma.var,Y_coeff),  
                                solve.variable=c(Carma.var,Y_coeff),
                                xinit=c(Vt,mydots$xinit))
+        }else{# We add this part to have as initial condition for the COGARCH model V_0=a_0+a'X_0 LM 13/02/2015
+           V01<-paste(coeff_alpha,mydots$xinit,sep="*")
+           V02<-paste(V01,collapse="+")
+           V0t<-paste(loc.par,V02,sep="+") 
+           
+           
+           Model_Carma<-setModel(drift=drift_Carma, 
+                              diffusion=diffusion_Carma,
+                              hurst=mydots$hurst, 
+                              state.variable=c(Carma.var,Y_coeff),  
+                              solve.variable=c(Carma.var,Y_coeff),
+                              xinit=c(V0t,mydots$xinit))
+        }
 #         return(Model_Carma1)
       }else{ 
 #         coeff_gamma<-c(paste(lin.par,1:p,sep=""),as.character(matrix(0,1,p-q)))

Modified: pkg/yuima/R/setCogarch.R
===================================================================
--- pkg/yuima/R/setCogarch.R	2015-02-11 18:28:34 UTC (rev 360)
+++ pkg/yuima/R/setCogarch.R	2015-02-17 19:36:14 UTC (rev 361)
@@ -110,6 +110,7 @@
                         ma.par=ma.par,
                         loc.par=loc.par,
                         lin.par=ma.par,
+                        XinExpr=XinExpr,
                         Cogarch=TRUE)
     #  In order to have a representation of a Cogarch(p,q) model coherent with the 
     # Chaadra Brockwell and Davis we need to modify the slot xinit and drift[1]

Modified: pkg/yuima/R/simulate.R
===================================================================
--- pkg/yuima/R/simulate.R	2015-02-11 18:28:34 UTC (rev 360)
+++ pkg/yuima/R/simulate.R	2015-02-17 19:36:14 UTC (rev 361)
@@ -13,7 +13,7 @@
 
 setGeneric("simulate",
            function(object, nsim=1, seed=NULL, xinit, true.parameter, space.discretized=FALSE, 
-                    increment.W=NULL, increment.L=NULL, hurst, methodfGn="WoodChan", 
+                    increment.W=NULL, increment.L=NULL, idxCOGARCH=FALSE, hurst, methodfGn="WoodChan", 
                     sampling=sampling, subsampling=subsampling, ...
                     #		Initial = 0, Terminal = 1, n = 100, delta, 
                     #		grid = as.numeric(NULL), random = FALSE, sdelta=as.numeric(NULL), 
@@ -25,9 +25,9 @@
 
 setMethod("simulate", "yuima.model",
           function(object, nsim=1, seed=NULL, xinit, true.parameter, 
-                   space.discretized=FALSE, increment.W=NULL, increment.L=NULL,
+                   space.discretized=FALSE, increment.W=NULL, increment.L=NULL, idxCOGARCH=FALSE,
                    hurst, methodfGn="WoodChan",
-                   sampling, subsampling,
+                   sampling, subsampling, 
                    #Initial = 0, Terminal = 1, n = 100, delta, 
                    #	grid, random = FALSE, sdelta=as.numeric(NULL), 
                    #	sgrid=as.numeric(NULL), interpolation="none"
@@ -47,7 +47,8 @@
             out <- simulate(tmpyuima, nsim=nsim, seed=seed, xinit=xinit, 
                             true.parameter=true.parameter, 
                             space.discretized=space.discretized, 
-                            increment.W=increment.W, increment.L=increment.L,
+                            increment.W=increment.W, increment.L=increment.L, 
+                            idxCOGARCH=idxCOGARCH,
                             hurst=hurst,methodfGn=methodfGn, subsampling=subsampling)
             return(out)	
           })
@@ -61,7 +62,8 @@
 
 setMethod("simulate", "yuima",
           function(object, nsim=1, seed=NULL, xinit, true.parameter, 
-                   space.discretized=FALSE, increment.W=NULL, increment.L=NULL,
+                   space.discretized=FALSE, increment.W=NULL, increment.L=NULL, 
+                   idxCOGARCH=FALSE,
                    hurst,methodfGn="WoodChan",
                    sampling, subsampling,
                    Initial = 0, Terminal = 1, n = 100, delta, 
@@ -70,7 +72,7 @@
             
             if(is(object at model,"yuima.cogarch")){
               res<-aux.simulateCogarch(object, nsim, seed, xinit, true.parameter, 
-                           space.discretized, increment.W, increment.L,
+                           space.discretized, increment.W, increment.L, idxCOGARCH,
                            hurst,methodfGn,
                            sampling, subsampling,
                            Initial, Terminal, n, delta, 
@@ -469,7 +471,7 @@
 }
 
 aux.simulateCogarch<-function(object, nsim, seed, xinit, true.parameter, 
-                              space.discretized, increment.W, increment.L,
+                              space.discretized, increment.W, increment.L, idxCOGARCH,
                               hurst,methodfGn,
                               sampling, subsampling,
                               Initial, Terminal, n, delta, 
@@ -479,39 +481,56 @@
   model<-yuimaCogarch at model
   info<-model at info
   samp <- yuimaCogarch at sampling
-    aux.Noise<-setModel(drift="0",
-                        diffusion="0",
-                        jump.coeff="1",
-                        measure=info at measure,
-                        measure.type=info at measure.type)
+  if(idxCOGARCH==FALSE||(idxCOGARCH==TRUE && model at measure.type=="code")){  
+      aux.Noise<-setModel(drift="0",
+                          diffusion="0",
+                          jump.coeff="1",
+                          measure=info at measure,
+                          measure.type=info at measure.type)
   
-#   aux.samp<-setSampling(Initial = samp at Initial, Terminal = samp at Terminal[1], n = samp at n[1], delta = samp at delta, 
-#                         grid=samp at grid, random = samp at random, sdelta=samp at sdelta, 
-#                         sgrid=samp at sgrid, interpolation=samp at interpolation )
+  #    aux.samp<-setSampling(Initial = samp at Initial, Terminal = samp at Terminal[1], n = samp at n[1], delta = samp at delta, 
+  #                         grid=samp at grid, random = samp at random, sdelta=samp at sdelta, 
+  #                         sgrid=samp at sgrid, interpolation=samp at interpolation )
 
-    aux.samp<-setSampling(Initial = samp at Initial, Terminal = samp at Terminal[1], n = samp at n[1])
-    auxModel<-setYuima(model=aux.Noise, sampling= aux.samp)
+      aux.samp<-setSampling(Initial = samp at Initial, Terminal = samp at Terminal[1], n = samp at n[1])
+      auxModel<-setYuima(model=aux.Noise, sampling= aux.samp)
 
-  if(length(model at parameter@measure)==0){
-    aux.incr2<-aux.simulate(object=auxModel, nsim=nsim, seed=seed, 
-                           space.discretized=space.discretized, increment.W=increment.W, 
-                           increment.L=increment.L,
-                           hurst=0.5,methodfGn=methodfGn)
-  }else{
-    aux.incr2<-aux.simulate(object=auxModel, nsim=nsim, seed=seed, 
-                            true.parameter = true.parameter[model at parameter@measure], 
-                            space.discretized=space.discretized, increment.W=increment.W, 
-                            increment.L=increment.L,
-                            hurst=0.5,methodfGn=methodfGn)
-  }    
-  increment<-diff(as.numeric(get.zoo.data(aux.incr2)[[1]]))
-  # Using the simulated increment for generating the quadratic variation
-  # As first step we compute it in a crude way. A more fine approach is based on 
-  # the mpv function.
-  quadratVariation <- increment^2
-  incr.L <- t(matrix(c(increment,quadratVariation),ncol=2))
-  incr.W <- matrix(0, nrow=1,ncol=length(increment))
-  # Simulate trajectories Cogarch
+    if(length(model at parameter@measure)==0){
+      aux.incr2<-aux.simulate(object=auxModel, nsim=nsim, seed=seed, 
+                             space.discretized=space.discretized, increment.W=increment.W, 
+                             increment.L=increment.L,
+                             hurst=0.5,methodfGn=methodfGn)
+    }else{
+      aux.incr2<-aux.simulate(object=auxModel, nsim=nsim, seed=seed, 
+                              true.parameter = true.parameter[model at parameter@measure], 
+                              space.discretized=space.discretized, increment.W=increment.W, 
+                              increment.L=increment.L,
+                              hurst=0.5,methodfGn=methodfGn)
+    }    
+    increment<-diff(as.numeric(get.zoo.data(aux.incr2)[[1]]))
+    # Using the simulated increment for generating the quadratic variation
+    # As first step we compute it in a crude way. A more fine approach is based on 
+    # the mpv function.
+    quadratVariation <- increment^2
+    incr.L <- t(matrix(c(increment,quadratVariation),ncol=2))
+    incr.W <- matrix(0, nrow=1,ncol=length(increment))
+    # Simulate trajectories Cogarch
+  }
+  d.size <- model at equation.number  
+  if(missing(xinit)){
+    xinit <- yuimaCogarch at model@xinit
+  } else {
+    if(length(xinit) != d.size){
+      if(length(xinit)==1){
+        xinit <- rep(xinit, d.size)
+      } else {
+        yuima.warn("Dimension of xinit variables missmatch.")
+        return(NULL)
+      }
+    }
+  }
+  xinit <- as.expression(xinit)  # force xinit to be an expression
+  if(idxCOGARCH==FALSE){
   result <- aux.simulate(object=yuimaCogarch, nsim=nsim, seed=seed, xinit=xinit,
                          true.parameter = true.parameter, 
                          space.discretized = space.discretized,increment.W =incr.W,
@@ -521,6 +540,155 @@
                     Initial=Initial, Terminal=Terminal, n=n, delta=delta, 
                     grid=grid, random=random, sdelta=sdelta, 
                     sgrid=sgrid, interpolation=interpolation)
+  }else{
+    Terminal <- samp at Terminal[1] 
+    n <- samp at n[1]
+    Delta <- Terminal/n
+    name.ar <- paste0(info at ar.par,c(1:info at q))
+    name.ma <- paste0(info at ma.par,c(1:info at p))
+    name.loc <- info at loc.par
+    name.param <- names(true.parameter)
+    parms <- as.numeric(true.parameter)
+    names(parms)<-name.param
+    value.ar <- parms[name.ar] 
+    value.ma <- parms[name.ma]
+    value.a0 <- parms[name.loc]
+    AMatrix <- MatrixA(value.ar)
+    avect<-evect<-matrix(0,info at q,1)
+    evect[info at q,] <- 1
+    avect[c(1,info at p),1] <- value.ma
+    Indent<-diag(info at q)
+    # Inputs: incr.L 
+    tavect<-t(avect)
+    
+    ncolsim <- (info at q+2)
+    sim <- matrix(0,n,ncolsim)
+    
+    par.len <- length(model at parameter@all)
+    if(missing(true.parameter) & par.len>0){
+      true.parameter <- vector(par.len, mode="list")
+      for(i in 1:par.len)
+        true.parameter[[i]] <- 0
+      names(true.parameter) <-   model at parameter@all
+    }
+    
+    yuimaEnv <- new.env()
+    
+    if(par.len>0){
+      for(i in 1:par.len){
+        pars <- model at parameter@all[i]
+        for(j in 1:length(true.parameter)){
+          if( is.na(match(pars, names(true.parameter)[j]))!=TRUE){
+            assign(model at parameter@all[i], true.parameter[[j]], yuimaEnv)
+          }
+        }
+        #assign(sdeModel at parameter@all[i], true.parameter[[i]], yuimaEnv)
+      }
+    }
+   
+    for(i in c(1:ncolsim)){
+      sim[1,i] <- eval(xinit[i], yuimaEnv)
+    }
+    
+    if(yuimaCogarch at model@measure.type=="code"){
+            for(t in c(2:n)){
+        sim[t,3:ncolsim] <- value.a0*expm(AMatrix*Delta)%*%evect*incr.L[2,t-1]+
+          expm(AMatrix*Delta)%*%(Indent+evect%*%tavect*incr.L[2,t-1])%*%sim[t-1,3:ncolsim]
+#         sim[t,2]<-value.a0+tavect%*%sim[t,3:ncolsim]
+#         sim[t,1]<-sim[t-1,1]+sqrt(sim[t,2])*incr.L[1,t]  
+#        sim[t,3:ncolsim]<-expm(AMatrix*Delta)%*%sim[t-1,3:ncolsim]+expm(AMatrix)%*%evect*sim[t-1,2]*incr.L[2,t]
+#        sim[t,3:ncolsim]<-sim[t-1,3:ncolsim]+AMatrix*Delta%*%sim[t-1,3:ncolsim]+evect*sim[t-1,2]*incr.L[2,t-1]
+        sim[t,2]<-value.a0+tavect%*%sim[t,3:ncolsim]
+        sim[t,1]<-sim[t-1,1]+sqrt(sim[t-1,2])*incr.L[1,t-1]
+        
+      }
+      X <- ts(sim)
+      Data <- setData(X,delta = Delta)
+      result <- setYuima(data=Data,model=yuimaCogarch at model, sampling=yuimaCogarch at sampling)
+    }else{
+        lambda <- eval(model at measure$intensity, yuimaEnv)
+        
+        
+        #Simulating jump times 
+      intensity <- lambda*Delta
+      jump_time<-numeric()
+      jump_time[1] <- rexp(1, rate = intensity) 
+      # In yuima this part is evaluated using function eval
+      Time <-numeric()
+      Time[1] <- jump_time[1]
+      j <- 1
+      numb_jum<-numeric()
+      for (i in c(1:n) ){
+        numb_jum[i]<-0
+        while(Time[j]<i){
+          numb_jum[i]<-numb_jum[i]+1
+          jump_time[j+1]<-rexp(1,rate=intensity)
+          Time[j+1]<-Time[j]+jump_time[j+1]
+          j<-j+1
+        }
+      }
+      total_NumbJ <- j-1
+      # Counting the number of jumps 
+      N<-matrix(1,n,1)
+      N[1,1]<-numb_jum[1]
+      for(i in c(2:n)){
+        N[i,1]=N[i-1,1]+numb_jum[i]
+      }
+      # Simulating the driving process
+      F <- suppressWarnings(parse(text=gsub("^d(.+?)\\(.+?,", "r\\1(total_NumbJ,", model at measure$df$expr, perl=TRUE)))
+      assign("total_NumbJ",total_NumbJ, envir=yuimaEnv)
+      dL<-eval(F, envir=yuimaEnv)
+      #dL<-rnorm(total_NumbJ,mean=0,sd=1)
+      L<-matrix(1,total_NumbJ,1)
+      L[1]<-dL[1]
+      for(j in c(2:total_NumbJ)){
+        L[j]<-L[j-1] + dL[j]
+      }
+      # Computing the processes V and Y at jump
+      V<-matrix(1,total_NumbJ,1)
+      Y<-matrix(1,info at q,total_NumbJ)
+      Y[,1]<-matrix(1,info at q,1) #Starting point for unobservable State Space Process.
+      Y[,1]<-expm(AMatrix*jump_time[1])%*%Y[,1]
+      Y[,1]<-Y[,1]+(value.a0+sum(tavect*Y[,1]))*evect*dL[1]^2
+      V[1,]<-value.a0+sum(tavect*Y[,1])
+      for(j in c(2:total_NumbJ)){
+        Y[,j]<-Y[,j-1]
+        Y[,j]<-expm(AMatrix*jump_time[j])%*%Y[,j] 
+        Y[,j]<-Y[,j]+(value.a0+sum(tavect*Y[,j]))*evect*dL[j]^2
+        V[j,]<-value.a0+sum(tavect*Y[,j])
+      }
+      # Computing the process G at jump time
+      G<-matrix(1, total_NumbJ,1)
+      G[1]<-sqrt(V[1])*dL[1]
+      for(j in c(2:total_NumbJ)){
+        G[j]<-G[j-1]+sqrt(V[j])*dL[j] 
+      }
+      # Realizations observed at integer times
+      i<-1
+      while(N[i]==0){
+        i <- i+1 
+      }
+#       G_obs<-numeric()
+       L_obs<-numeric()
+#       V_obs<-numeric()
+#       Y_obs<-matrix(0,info at q,)
+      sim[c(1:(i-1)),1]<-0
+      sim[c(i:n),1]<-G[N[c(i:n)]]
+      L_obs[c(1:(i-1))]<-0
+      L_obs[c(i:n)]<-L[N[c(i:n)]]
+      for(j in c(1:(i-1))){
+        sim[j,3:ncolsim]<-as.numeric(Y[,j])
+        sim[j,2]<-value.a0+tavect%*%expm(AMatrix*j)%*%matrix(1,info at q,1)#Starting point for unobservable State Space Process 
+      }
+      for(j in c(i:n)){
+        sim[j,3:ncolsim]<-as.numeric(Y[,N[j]])
+        sim[j,2]<-value.a0+as.numeric(tavect%*%expm(AMatrix*(j-Time[N[j]]))%*%Y[,N[j]]) 
+      }
+    }
+  X <- ts(sim)
+  Data <- setData(X,delta = Delta)
+  result <- setYuima(data=Data,model=yuimaCogarch at model, sampling=yuimaCogarch at sampling)
+  }
   return(result)
 }
 

Deleted: pkg/yuima/man/MM.COGARCH.rd
===================================================================
--- pkg/yuima/man/MM.COGARCH.rd	2015-02-11 18:28:34 UTC (rev 360)
+++ pkg/yuima/man/MM.COGARCH.rd	2015-02-17 19:36:14 UTC (rev 361)
@@ -1,76 +0,0 @@
-\name{MM.COGARCH}
-\alias{MM.COGARCH}
-\alias{Method of Moment COGARCH}
-\alias{Estimation COGARCH}
-\alias{est. COGARCH}
-\alias{est. yuima Cog}
-%- Also NEED an '\alias' for EACH other topic documented here.
-\title{
-Method of Moments for COGARCH(P,Q). 
-}
-\description{
-The function returns the estimated parameters of a COGARCH(P,Q) model. The parameters are abtained by matching theoretical vs empirical autocorrelation function. The theoretical autocorrelation function is computed according the methodology developed in Chadraa (2009).
-}
-\usage{
-MM.COGARCH(yuima, data = NULL, start, 
- method="BFGS", fixed = list(), lower, upper)
-}
-%- maybe also 'usage' for other objects documented here.
-\arguments{
-  \item{yuima}{a yuima object or an object of \code{\link{yuima.cogarch-class}}.}
-  \item{data}{an object of class \code{\link{yuima.data-class}} contains the observations available at uniformly spaced time. If \code{data=NULL}, the default, the function uses the data in an object of \code{\link{yuima-class}}.}
-  \item{start}{a \code{list} containing the starting values for the optimization routine.}
-  \item{method}{a string indicating one of the methods available in \code{\link{optim}}.}
-  \item{fixed}{a list of fixed parameters in optimization routine.}
-  \item{lower}{a named list for specifying lower bounds of parameters}
-  \item{upper}{a named list for specifying upper bounds of parameters}
-}
-%\details{
-%Please complete !!!
-%}
-\value{ The function returns a list with the same components of the object obtained when the function  \code{\link{optim}} is used.
-}
-\references{
-Chadraa, E. (2009) Statistical Modeling with COGARCH(P,Q) Processes. Phd Thesis
-}
-\author{
-The YUIMA Project Team.
-}
-%\note{
-%%  ~~further notes~~
-%}
-
-%% ~Make other sections like Warning with \section{Warning }{....} ~
-
-%\seealso{
-%% ~~objects to See Also as \code{\link{help}}, ~~~
-%}
-\examples{
-\dontrun{
-# Example COGARCH(1,1): the parameters are the same used in Haugh et al. 2005. In this case 
-# we assume the underlying noise is a symmetric variance gamma.
-# As first step we define the COGARCH(1,1) in yuima:
-
-mod1 <- setCogarch(p = 1, q = 1, work = FALSE,
-                   measure=list(df="rbgamma(z,1,sqrt(2),1,sqrt(2))"),
-                    measure.type = "code", Cogarch.var = "y",
-                    V.var = "v", Latent.var="x")
-
-param <- list(a1 = 0.038,  b1 =  0.053,
-              a0 = 0.04/0.053, x1 = 0)
-
-# We generate a trajectory
-
-samp <- setSampling(Terminal=5000, n=5000)
-set.seed(100)
-sim1 <- simulate(mod1, sampling = samp, true.parameter = param)
-
-# We estimate the model
-
-res1 <- MM.COGARCH(yuima = sim1, start = param)
-}
-}
-% Add one or more standard keywords, see file 'KEYWORDS' in the
-% R documentation directory.
-\keyword{ Method of Moments }
-\keyword{ Estimation COGARCH }% __ONLY ONE__ keyword per line

Added: pkg/yuima/man/gmm.rd
===================================================================
--- pkg/yuima/man/gmm.rd	                        (rev 0)
+++ pkg/yuima/man/gmm.rd	2015-02-17 19:36:14 UTC (rev 361)
@@ -0,0 +1,78 @@
+\name{gmm}
+\alias{gmm}
+\alias{gmm.COGARCH}
+\alias{Method of Moment COGARCH}
+\alias{Estimation COGARCH}
+\alias{est. COGARCH}
+\alias{est. yuima Cog}
+%- Also NEED an '\alias' for EACH other topic documented here.
+\title{
+Method of Moments for COGARCH(P,Q). 
+}
+\description{
+The function returns the estimated parameters of a COGARCH(P,Q) model. The parameters are abtained by matching theoretical vs empirical autocorrelation function. The theoretical autocorrelation function is computed according the methodology developed in Chadraa (2009).
+}
+\usage{
+gmm(yuima, data = NULL, start, 
+ method="BFGS", fixed = list(), lower, upper, lag.max = NULL)
+}
+%- maybe also 'usage' for other objects documented here.
+\arguments{
+  \item{yuima}{a yuima object or an object of \code{\link{yuima.cogarch-class}}.}
+  \item{data}{an object of class \code{\link{yuima.data-class}} contains the observations available at uniformly spaced time. If \code{data=NULL}, the default, the function uses the data in an object of \code{\link{yuima-class}}.}
+  \item{start}{a \code{list} containing the starting values for the optimization routine.}
+  \item{method}{a string indicating one of the methods available in \code{\link{optim}}.}
+  \item{fixed}{a list of fixed parameters in optimization routine.}
+  \item{lower}{a named list for specifying lower bounds of parameters.}
+  \item{upper}{a named list for specifying upper bounds of parameters.}
+  \item{lag.max}{maximum lag at which to calculate the theoretical and empirical acf. Default is \code{sqrt{N}} where \code{N} is the number of observation.}
+}
+%\details{
+%Please complete !!!
+%}
+\value{ The function returns a list with the same components of the object obtained when the function  \code{\link{optim}} is used.
+}
+\references{
+Chadraa, E. (2009) Statistical Modeling with COGARCH(P,Q) Processes. Phd Thesis
+}
+\author{
+The YUIMA Project Team.
+}
+%\note{
+%%  ~~further notes~~
+%}
+
+%% ~Make other sections like Warning with \section{Warning }{....} ~
+
+%\seealso{
+%% ~~objects to See Also as \code{\link{help}}, ~~~
+%}
+\examples{
+\dontrun{
+# Example COGARCH(1,1): the parameters are the same used in Haugh et al. 2005. In this case 
+# we assume the underlying noise is a symmetric variance gamma.
+# As first step we define the COGARCH(1,1) in yuima:
+
+mod1 <- setCogarch(p = 1, q = 1, work = FALSE,
+                   measure=list(df="rbgamma(z,1,sqrt(2),1,sqrt(2))"),
+                    measure.type = "code", Cogarch.var = "y",
+                    V.var = "v", Latent.var="x")
+
+param <- list(a1 = 0.038,  b1 =  0.053,
+              a0 = 0.04/0.053, x1 = 0)
+
+# We generate a trajectory
+
+samp <- setSampling(Terminal=5000, n=5000)
+set.seed(100)
+sim1 <- simulate(mod1, sampling = samp, true.parameter = param)
+
+# We estimate the model
+
+res1 <- MM.COGARCH(yuima = sim1, start = param)
+}
+}
+% Add one or more standard keywords, see file 'KEYWORDS' in the
+% R documentation directory.
+\keyword{ Method of Moments }
+\keyword{ Estimation COGARCH }% __ONLY ONE__ keyword per line

Modified: pkg/yuima/man/simulate.Rd
===================================================================
--- pkg/yuima/man/simulate.Rd	2015-02-11 18:28:34 UTC (rev 360)
+++ pkg/yuima/man/simulate.Rd	2015-02-17 19:36:14 UTC (rev 361)
@@ -4,7 +4,7 @@
 \description{Simulate multi-dimensional stochastic processes.}
 \usage{
 simulate(object, nsim=1, seed=NULL, xinit, true.parameter, space.discretized = FALSE, 
- increment.W = NULL, increment.L = NULL, hurst, methodfGn = "WoodChan",
+ increment.W = NULL, increment.L = NULL, idxCOGARCH = FALSE, hurst, methodfGn = "WoodChan",
  	sampling=sampling, subsampling=subsampling, ...)
 }
 \arguments{
@@ -16,6 +16,7 @@
 	Maruyama method.}
   \item{increment.W}{to specify Wiener increment for each time tics in advance.}
   \item{increment.L}{to specify Levy increment for each time tics in advance.}
+  \item{idxCOGARCH}{Logical Variable for simulation scheme used if the model is a COGARCH(P,Q).}
   \item{nsim}{Not used yet. Included only to match the standard genenirc in 
 	package \code{stats}.}
   \item{seed}{Not used yet. Included only to match the standard genenirc in 



More information about the Yuima-commits mailing list