[Yuima-commits] r269 - in pkg/yuima: . R man
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Wed Jan 22 13:56:16 CET 2014
Author: lorenzo
Date: 2014-01-22 13:56:16 +0100 (Wed, 22 Jan 2014)
New Revision: 269
Added:
pkg/yuima/man/CarmaRecovNoise.Rd
Modified:
pkg/yuima/DESCRIPTION
pkg/yuima/NAMESPACE
pkg/yuima/R/qmle.R
pkg/yuima/man/qmle.Rd
pkg/yuima/man/yuima.carma-class.Rd
Log:
Added Documentation for CarmaRecovNoise,
CarmaRecovNoise works internally in qmle for recovering Levy
Modified: pkg/yuima/DESCRIPTION
===================================================================
--- pkg/yuima/DESCRIPTION 2014-01-21 21:49:22 UTC (rev 268)
+++ pkg/yuima/DESCRIPTION 2014-01-22 12:56:16 UTC (rev 269)
@@ -1,7 +1,7 @@
Package: yuima
Type: Package
Title: The YUIMA Project package (unstable version)
-Version: 0.1.220
+Version: 0.1.221
Date: 2014-01-13
Depends: methods, zoo, stats4, utils, Matrix
Suggests: cubature, mvtnorm
Modified: pkg/yuima/NAMESPACE
===================================================================
--- pkg/yuima/NAMESPACE 2014-01-21 21:49:22 UTC (rev 268)
+++ pkg/yuima/NAMESPACE 2014-01-22 12:56:16 UTC (rev 269)
@@ -110,6 +110,8 @@
export(qmleR)
export(qmleL)
+export(CarmaRecovNoise) # Estimates the Levy in carma model
+
export(qgv)
export(mmfrac)
Modified: pkg/yuima/R/qmle.R
===================================================================
--- pkg/yuima/R/qmle.R 2014-01-21 21:49:22 UTC (rev 268)
+++ pkg/yuima/R/qmle.R 2014-01-22 12:56:16 UTC (rev 269)
@@ -518,11 +518,15 @@
#if(!is(yuima at model,"yuima.carma")){
names(par) <- unique(c(diff.par, drift.par))
nm <- unique(c(diff.par, drift.par))
- if(is(yuima at model,"yuima.carma") && (NoNeg.Noise==TRUE)){
- nm <-c(nm,mean.noise)
+ if(is(yuima at model,"yuima.carma") && length(yuima at model@parameter at measure)!=0){
nm <-c(nm,measure.par)
+ if((NoNeg.Noise==TRUE)){nm <-c(nm,mean.noise)}
+
nm<-unique(nm)
}
+ if(is(yuima at model,"yuima.carma") && (length(yuima at model@info at loc.par)!=0)){
+ nm <-unique(c(nm,yuima at model@info at loc.par))
+ }
#}
# print(par)
# print(coef)
@@ -701,7 +705,7 @@
if(is(yuima at model, "yuima.carma") && length(yuima at model@info at lin.par)==0
&& length(yuima at model@parameter at jump)!=0){
diff.par<-yuima at model@parameter at jump
- measure.par<-yuima at model@parameter at measure
+ # measure.par<-yuima at model@parameter at measure
}
if(is(yuima at model, "yuima.carma") && length(yuima at model@info at lin.par)==0
@@ -891,6 +895,15 @@
} else{sigma <- 1}
loc.par <- yuima at model@info at loc.par
mu <- param[loc.par]
+
+ NoNeg.Noise<-FALSE
+ if(is(yuima at model,"yuima.carma")){
+ if("mean.noise" %in% names(param)){
+
+ NoNeg.Noise<-TRUE
+ }
+ }
+
# Lines 883:840 work if we have a no negative noise
if(is(yuima at model,"yuima.carma")&&(NoNeg.Noise==TRUE)){
if (length(b)==p){
Added: pkg/yuima/man/CarmaRecovNoise.Rd
===================================================================
--- pkg/yuima/man/CarmaRecovNoise.Rd (rev 0)
+++ pkg/yuima/man/CarmaRecovNoise.Rd 2014-01-22 12:56:16 UTC (rev 269)
@@ -0,0 +1,131 @@
+\name{CarmaRecovNoise}
+\alias{Recovering.Noise}
+\alias{Carma.Recovering}
+\alias{CarmaRecovNoise}
+\alias{Levy.Carma}
+\title{Estimation for the underlying Levy in a carma model}
+\description{Retrieve the increment of the underlying Levy for the carma(p,q) process using the approach developed in Brockwell et al.(2011)}
+\usage{
+CarmaRecovNoise(yuima, param, data=NULL, NoNeg.Noise=FALSE)
+}
+\arguments{
+ \item{yuima}{a yuima object or an object of \code{\link{yuima.carma-class}}.}
+ \item{param}{\code{list} of parameters for the carma.}
+ \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 'CarmaRecovNoise' uses the data in an object of \code{\link{yuima.data-class}}.}
+ \item{NoNeg.Noise}{Estimate a non-negative Levy-Driven Carma process. By default \code{NoNeg.Noise=FALSE}.}
+}
+\value{
+ %\item{QL}{a real value.}
+ \item{incr.Levy}{a numeric object contains the estimated increments.}
+ }
+\author{The YUIMA Project Team}
+\note{
+ %The function ml.ql uses the function optim internally.
+ The function \code{qmle} uses the function \code{CarmaRecovNoise} for estimation of underlying Levy in the carma model.
+}
+
+ \references{
+ Brockwell, P., Davis, A. R. and Yang. Y. (2011)
+Estimation for Non-Negative Levy-Driven CARMA Process, \emph{Journal of Business And Economic Statistics}, \bold{29} - 2, 250-259.
+}
+
+
+\examples{
+#Ex.1: Carma(p=3, q=0) process driven by a brownian motion.
+
+mod0<-setCarma(p=3,q=0)
+
+# We fix the autoregressive and moving average parameters
+# to ensure the existence of a second order stationary solution for the process.
+
+true.parm0 <-list(a1=4,a2=4.75,a3=1.5,b0=1)
+
+# We simulate a trajectory of the Carma model.
+
+numb.sim<-1000
+samp0<-setSampling(Terminal=100,n=numb.sim)
+set.seed(100)
+incr.W<-matrix(rnorm(n=numb.sim,mean=0,sd=sqrt(100/numb.sim)),1,numb.sim)
+
+sim0<-simulate(mod0,
+ true.parameter=true.parm0,
+ sampling=samp0, increment.W=incr.W)
+
+#Applying the CarmaRecovNoise
+
+system.time(
+ inc.Levy0<-CarmaRecovNoise(sim0,true.parm0)
+)
+
+# We compare the orginal with the estimated noise increments
+
+par(mfrow=c(1,2))
+plot(t(incr.W)[1:998],type="l", ylab="",xlab="time")
+title(main="True Brownian Motion",font.main="1")
+plot(inc.Levy0,type="l", main="Filtered Brownian Motion",font.main="1",ylab="",xlab="time")
+
+# Ex.2: carma(2,1) driven by a compound poisson
+# where jump size is normally distributed and
+# the lambda is equal to 1.
+
+mod1<-setCarma(p=2,
+ q=1,
+ measure=list(intensity="Lamb",df=list("dnorm(z, 0, 1)")),
+ measure.type="CP")
+
+true.parm1 <-list(a1=1.39631, a2=0.05029,
+ b0=1,b1=2,
+ Lamb=1)
+
+# We generate a sample path.
+
+samp1<-setSampling(Terminal=100,n=200)
+set.seed(123)
+sim1<-simulate(mod1,
+ true.parameter=true.parm1,
+ sampling=samp1)
+
+# We estimate the parameter using qmle.
+carmaopt1 <- qmle(sim1, start=true.parm1)
+summary(carmaopt1$mle)
+# Internally qmle uses CarmaRecovNoise. The result is in
+carmaopt1$Incr->inc.Levy1
+plot(inc.Levy1)
+
+# Ex.3: Carma(p=2,q=1) with scale and location parameters
+# driven by a Compound Poisson
+# with jump size normally distributed.
+mod2<-setCarma(p=2,
+ q=1,
+ loc.par="mu",
+ scale.par="sig",
+ measure=list(intensity="Lamb",df=list("dnorm(z, 0, 1)")),
+ measure.type="CP")
+
+true.parm2 <-list(a1=1.39631,
+ a2=0.05029,
+ b0=1,
+ b1=2,
+ Lamb=1,
+ mu=0.5,
+ sig=0.23)
+# We simulate the sample path
+set.seed(123)
+sim2<-simulate(mod2,
+ true.parameter=true.parm2,
+ sampling=samp1)
+
+# We estimate the Carma and we plot the underlying noise.
+
+carmaopt2 <- qmle(sim2, start=true.parm2)
+summary(carmaopt2$mle)
+
+carmaopt2$Incr->inc.Levy2
+# Increments estimated by CarmaRecovNoise
+plot(inc.Levy2)
+}
+
+
+% Add one or more standard keywords, see file 'KEYWORDS' in the
+% R documentation directory.
+\keyword{ts}
Modified: pkg/yuima/man/qmle.Rd
===================================================================
--- pkg/yuima/man/qmle.Rd 2014-01-21 21:49:22 UTC (rev 268)
+++ pkg/yuima/man/qmle.Rd 2014-01-22 12:56:16 UTC (rev 269)
@@ -69,6 +69,8 @@
\note{
%The function ml.ql uses the function optim internally.
The function qmle uses the function optim internally.
+
+ The function qmle uses the function \code{\link{CarmaRecovNoise}} internally for estimation of underlying Levy if the model is an object of \code{\link{yuima.carma-class}}.
}
\examples{
#dXt^e = -theta2 * Xt^e * dt + theta1 * dWt
Modified: pkg/yuima/man/yuima.carma-class.Rd
===================================================================
--- pkg/yuima/man/yuima.carma-class.Rd 2014-01-21 21:49:22 UTC (rev 268)
+++ pkg/yuima/man/yuima.carma-class.Rd 2014-01-22 12:56:16 UTC (rev 269)
@@ -52,7 +52,8 @@
\describe{
\item{simulate}{simulation method. For more information see
\code{\link{simulate}}.}
- \item{toLatex}{This method converts an object of \code{yuima.carma-class} to character vectors with LaTeX markup.}
+ \item{toLatex}{This method converts an object of \code{yuima.carma-class} to character vectors with LaTeX markup.}
+ \item{CarmaRecovNoise}{Recovering underlying Levy. For more information see \code{\link{CarmaRecovNoise}}. }
}
}
\author{The YUIMA Project Team}
More information about the Yuima-commits
mailing list