[Pomp-commits] r580 - in pkg: R man
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Sun Jan 8 22:36:41 CET 2012
Author: kingaa
Date: 2012-01-08 22:36:40 +0100 (Sun, 08 Jan 2012)
New Revision: 580
Added:
pkg/R/parmat.R
pkg/man/parmat.Rd
Log:
- the 'parmat' function to construct parameter matrices in one line
Added: pkg/R/parmat.R
===================================================================
--- pkg/R/parmat.R (rev 0)
+++ pkg/R/parmat.R 2012-01-08 21:36:40 UTC (rev 580)
@@ -0,0 +1,5 @@
+parmat <- function (params, nrep = 1) {
+ p <- matrix(data=params,nrow=length(params),ncol=nrep)
+ rownames(p) <- names(params)
+ p
+}
Added: pkg/man/parmat.Rd
===================================================================
--- pkg/man/parmat.Rd (rev 0)
+++ pkg/man/parmat.Rd 2012-01-08 21:36:40 UTC (rev 580)
@@ -0,0 +1,29 @@
+\name{parmat}
+\alias{parmat}
+\title{Create a matrix of parameters}
+\description{
+ \code{parmat} is a utility that makes a vector of parameters suitable for use in \pkg{pomp} functions.
+}
+\usage{
+parmat(params, nrep = 1)
+}
+\arguments{
+ \item{params}{
+ named numeric vector of parameters.
+ }
+ \item{nrep}{
+ number of replicates (columns) desired.
+ }
+}
+\value{
+ \code{parmat} returns a matrix consisting of \code{nrep} copies of \code{params} and rownames identical to the names of \code{params}.
+}
+\author{Aaron A. King \email{kingaa at umich dot edu}}
+\examples{
+ ## generate a bifurcation diagram for the Ricker map
+ data(ricker)
+ p <- parmat(coef(ricker),nrep=500)
+ p["log.r",] <- seq(from=1.5,to=4,length=500)
+ x <- trajectory(ricker,times=seq(from=1000,to=2000,by=1),params=p)
+ matplot(p["log.r",],x["N",,],pch='.',col='black',xlab="log(r)",ylab="N")
+}
More information about the pomp-commits
mailing list