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

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Wed Jul 7 00:27:56 CEST 2010


Author: iacus
Date: 2010-07-07 00:27:56 +0200 (Wed, 07 Jul 2010)
New Revision: 87

Added:
   pkg/yuima/NEWS
   pkg/yuima/R/toLatex.R
   pkg/yuima/man/toLatex.Rd
Removed:
   pkg/yuima/inst/
Modified:
   pkg/yuima/DESCRIPTION
   pkg/yuima/NAMESPACE
   pkg/yuima/R/quasi-likelihood.R
   pkg/yuima/R/simulate.R
   pkg/yuima/R/yuima.sampling.R
Log:
added news and toLatex

Modified: pkg/yuima/DESCRIPTION
===================================================================
--- pkg/yuima/DESCRIPTION	2010-06-28 09:39:24 UTC (rev 86)
+++ pkg/yuima/DESCRIPTION	2010-07-06 22:27:56 UTC (rev 87)
@@ -1,9 +1,9 @@
 Package: yuima
 Type: Package
 Title: The YUIMA Project package (unstable version)
-Version: 0.0.90
-Date: 2010-06-28
-Depends: methods, zoo, stats4
+Version: 0.0.91
+Date: 2010-07-05
+Depends: methods, zoo, stats4, utils
 Suggests: adapt, mvtnorm
 Author: YUIMA Project Team.
 Maintainer: Stefano M. Iacus <stefano.iacus at R-project.org>

Modified: pkg/yuima/NAMESPACE
===================================================================
--- pkg/yuima/NAMESPACE	2010-06-28 09:39:24 UTC (rev 86)
+++ pkg/yuima/NAMESPACE	2010-07-06 22:27:56 UTC (rev 87)
@@ -5,6 +5,12 @@
 importFrom("zoo")
 importFrom(stats, confint)
 
+importFrom(utils, toLatex)
+
+
+
+
+
 exportClasses("yuima",
               "yuima.data",
               "yuima.sampling",
@@ -30,8 +36,6 @@
               "ml.ql",
               "adaBayes",
               "limiting.gamma",
-			  
-			  
 			  "getF",
 			  "getf",
 			  "getxinit",
@@ -87,3 +91,6 @@
 export(negquasilik)
 
 
+S3method(toLatex, yuima)
+S3method(toLatex, yuima.model)
+

Added: pkg/yuima/NEWS
===================================================================
--- pkg/yuima/NEWS	                        (rev 0)
+++ pkg/yuima/NEWS	2010-07-06 22:27:56 UTC (rev 87)
@@ -0,0 +1,11 @@
+Changes in Version 0.0.91
+
+  o added toLatex method for yuima objects.
+
+  o when simulate is executed, the xinit slot in
+    the return yuima object is set to the proper value.
+
+Changes in Version 1.0.90
+
+  o released first demo for R/Rmetrics conference, Meielisalp, 2010
+

Modified: pkg/yuima/R/quasi-likelihood.R
===================================================================
--- pkg/yuima/R/quasi-likelihood.R	2010-06-28 09:39:24 UTC (rev 86)
+++ pkg/yuima/R/quasi-likelihood.R	2010-07-06 22:27:56 UTC (rev 87)
@@ -1287,7 +1287,7 @@
 
 		yuima.warn(sprintf("NEG-QL: %f, %s", -QL, paste(names(param),param,sep="=",collapse=", ")))
 	}
-
+	if(is.infinite(QL)) return(1e10)
 	return(-QL)
 
 }

Modified: pkg/yuima/R/simulate.R
===================================================================
--- pkg/yuima/R/simulate.R	2010-06-28 09:39:24 UTC (rev 86)
+++ pkg/yuima/R/simulate.R	2010-07-06 22:27:56 UTC (rev 87)
@@ -212,7 +212,7 @@
 
  for(i in 1:length(yuima at data@zoo.data)) 
 		time(yuima at data@zoo.data[[i]]) <- yuima at sampling@grid[[1]]  ## to be fixed
-
+  yuima at model@xinit <- xinit
   if(missing(subsampling))
 		return(yuima)
   subsampling(yuima, subsampling)

