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

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Mon Nov 17 21:28:47 CET 2014


Author: lorenzo
Date: 2014-11-17 21:28:46 +0100 (Mon, 17 Nov 2014)
New Revision: 354

Modified:
   pkg/yuima/DESCRIPTION
   pkg/yuima/NAMESPACE
   pkg/yuima/R/setCogarch.R
   pkg/yuima/R/toLatex.R
   pkg/yuima/man/setCogarch.Rd
   pkg/yuima/man/toLatex.Rd
Log:
Add toLatex for Cogarch Model

Modified: pkg/yuima/DESCRIPTION
===================================================================
--- pkg/yuima/DESCRIPTION	2014-11-16 23:30:52 UTC (rev 353)
+++ pkg/yuima/DESCRIPTION	2014-11-17 20:28:46 UTC (rev 354)
@@ -1,7 +1,7 @@
 Package: yuima
 Type: Package
 Title: The YUIMA Project package for SDEs
-Version: 1.0.50
+Version: 1.0.51
 Date: 2014-11-17
 Depends: methods, zoo, stats4, utils, expm, cubature, mvtnorm
 Author: YUIMA Project Team

Modified: pkg/yuima/NAMESPACE
===================================================================
--- pkg/yuima/NAMESPACE	2014-11-16 23:30:52 UTC (rev 353)
+++ pkg/yuima/NAMESPACE	2014-11-17 20:28:46 UTC (rev 354)
@@ -139,7 +139,7 @@
 S3method(toLatex, yuima)
 S3method(toLatex, yuima.model)
 S3method(toLatex, yuima.carma)
+S3method(toLatex, yuima.cogarch)
 
-
 useDynLib(yuima)
 

Modified: pkg/yuima/R/setCogarch.R
===================================================================
--- pkg/yuima/R/setCogarch.R	2014-11-16 23:30:52 UTC (rev 353)
+++ pkg/yuima/R/setCogarch.R	2014-11-17 20:28:46 UTC (rev 354)
@@ -82,7 +82,7 @@
                    measure.type=NULL,
                    XinExpr=FALSE,
                    startCogarch=0,
