[Pomp-commits] r281 - in pkg: . R man

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Wed Jun 30 23:57:16 CEST 2010


Author: kingaa
Date: 2010-06-30 23:57:15 +0200 (Wed, 30 Jun 2010)
New Revision: 281

Added:
   pkg/R/traj-match.R
   pkg/man/traj-match.Rd
Removed:
   pkg/R/trajmatch.R
   pkg/man/trajmatch.Rd
Modified:
   pkg/DESCRIPTION
   pkg/man/mif-class.Rd
Log:
- minor rearrangements of files
- fix typo


Modified: pkg/DESCRIPTION
===================================================================
--- pkg/DESCRIPTION	2010-06-30 20:00:19 UTC (rev 280)
+++ pkg/DESCRIPTION	2010-06-30 21:57:15 UTC (rev 281)
@@ -17,7 +17,7 @@
 	 pomp-fun.R pomp.R pomp-methods.R rmeasure-pomp.R rprocess-pomp.R 
 	 dmeasure-pomp.R dprocess-pomp.R simulate-pomp.R skeleton-pomp.R 
 	 trajectory-pomp.R plot-pomp.R init.state-pomp.R 
-	 pfilter.R trajmatch.R bsmc.R
+	 pfilter.R traj-match.R bsmc.R
 	 mif-class.R particles-mif.R pfilter-mif.R mif.R mif-methods.R compare.mif.R 
 	 pmcmc.R pmcmc-methods.R compare.pmcmc.R
 	 nlf-funcs.R nlf-guts.R nlf-lql.R nlf-objfun.R nlf.R 

Copied: pkg/R/traj-match.R (from rev 277, pkg/R/trajmatch.R)
===================================================================
--- pkg/R/traj-match.R	                        (rev 0)
+++ pkg/R/traj-match.R	2010-06-30 21:57:15 UTC (rev 281)
@@ -0,0 +1,40 @@
+traj.match <- function (object, start, est, method = "Nelder-Mead", gr = NULL, ...) {
+  if (!is(object,'pomp'))
+    stop("traj.match error: ",sQuote("object")," must be a ",sQuote("pomp")," object",call.=FALSE)
+  if (is.character(est)) {
+    if (!all(est%in%names(start)))
+      stop("traj.match error: parameters named in ",sQuote("est")," must exist in ",sQuote("start"),call.=FALSE)
+    par.est <- which(names(start)%in%est)
+  } else if (is.numeric(est)) {
+    est <- as.integer(est)
+    if (any((est<1)|(est>length(start))))
+      stop("traj.match error: some index in ",sQuote("est")," corresponds to no parameters in ",sQuote("start"),call.=FALSE)
+    par.est <- as.integer(est)
+  }
+  guess <- start[par.est]
+  opt <- optim(
+               par=guess,
+               fn=function (x) {
+                 p <- start
+                 p[par.est] <- x
+                 x <- trajectory(object,params=p)[,,-1,drop=FALSE]
+                 d <- dmeasure(
+                               object,
+                               y=data.array(object),
+                               x=x,
+                               times=time(object),
+                               params=as.matrix(p),
+                               log=TRUE
+                               )
+                 -sum(d)
+               },
+               gr=gr,
+               method=method,
+               control=list(...)
+               )
+  opt$value <- -opt$value
+  start[par.est] <- opt$par
+  opt$params <- start
+  opt$par <- NULL
+  opt
+}

Deleted: pkg/R/trajmatch.R
===================================================================
--- pkg/R/trajmatch.R	2010-06-30 20:00:19 UTC (rev 280)
+++ pkg/R/trajmatch.R	2010-06-30 21:57:15 UTC (rev 281)
@@ -1,40 +0,0 @@
-traj.match <- function (object, start, est, method = "Nelder-Mead", gr = NULL, ...) {
-  if (!is(object,'pomp'))
-    stop("traj.match error: ",sQuote("object")," must be a ",sQuote("pomp")," object",call.=FALSE)
-  if (is.character(est)) {
-    if (!all(est%in%names(start)))
-      stop("traj.match error: parameters named in ",sQuote("est")," must exist in ",sQuote("start"),call.=FALSE)
-    par.est <- which(names(start)%in%est)
-  } else if (is.numeric(est)) {
-    est <- as.integer(est)
-    if (any((est<1)|(est>length(start))))
-      stop("traj.match error: some index in ",sQuote("est")," corresponds to no parameters in ",sQuote("start"),call.=FALSE)
-    par.est <- as.integer(est)
-  }
-  guess <- start[par.est]
-  opt <- optim(
-               par=guess,
-               fn=function (x) {
-                 p <- start
-                 p[par.est] <- x
-                 x <- trajectory(object,params=p)[,,-1,drop=FALSE]
-                 d <- dmeasure(
-                               object,
-                               y=data.array(object),
-                               x=x,
-                               times=time(object),
-                               params=as.matrix(p),
-                               log=TRUE
-                               )
-                 -sum(d)
-               },
-               gr=gr,
-               method=method,
-               control=list(...)
-               )
-  opt$value <- -opt$value
-  start[par.est] <- opt$par
-  opt$params <- start
-  opt$par <- NULL
-  opt
-}

