[Pomp-commits] r170 - in pkg: R man

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Wed Oct 7 22:36:47 CEST 2009


Author: kingaa
Date: 2009-10-07 22:36:46 +0200 (Wed, 07 Oct 2009)
New Revision: 170

Modified:
   pkg/R/slice.R
   pkg/man/slice.Rd
   pkg/man/sobol.Rd
Log:
- add a new function: profile.design, to aid in construction of likelihood profiles


Modified: pkg/R/slice.R
===================================================================
--- pkg/R/slice.R	2009-09-30 02:14:38 UTC (rev 169)
+++ pkg/R/slice.R	2009-10-07 20:36:46 UTC (rev 170)
@@ -19,3 +19,18 @@
   y$slice <- as.factor(rep(names(vars)[varying],each=n))
   y
 }
+
+profile.design <- function (..., vars, n) {
+  prof <- list(...)
+  y <- as.matrix(sobol(vars,n))
+  x <- as.matrix(do.call(expand.grid,prof))
+  z <- array(dim=c(nrow(x),nrow(y),ncol(x)+ncol(y)))
+  for (j in 1:nrow(x)) {
+    for (k in 1:nrow(y)) {
+      z[j,k,] <- c(x[j,],y[k,])
+    }
+  }
+  dim(z) <- c(nrow(x)*nrow(y),ncol(x)+ncol(y))
+  colnames(z) <- c(colnames(x),colnames(y))
+  as.data.frame(z)
+}

Modified: pkg/man/slice.Rd
===================================================================
--- pkg/man/slice.Rd	2009-09-30 02:14:38 UTC (rev 169)
+++ pkg/man/slice.Rd	2009-10-07 20:36:46 UTC (rev 170)
@@ -1,29 +1,59 @@
 \name{slice.design}
 \alias{slice.design}
-\title{Slices through multidimensional parameter space}
+\alias{profile.design}
+\title{Design matrices for likelihood slices and profiles}
 \description{
-  Generate a data-frame representing points taken along one or more slices through a point in a multidimensional space.
+  \code{slice.design} generates a data-frame representing points taken along one or more slices through a point in a multidimensional space.
+  \code{profile.design} generates a data-frame where each row can be used as the starting point for a profile likelihood calculation.
 }
 \usage{
 slice.design(vars, n)
+profile.design(\dots, vars, n)
 }
 \arguments{
+  \item{\dots}{
+    Specifies the parameters over which to profile.
+  }
   \item{vars}{
-    Named list of numeric vectors, each of which has length either 1 or 3.
+    For the \code{slice.design} case:
+    \code{vars} is a named list of numeric vectors, each of which has length either 1 or 3.
     Variables along which slices are to be taken should have length 3, corresponding to the minimum of the range, central point, and maximum of the range.
     For fixed variables, specify just the value.
+
+    For the \code{profile.design} case:
+    Named list of numeric vectors, each of which has length 2, specifying the range over which the parameter is to be sampled.
   }
-  \item{n}{Number of points per slice.}
+  \item{n}{
+    In the case of \code{slice.design}, the number of points per slice.
+    In the case of \code{profile.design}, the number of starts per profile point.
+  }
 }
 \value{
   \code{slice.design} returns a data frame with \code{n} points per slice.
   The column \code{slice} is a factor that tells which slice each point belongs to. 
+
+  \code{profile.design} returns a data frame with \code{n} points per profile point.
+  The parameters in \code{vars} are sampled using \code{sobol}.
 }
+\seealso{\code{\link{sobol}}}
 \author{Aaron A. King \email{kingaa at umich dot edu}}
 \examples{
 ## A single 11-point slice through the point c(A=3,B=8,C=0) along the B direction.
-slice.design(list(A=3,B=c(0,8,10),C=0),n=11)
+x <- slice.design(list(A=3,B=c(0,8,10),C=0),n=11)
+dim(x)
+plot(x)
 ## Two slices through the same point along the A and C directions.
-slice.design(list(A=c(0,3,5),B=8,C=c(0,0,5)),n=11)
+x <- slice.design(list(A=c(0,3,5),B=8,C=c(0,0,5)),n=11)
+dim(x)
+plot(x)
+
+## A one-parameter profile design:
+x <- profile.design(p=1:10,vars=list(a=c(0,1),b=c(0,5)),n=20)
+dim(x)
+plot(x)
+## A two-parameter profile design:
+x <- profile.design(p=1:10,q=3:5,vars=list(a=c(0,1),b=c(0,5)),n=20)
+dim(x)
+plot(x)
 }
 \keyword{design}

Modified: pkg/man/sobol.Rd
===================================================================
--- pkg/man/sobol.Rd	2009-09-30 02:14:38 UTC (rev 169)
+++ pkg/man/sobol.Rd	2009-10-07 20:36:46 UTC (rev 170)
@@ -21,6 +21,7 @@
   Numerical Recipes in C,
   Cambridge University Press, 1992
 }
+\seealso{\code{\link{slice.design}}, \code{\link{profile.design}}}
 \author{Aaron A. King \email{kingaa at umich dot edu}}
 \examples{
 plot(sobol(vars=list(a=c(0,1),b=c(100,200)),100))



More information about the pomp-commits mailing list