-                   work=TRUE,...){
+                   work=FALSE,...){
 # We use the same parametrization as in Brockwell (2000) 
   call <- match.call()
   mydots <- as.list(call)[-(1:2)]

Modified: pkg/yuima/R/toLatex.R
===================================================================
--- pkg/yuima/R/toLatex.R	2014-11-16 23:30:52 UTC (rev 353)
+++ pkg/yuima/R/toLatex.R	2014-11-17 20:28:46 UTC (rev 354)
@@ -6,10 +6,12 @@
 	mod <- object
     if (class(object) == "yuima.carma") 
   mod <- object
+	if (class(object) == "yuima.cogarch") 
+	  mod <- object
     if (class(object) == "yuima") 
 	mod <- object at model
     #if(class(mod) =="yuima.carma" && length(mod at info@lin.par)==0 )
-      if(class(mod) =="yuima.carma"  )
+      if((class(mod) =="yuima.carma") || (class(mod) =="yuima.cogarch")  )
       { 
 #         yuima.warn("")
         
@@ -31,31 +33,56 @@
         if (!length(mod at jump.variable)==0){noise.var <- mod at jump.variable}
         dr <- paste("\\left\\{\\begin{array}{l} \n")
         main.con <- info at ma.par
-        if(length(info at loc.par)==0 && !length(info at scale.par)==0){
-          main.con<-paste(info at scale.par,"* \\ ", info at ma.par)
-        }
+        if(class(mod)=="yuima.carma"){
+          if(length(info at loc.par)==0 && !length(info at scale.par)==0){
+            main.con<-paste(info at scale.par,"* \\ ", info at ma.par)
+          }
         
-        if(!length(info at loc.par)==0 && length(info at scale.par)==0){
-          main.con<-paste(info at loc.par,"+ \\ ", info at ma.par)
+          if(!length(info at loc.par)==0 && length(info at scale.par)==0){
+            main.con<-paste(info at loc.par,"+ \\ ", info at ma.par)
+          }
+          
+          if(!length(info at loc.par)==0 && !length(info at scale.par)==0){
+            main.con<-paste(info at loc.par,"+ \\ ",info at scale.par,"* \\ ", info at ma.par)
+          }
+        }else{
+          if(class(mod)=="yuima.cogarch"){
+            main.con<-paste(info at loc.par,"+ \\ ", info at ma.par)  
+          }
         }
+        if((class(mod) =="yuima.carma")){
+          dr <- paste(dr, info at Carma.var,
+                      "\\left(", sprintf("%s", mod at time.variable),"\\right) = ",main.con, "'" , 
+                     info at Latent.var,"\\left(", sprintf("%s", mod at time.variable),"\\right) \\\\ \n")
+        }else{
+          if((class(mod) =="yuima.cogarch")){
+            dr <- paste(dr, sprintf("d%s", info at Cogarch.var),
+                        "\\left(", sprintf("%s", mod at time.variable),"\\right) = \\ sqrt{",info at V.var, 
+                        "\\left(", sprintf("%s", mod at time.variable),"\\right)} \\ ",
+                        sprintf("d%s", noise.var),"\\left(", sprintf("%s", mod at time.variable),"\\right) \\\\ \n")
+            dr <- paste(dr, info at V.var,
+                        "\\left(", sprintf("%s", mod at time.variable),"\\right) = ",main.con, "'" , 
+                        info at Latent.var,"\\left(", sprintf("%s", mod at time.variable),"\\right) \\\\ \n")
+                        
+          }
+        }
         
-        if(!length(info at loc.par)==0 && !length(info at scale.par)==0){
-          main.con<-paste(info at loc.par,"+ \\ ",info at scale.par,"* \\ ", info at ma.par)
+        if((class(mod) =="yuima.carma")){
+          noise.latent.var <- noise.var
+        }else{
+          if((class(mod) =="yuima.cogarch")){
+            noise.latent.var <- paste0("\\left[",noise.var,",",noise.var,"\\right]^{q}")
+          }
+            
         }
+        dr <- paste(dr, sprintf("d%s", info at Latent.var),
+                       "\\left(", sprintf("%s", mod at time.variable),"\\right)",
+                       "=","A",info at Latent.var,
+                        "\\left(", sprintf("%s", mod at time.variable),"\\right)",
+                        sprintf("d%s", mod at time.variable),
+                       "+ e",sprintf("d%s", noise.latent.var),"\\left(",
+                       mod at time.variable, "\\right) \\\\ \n")
         
-        dr <- paste(dr, info at Carma.var,
-                    "\\left(", sprintf("%s", mod at time.variable),"\\right) = ",main.con, "'" , 
-                   info at Latent.var,"\\left(", sprintf("%s", mod at time.variable),"\\right) \\\\ \n")
-        
-        
-        
-        dr <- paste(dr, sprintf("d%s", info at Latent.var),
-                     "\\left(", sprintf("%s", mod at time.variable),"\\right)",
-                     "=","A",info at Latent.var,
-                      "\\left(", sprintf("%s", mod at time.variable),"\\right)",
-                      sprintf("d%s", mod at time.variable),
-                     "+ e",sprintf("d%s", noise.var),"\\left(",
-                     mod at time.variable, "\\right) \\\\ \n")
         dr<- paste(dr, "\\end{array}\\right.")
 #11/12
         for (i in 1:ns) {
@@ -69,7 +96,14 @@
         # Vector Latent Variable.
         
         body <- c(body, paste("$$"))
-        latent.lab0<-paste(info at Latent.var,0:(info at p-1),sep="_")
+        if(class(mod)=="yuima.carma"){
+          latent.lab0<-paste(info at Latent.var,0:(info at p-1),sep="_")
+        }else{
+          if(class(mod)=="yuima.cogarch"){
+              latent.lab0<-paste(info at Latent.var,1:info at q,sep="_")
+          }
+        }
+
         if(length(latent.lab0)==1){latent.lab<-latent.lab0}
         if(length(latent.lab0)==2){
           latent.lab0[1]<-paste(latent.lab0[1],"(",mod at time.variable,")",",\\ ",sep="")
@@ -99,11 +133,17 @@
         #b.nozeros <-c(0:info at q)
         
       #  ma.lab0<-paste(paste(info at ma.par,0:(info at q),sep="_"),collapse=", \\ ")
-        ma.lab0<-paste(info at ma.par,0:(info at q),sep="_")
-        
+        if(class(mod)=="yuima.carma"){
+          ma.lab0<-paste(info at ma.par,0:(info at q),sep="_")
+        }else{
+          if(class(mod)=="yuima.cogarch"){
+            ma.lab0<-paste(info at ma.par,1:(info at p),sep="_")
+          }
+        }
         #if(length(ma.lab0)==1){ma.lab1<-ma.lab0}
-        if(info at q>=0 && info at q<=1){
-          ma.lab1<-paste(ma.lab0,collapse=", \\ ")}
+        if(class(mod)=="yuima.carma"){
+          if(info at q>=0 && info at q<=1){
+            ma.lab1<-paste(ma.lab0,collapse=", \\ ")}
         #if(length(ma.lab0)==2){
 #         if(info at q==1){
 #           ma.lab0[1]<-paste(ma.lab0[1],",\\ ",sep="")
@@ -111,14 +151,30 @@
 #           ma.lab1<-ma.lab0
 #         }
         #if(length(ma.lab0)>2){
-        if(info at q>1){
-          ma.lab1<-paste(ma.lab0[1],
-                            ",\\ ","\\ldots",
-                            " \\ , \\ ",tail(ma.lab0,n=1))
+          if(info at q>1){
+            ma.lab1<-paste(ma.lab0[1],
+                              ",\\ ","\\ldots",
+                              " \\ , \\ ",tail(ma.lab0,n=1))
+          }
+        }else{
+          if(class(mod)=="yuima.cogarch"){
+            if(info at p>=0 && info at p<=2){
+              ma.lab1<-paste(ma.lab0,collapse=", \\ ")
+            }
+            if(info at p>2){
+              ma.lab1<-paste(ma.lab0[1],
+                             ",\\ ","\\ldots",
+                             " \\ , \\ ",tail(ma.lab0,n=1))
+            }
+          }  
         }
-        
-        
-        numb.zero<-(info at p-(info at q+1))
+        if(class(mod)=="yuima.carma"){  
+          numb.zero<-(info at p-(info at q+1))
+        }else{
+          if(class(mod)=="yuima.cogarch"){
+            numb.zero<-(info at q-info@p)
+          }
+        }
         if (numb.zero==0){ma.lab <- ma.lab1}
         if (numb.zero>0&&numb.zero<=2){
           zeros<- 0*c(1:numb.zero)
@@ -148,7 +204,12 @@
         
         if (!length(mod at jump.variable)==0){
           noise.coef <- mod at jump.coeff
-          vect.e0 <- substr(tail(noise.coef,n=1), 2, nchar(tail(noise.coef,n=1)) -1)
+          if(class(mod)=="yuima.carma"){
+            vect.e0 <- substr(tail(noise.coef,n=1), 18, nchar(tail(noise.coef,n=1)) -2)
+          }else{
+            vect.e0 <- substr(tail(noise.coef,n=1), 18, nchar(tail(noise.coef,n=1)) -2)
+          }
+          #vect.e0 <- substr(tail(noise.coef,n=1), 2, nchar(tail(noise.coef,n=1)) -1)
         } else{ 
           if(length(info at lin.par) != 0){
                 
@@ -169,12 +230,19 @@
   #           }
           }  
         }
-        
-        if (info at p==1){vect.e <- vect.e0}
-        if (info at p==2){vect.e <- paste("0, \\ ",vect.e0)}
-        if (info at p==3){vect.e <- paste("0, \\ 0, \\ ",vect.e0)}
-        if (info at p>3){vect.e <- paste("0, \\ \\ldots \\ , \\ 0, \\  ",vect.e0)}
-        
+        if(class(mod)=="yuima.carma"){
+          if (info at p==1){vect.e <- vect.e0}
+          if (info at p==2){vect.e <- paste("0, \\ ",vect.e0)}
+          if (info at p==3){vect.e <- paste("0, \\ 0, \\ ",vect.e0)}
+          if (info at p>3){vect.e <- paste("0, \\ \\ldots \\ , \\ 0, \\  ",vect.e0)}
+        }else{
+          if(class(mod)=="yuima.cogarch"){
+            if (info at q==1){vect.e <- vect.e0}
+            if (info at q==2){vect.e <- paste("0, \\ ",vect.e0)}
+            if (info at q==3){vect.e <- paste("0, \\ 0, \\ ",vect.e0)}
+            if (info at q>3){vect.e <- paste("0, \\ \\ldots \\ , \\ 0, \\  ",vect.e0)}
+          }
+        }
         coeff.e<- paste("e","=","\\left[",  vect.e , "\\right]'")
         
         for (i in 1:ns) {
@@ -188,36 +256,75 @@
         body <- c(body, paste("$$"))
         # Matrix A        
         body <- c(body, paste("$$"))
-        
-        if(info at p==1){
-          cent.col<-"c"
-          last.A<-paste(paste(paste("",info at ar.par,sep=" -"),info at p:1,sep="_"),collapse=" &")
+
+        if(class(mod)=="yuima.cogarch"){
+          Up.A<-NULL
         }
         
-        if(info at p==2){
-          cent.col<-"cc"
-          Up.A <-" 0 & 1 \\\\ \n"
-          last.A<-paste(paste(paste("",info at ar.par,sep=" -"),info at p:1,sep="_"),collapse=" &")
+        if(class(mod)=="yuima.carma"){
+          if(info at p==1){
+            cent.col<-"c"
+            last.A<-paste(paste(paste("",info at ar.par,sep=" -"),info at p:1,sep="_"),collapse=" &")
+          }
+        }else{
+          if(class(mod)=="yuima.cogarch"){ 
+            if(info at q==1){
+              cent.col<-"c"
+              last.A<-paste(paste(paste("",info at ar.par,sep=" -"),info at q:1,sep="_"),collapse=" &")
+            }
+          }
         }
-        
-        if(info at p==3){
-          cent.col<-"ccc"
-          Up.A <-" 0 & 1 & 0 \\\\ \n 0 & 0 & 1 \\\\ \n"
-          last.A<-paste(paste(paste("",info at ar.par,sep=" -"),info at p:1,sep="_"),collapse=" &")
-          
+       
+        if(class(mod)=="yuima.carma"){
+            if(info at p==2){
+              cent.col<-"cc"
+              Up.A <-" 0 & 1 \\\\ \n"
+              last.A<-paste(paste(paste("",info at ar.par,sep=" -"),info at p:1,sep="_"),collapse=" &")
+            }
+            
+            if(info at p==3){
+              cent.col<-"ccc"
+              Up.A <-" 0 & 1 & 0 \\\\ \n 0 & 0 & 1 \\\\ \n"
+              last.A<-paste(paste(paste("",info at ar.par,sep=" -"),info at p:1,sep="_"),collapse=" &")
+              
+            }
+            
+            if(info at p>3){
+              cent.col<-"cccc"
+              Up.A <-" 0 & 1 & \\ldots & 0 \\\\ \n \\vdots & \\vdots & \\ddots & \\vdots \\\\ \n 0 & 0 & \\ldots & 1 \\\\ \n"
+              dummy.ar<-paste(paste("",info at ar.par,sep=" -"),info at p:1,sep="_")
+              last.A <- paste(dummy.ar[1]," & ", dummy.ar[2]," & \\ldots &", tail(dummy.ar,n=1) )
+            
+            }
+        }else{
+          if(class(mod)=="yuima.cogarch"){ 
+              if(info at q==2){
+                cent.col<-"cc"
+                Up.A <-" 0 & 1 \\\\ \n"
+                last.A<-paste(paste(paste("",info at ar.par,sep=" -"),info at q:1,sep="_"),collapse=" &")
+              }
+              
+              if(info at q==3){
+                cent.col<-"ccc"
+                Up.A <-" 0 & 1 & 0 \\\\ \n 0 & 0 & 1 \\\\ \n"
+                last.A<-paste(paste(paste("",info at ar.par,sep=" -"),info at q:1,sep="_"),collapse=" &")
+                
+              }
+              
+              if(info at q>3){
+                cent.col<-"cccc"
+                Up.A <-" 0 & 1 & \\ldots & 0 \\\\ \n \\vdots & \\vdots & \\ddots & \\vdots \\\\ \n 0 & 0 & \\ldots & 1 \\\\ \n"
+                dummy.ar<-paste(paste("",info at ar.par,sep=" -"),info at q:1,sep="_")
+                last.A <- paste(dummy.ar[1]," & ", dummy.ar[2]," & \\ldots &", tail(dummy.ar,n=1) )
+                
+              }          
+          }
         }
-        
-        if(info at p>3){
-          cent.col<-"cccc"
-          Up.A <-" 0 & 1 & \\ldots & 0 \\\\ \n \\vdots & \\vdots & \\ddots & \\vdots \\\\ \n 0 & 0 & \\ldots & 1 \\\\ \n"
-          dummy.ar<-paste(paste("",info at ar.par,sep=" -"),info at p:1,sep="_")
-          last.A <- paste(dummy.ar[1]," & ", dummy.ar[2]," & \\ldots &", tail(dummy.ar,n=1) )
-        
-        }
+
         matrix.A <-paste(Up.A ,last.A," \\\\ \n",sep="")
         
         array.start<-paste0("\\begin{array}{",cent.col,"}\n",collapse="")
-        MATR.A<-paste("A ","=","\\left[",array.start,  matrix.A,  "\\end{array}\\right]'" )
+        MATR.A<-paste("A ","=","\\left[",array.start,  matrix.A,  "\\end{array}\\right]" )
         
         for (i in 1:ns) {
           MATR.A <- gsub(mysymb[i], myrepl[i], MATR.A, fixed = "TRUE")
@@ -230,7 +337,7 @@
         
         return(body)
         
-    } else{
+    } else{ 
     n.eq <- mod at equation.number
     dr <- paste("\\left(\\begin{array}{c}\n")
     for (i in 1:n.eq) {
@@ -325,4 +432,7 @@
 
 toLatex.yuima.model <- toLatex.yuima 
 
-toLatex.yuima.carma <- toLatex.yuima
\ No newline at end of file
+toLatex.yuima.carma <- toLatex.yuima
+
+toLatex.yuima.cogarch <- toLatex.yuima
+

Modified: pkg/yuima/man/setCogarch.Rd
===================================================================
--- pkg/yuima/man/setCogarch.Rd	2014-11-16 23:30:52 UTC (rev 353)
+++ pkg/yuima/man/setCogarch.Rd	2014-11-17 20:28:46 UTC (rev 354)
@@ -14,7 +14,7 @@
 
 \code{dGt = sqrt(Vt)dZt}
 
-\code{Vt = a0 + (a1 Yt(1) + ... + b(p) Yt(p))}
+\code{Vt = a0 + (a1 Yt(1) + ... + a(p) Yt(p))}
 
 \code{dYt(1) = Yt(2) dt}  
   
@@ -27,12 +27,12 @@
 
 }
 \usage{
-setCogarch(p, q, ar.par = "b", ma.par = "a", loc.par = "a0", Cogarch.var = "g", V.var = "v", Latent.var = "y", jump.variable = "z",  time.variable = "t", measure = NULL, measure.type = NULL, XinExpr = FALSE, startCogarch = 0, work = TRUE, ...)
+setCogarch(p, q, ar.par = "b", ma.par = "a", loc.par = "a0", Cogarch.var = "g", V.var = "v", Latent.var = "y", jump.variable = "z",  time.variable = "t", measure = NULL, measure.type = NULL, XinExpr = FALSE, startCogarch = 0, work = FALSE, ...)
 }
 %- maybe also 'usage' for other objects documented here.
 \arguments{
-  \item{p}{a non negative integer that is the number of the moving average coefficients.}
-  \item{q}{a non-negative integer that indicates the number of the autoregressive  coefficients.}
+  \item{p}{a non negative integer that is the number of the moving average coefficients of the Variance process.}
+  \item{q}{a non-negative integer that indicates the number of the autoregressive  coefficients of the Variance process.}
   \item{ar.par}{a character-string that is the label of the autoregressive coefficients.}
   \item{ma.par}{a character-string that is the label of the autoregressive coefficients.}
   \item{loc.par}{the location coefficient.}
@@ -49,8 +49,10 @@
   \item{\dots}{Arguments to be passed to \code{setCogarch} such as the slots of the \code{\link{yuima.model-class}}}
 }
 \details{
-Please refer to the vignettes and the examples or to the \pkg{yuimadocs} package.
+We remark that the 
 
+Please refer to the vignettes and the examples.
+
 An object of \code{\link{yuima.cogarch-class}} contains:
 
 \describe{    

Modified: pkg/yuima/man/toLatex.Rd
===================================================================
--- pkg/yuima/man/toLatex.Rd	2014-11-16 23:30:52 UTC (rev 353)
+++ pkg/yuima/man/toLatex.Rd	2014-11-17 20:28:46 UTC (rev 354)
@@ -4,15 +4,17 @@
 \alias{toLatex.yuima}
 \alias{toLatex.yuima.model}
 \alias{toLatex.yuima.carma}
+\alias{toLatex.yuima.cogarch}
 \description{
   These methods convert \code{\link{yuima-class}},
-   \code{\link{yuima.model-class}} or \code{\link{yuima.carma-class}} objects to character vectors with
+   \code{\link{yuima.model-class}}, \code{\link{yuima.carma-class}} or \code{\link{yuima.cogarch-class}} objects to character vectors with
    LaTeX markup.
 }
 \usage{
 \method{toLatex}{yuima}(object,\dots)
 \method{toLatex}{yuima.model}(object,\dots)
 \method{toLatex}{yuima.carma}(object,\dots)
+\method{toLatex}{yuima.cogarch}(object,\dots)
 }
 \arguments{
   \item{object}{object of a class yuima, yuima.model or yuima.carma.}
@@ -67,5 +69,14 @@
 carma1<-setCarma(p=3,q=1,loc.par="c",scale.par="s")
 str(carma1)
 toLatex(carma1)
+
+# A COGARCH(p=3,q=5) process.
+cogarch1<-setCogarch(p=3,q=5,
+                       measure=list(df=list("rNIG(z, mu00, bu00, 1, 0)")),
+                       measure.type="code")
+str(cogarch1)
+toLatex(cogarch1)
+
+
 }
 \keyword{misc}



More information about the Yuima-commits mailing list