Modified: pkg/man/mif-class.Rd
===================================================================
--- pkg/man/mif-class.Rd	2010-06-30 20:00:19 UTC (rev 280)
+++ pkg/man/mif-class.Rd	2010-06-30 21:57:15 UTC (rev 281)
@@ -8,7 +8,7 @@
   See \code{\link{mif}} for usage.
 }
 \section{Objects from the Class}{
-  Objects can be created by calls to the \code{\link{mif}} method on an \code{\link{pomp}} object.
+  Objects can be created by calls to the \code{\link{mif}} method on a \code{\link{pomp}} object.
   Such a call uses the MIF algorithm to fit the model parameters.
 }
 \section{Slots}{

Copied: pkg/man/traj-match.Rd (from rev 277, pkg/man/trajmatch.Rd)
===================================================================
--- pkg/man/traj-match.Rd	                        (rev 0)
+++ pkg/man/traj-match.Rd	2010-06-30 21:57:15 UTC (rev 281)
@@ -0,0 +1,55 @@
+\name{traj.match}
+\alias{traj.match}
+\title{Trajectory matching}
+\description{
+  Match trajectories.
+}
+\usage{
+traj.match(object, start, est, method = "Nelder-Mead", gr = NULL, \dots)
+}
+\arguments{
+  \item{object}{A \code{pomp} object.}
+  \item{start}{Initial guess for parameters.}
+  \item{est}{Character vector containing the names of parameters to be estimated.}
+  \item{method}{
+    One of the optimization methods recognized by \code{\link{optim}}.
+  }
+  \item{gr}{
+    Passed to \code{\link{optim}}.
+  }
+  \item{\dots}{
+    Arguments that will be passed to \code{\link{optim}} in the \code{control} list.
+  }
+}
+\details{
+  Trajectory matching is accomplished using \code{\link{optim}}.
+  The \code{\link{trajectory}} method is used for this, which in turn uses the \code{skeleton} slot of the \code{pomp} object.
+}
+\examples{
+  data(ou2)
+  true.p <- c(
+	      alpha.1=0.9,alpha.2=0,alpha.3=-0.4,alpha.4=0.99,
+	      sigma.1=2,sigma.2=0.1,sigma.3=2,
+	      tau=1,
+              x1.0=50,x2.0=-50
+	      )
+  simdata <- simulate(ou2,nsim=1,params=true.p,seed=43553)
+  guess.p <- true.p
+  res <- traj.match(
+		    simdata,
+		    start=guess.p,
+		    est=c('alpha.1','alpha.3','alpha.4','x1.0','x2.0','tau'),
+		    maxit=2000,
+		    method="Nelder-Mead",
+		    reltol=1e-8
+		    )
+
+}
+\seealso{
+  \code{\link{optim}},
+  \code{\link{trajectory}},
+  \code{\link{pomp}},
+  \code{\link{pomp-class}}
+}
+\keyword{models}
+\keyword{ts}

Deleted: pkg/man/trajmatch.Rd
===================================================================
--- pkg/man/trajmatch.Rd	2010-06-30 20:00:19 UTC (rev 280)
+++ pkg/man/trajmatch.Rd	2010-06-30 21:57:15 UTC (rev 281)
@@ -1,55 +0,0 @@
-\name{traj.match}
-\alias{traj.match}
-\title{Trajectory matching}
-\description{
-  Match trajectories.
-}
-\usage{
-traj.match(object, start, est, method = "Nelder-Mead", gr = NULL, \dots)
-}
-\arguments{
-  \item{object}{A \code{pomp} object.}
-  \item{start}{Initial guess for parameters.}
-  \item{est}{Character vector containing the names of parameters to be estimated.}
-  \item{method}{
-    One of the optimization methods recognized by \code{\link{optim}}.
-  }
-  \item{gr}{
-    Passed to \code{\link{optim}}.
-  }
-  \item{\dots}{
-    Arguments that will be passed to \code{\link{optim}} in the \code{control} list.
-  }
-}
-\details{
-  Trajectory matching is accomplished using \code{\link{optim}}.
-  The \code{\link{trajectory}} method is used for this, which in turn uses the \code{skeleton} slot of the \code{pomp} object.
-}
-\examples{
-  data(ou2)
-  true.p <- c(
-	      alpha.1=0.9,alpha.2=0,alpha.3=-0.4,alpha.4=0.99,
-	      sigma.1=2,sigma.2=0.1,sigma.3=2,
-	      tau=1,
-              x1.0=50,x2.0=-50
-	      )
-  simdata <- simulate(ou2,nsim=1,params=true.p,seed=43553)
-  guess.p <- true.p
-  res <- traj.match(
-		    simdata,
-		    start=guess.p,
-		    est=c('alpha.1','alpha.3','alpha.4','x1.0','x2.0','tau'),
-		    maxit=2000,
-		    method="Nelder-Mead",
-		    reltol=1e-8
-		    )
-
-}
-\seealso{
-  \code{\link{optim}},
-  \code{\link{trajectory}},
-  \code{\link{pomp}},
-  \code{\link{pomp-class}}
-}
-\keyword{models}
-\keyword{ts}



More information about the pomp-commits mailing list