[Yuima-commits] r174 - in pkg/yuima: R man
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Mon Aug 8 16:31:14 CEST 2011
Author: iacus
Date: 2011-08-08 16:31:14 +0200 (Mon, 08 Aug 2011)
New Revision: 174
Modified:
pkg/yuima/R/phi.test.R
pkg/yuima/man/phi.test.Rd
Log:
update phi.test
Modified: pkg/yuima/R/phi.test.R
===================================================================
--- pkg/yuima/R/phi.test.R 2011-08-08 13:40:59 UTC (rev 173)
+++ pkg/yuima/R/phi.test.R 2011-08-08 14:31:14 UTC (rev 174)
@@ -1,6 +1,11 @@
-phi.test <- function(yuima, H0, H1, phi=log, print=FALSE,...){
+phi.test <- function(yuima, H0, H1, phi, print=FALSE,...){
+ phiname <- deparse(substitute(phi))
+ if(missing(phi)){
+ phi <- function(x) 1-x+x*log(x)
+ phiname <- "1-x+x*log(x)"
+ }
d.size <- yuima at model@equation.number
n <- length(yuima)[1]
@@ -20,10 +25,11 @@
}
g0 <- exp(quasiloglvec(yuima=yuima, param=H0, print=print, env))
g1 <- exp(quasiloglvec(yuima=yuima, param=H1, print=print, env))
- div <- mean(phi(exp(g1-g0)), na.rm=TRUE)
- stat <- 2*sum(phi(exp(g1-g0)), na.rm=TRUE)
+ y <- exp(g1-g0)
+ div <- mean(phi(y), na.rm=TRUE)
+ stat <- 2*sum(phi(y), na.rm=TRUE)
df <- length(H0)
- val <- list(div=div, stat=stat, H0=H0, H1=H1, phi=deparse(substitute(phi)), pvalue=1-pchisq(stat, df=df), df=df,est=est)
+ val <- list(div=div, stat=stat, H0=H0, H1=H1, phi=phiname, phi=phi, pvalue=1-pchisq(stat, df=df), df=df,est=est)
attr(val, "class") <- "phitest"
return( val )
}
@@ -35,7 +41,7 @@
symnum(x$pvalue, corr = FALSE, na = FALSE,
cutpoints = c(0, 0.001, 0.01, 0.05, 0.1, 1),
symbols = c("***", "**", "*", ".", " "))->Signif
- cat(sprintf("Phi-Divergence test statistic based on phi function '%s'\n",x$phi) )
+ cat(sprintf("Phi-Divergence test statistic based on phi = '%s'\n",x$phi) )
nm <- names(x$H0)
cat("H0: ")
cat(sprintf("%s = %s", nm, format(x$H0,digits=3,nsmall=3)))
Modified: pkg/yuima/man/phi.test.Rd
===================================================================
--- pkg/yuima/man/phi.test.Rd 2011-08-08 13:40:59 UTC (rev 173)
+++ pkg/yuima/man/phi.test.Rd 2011-08-08 14:31:14 UTC (rev 174)
@@ -3,13 +3,13 @@
\title{Phi-divergence test statistic for stochastic differential equations}
\description{Phi-divergence test statistic for stochastic differential equations.}
\usage{
-phi.test(yuima, H0, H1, phi=log, print=FALSE,...)
+phi.test(yuima, H0, H1, phi, print=FALSE,...)
}
\arguments{
\item{yuima}{a yuima object.}
\item{H0}{a named list of parameter under H0.}
\item{H1}{a named list of parameter under H1.}
- \item{phi}{the phi function to be used in the test.}
+ \item{phi}{the phi function to be used in the test. See Details.}
\item{print}{you can see a progress of the estimation when print is \code{TRUE}.}
\item{...}{passed to \code{\link{qmle}} function.}
}
@@ -18,6 +18,8 @@
\code{phi.test} executes a Phi-divergence test. If \code{H1} is not specified
this hypothesis is filled with the QMLE estimates.
+ If \code{phi} is missing, then \code{phi(x)=1-x+x*log(x)} and the
+ Phi-divergence statistic corresponds to the likelihood ratio test statistic.
}
\value{
\item{ans}{an obkect of class \code{phitest}.}
More information about the Yuima-commits
mailing list