Added: pkg/yuima/R/toLatex.R
===================================================================
--- pkg/yuima/R/toLatex.R	                        (rev 0)
+++ pkg/yuima/R/toLatex.R	2010-07-06 22:27:56 UTC (rev 87)
@@ -0,0 +1,73 @@
+
+toLatex.yuima <- function(object,...){
+	mod <- NULL
+	if(class(object)=="yuima.model") mod <- object
+	if(class(object)=="yuima") mod <- object at model
+ 	n.eq <- mod at equation.number
+	dr <- paste("\\left(\\begin{array}{c}\n")
+
+	for(i in 1:n.eq){
+		dr <- paste(dr, substr(mod at drift[i],2,nchar(mod at drift[i])-1), "\\\\ \n")
+	}
+	dr <- paste(dr, "\\end{array}\\right)", sprintf("d%s",mod at time.variable))
+
+	
+	df <- paste("\\left(\\begin{array}{c}\n")
+	
+	for(i in 1:n.eq){
+	  df <- paste(df, paste(mod at diffusion[[i]],collapse="+"))
+		
+	 
+	df <- paste(df, "\\\\ \n")
+        }
+	df <- paste(df, "\\end{array}\\right)")
+
+	n.n <- mod at noise.number
+	wn <- paste("\\left(\\begin{array}{c}\n")
+	wn <- paste(wn, paste(sprintf("dW%s",1:n.n), sep="", collapse="\\\\ "))
+	wn <- paste(wn, "\n \\end{array}\\right)")
+
+	st <- paste("\\left(\\begin{array}{c}\n")
+	st <- paste(st, paste(sprintf("d%s",mod at solve.variable), sep="", collapse="\\\\ "))
+	st <- paste(st, "\n \\end{array}\\right)")
+
+	mysymb <- c("*", "alpha", "beta", "gamma", "delta","rho","theta","sqrt")
+	myrepl<- c(" \\cdot ", "\\alpha ", "\\beta ", "\\gamma ", "\\delta ","\\rho ", "\\theta ", "\\sqrt ")
+	ns <- length(mysymb)
+
+	for(i in 1:ns){
+ 		dr <- gsub( mysymb[i], myrepl[i] , dr ,fixed="TRUE")
+		df <- gsub( mysymb[i], myrepl[i] , df ,fixed="TRUE")
+	}
+
+#	cat("$$\n")
+#	cat(st)
+#	cat("\n = \n")
+#	cat(dr)
+#	cat("\n +\n")
+#	cat(df)
+#	cat("'\n")
+#	cat(wn)
+#	cat("\n $$\n")
+#	cat("$$\n")
+#	cat(sprintf("%s(0)=%f,\\quad",mod at solve.variable,mod at xinit))
+#	cat("\n $$\n")
+
+	body <- paste("%%% Copy and paste the following output in your LaTeX file")
+	body <- body <- c(body,paste("$$"))
+	body <- c(body, paste(st))
+	body <- c(body, paste(" = "))
+	body <- c(body, paste(dr))
+	body <- c(body, paste(" +"))
+	body <- c(body, paste(df))
+	body <- c(body, paste("'"))
+	body <- c(body, paste(wn))
+	body <- c(body, paste("$$"))
+	body <- c(body, paste("$$"))
+	body <- c(body, paste(sprintf("%s(0)=%f,\\quad",mod at solve.variable,mod at xinit)))
+	body <- c(body, paste("$$"))
+	
+	structure(body, class="Latex")
+}
+
+toLatex.yuima.model <- toLatex.yuima 

Modified: pkg/yuima/R/yuima.sampling.R
===================================================================
--- pkg/yuima/R/yuima.sampling.R	2010-06-28 09:39:24 UTC (rev 86)
+++ pkg/yuima/R/yuima.sampling.R	2010-07-06 22:27:56 UTC (rev 87)
@@ -49,7 +49,7 @@
 # grid is missing, but random sampling					
 				if(!is.logical(random)){
 					.Object at regular <- FALSE
-					.Object at Terminal <- numeric(0)	
+					.Object at Terminal <- Terminal	
 					.Object at Initial <- Initial
 					.Object at n <- numeric(0)
 					.Object at delta <- numeric(0)	

Added: pkg/yuima/man/toLatex.Rd
===================================================================
--- pkg/yuima/man/toLatex.Rd	                        (rev 0)
+++ pkg/yuima/man/toLatex.Rd	2010-07-06 22:27:56 UTC (rev 87)
@@ -0,0 +1,64 @@
+\name{toLatex}
+\title{Additional Methods for LaTeX Representations for Yuima objects}
+\alias{toLatex}
+\alias{toLatex.yuima}
+\alias{toLatex.yuima.model}
+\description{
+  These methods convert \code{\link{yuima-class}} or
+   \code{\link{yuima.model-class}} objects to character vectors with
+   LaTeX markup.
+}
+\usage{
+\method{toLatex}{yuima}(object,\dots)
+\method{toLatex}{yuima.model}(object,\dots)
+}
+\arguments{
+  \item{object}{object of a class yuima or yuima.model.}
+  \item{\dots}{currently not used.}
+}
+\details{
+  This methos tries to convert a formal description of the model slot
+  of the yuima object into a LaTeX formula.
+  This is just a simple proof of concept and probably further LaTex 
+  manipulations for use in papers.
+  Copy and paste of the output of \code{toLatex} into a real LaTeX file
+  should do the job.
+} 
+\examples{
+# dXt = theta*Xt*dt + dWt
+mod1 <- setModel(drift="theta*y", diffusion=1, solve.variable=c("y"))
+str(mod1)
+toLatex(mod1)
+
+# A multi-dimensional (correlated) diffusion process. 
+# To describe the following model: 
+# X=(X1,X2,X3); dXt = U(t,Xt)dt + V(t)dWt
+# For drift coeffcient
+U <- c("-x1","-2*x2","-t*x3")
+# For diffusion coefficient of X1 
+v1 <- function(t) 0.5*sqrt(t)
+# For diffusion coefficient of X2
+v2 <- function(t) sqrt(t)
+# For diffusion coefficient of X3
+v3 <- function(t) 2*sqrt(t)
+# correlation
+rho <- function(t) sqrt(1/2)
+# coefficient matrix for diffusion term
+V <- matrix( c( "v1(t)",
+                "v2(t) * rho(t)",
+                "v3(t) * rho(t)",
+                "",
+                "v2(t) * sqrt(1-rho(t)^2)",
+                "",
+                "",
+                "",
+                "v3(t) * sqrt(1-rho(t)^2)" 
+               ), 3, 3)
+# Model sde using "setModel" function
+cor.mod <- setModel(drift = U, diffusion = V,
+state.variable=c("x1","x2","x3"), 
+solve.variable=c("x1","x2","x3") )
+str(cor.mod)
+toLatex(cor.mod)
+}
+\keyword{misc}



More information about the Yuima-commits mailing list