[Pomp-commits] r479 - in pkg: . R
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Mon May 16 16:55:37 CEST 2011
Author: kingaa
Date: 2011-05-16 16:55:37 +0200 (Mon, 16 May 2011)
New Revision: 479
Modified:
pkg/DESCRIPTION
pkg/R/sannbox.R
pkg/R/sobol.R
pkg/R/spect-match.R
pkg/R/spect.R
Log:
- replace some instances of 'sapply' with 'vapply'
Modified: pkg/DESCRIPTION
===================================================================
--- pkg/DESCRIPTION 2011-05-13 15:02:48 UTC (rev 478)
+++ pkg/DESCRIPTION 2011-05-16 14:55:37 UTC (rev 479)
@@ -1,8 +1,8 @@
Package: pomp
Type: Package
Title: Statistical inference for partially observed Markov processes
-Version: 0.37-1
-Date: 2011-05-14
+Version: 0.37-2
+Date: 2011-05-16
Author: Aaron A. King, Edward L. Ionides, Carles Breto, Steve Ellner, Bruce Kendall, Helen Wearing, Matthew J. Ferrari, Michael Lavine, Daniel C. Reuman
Maintainer: Aaron A. King <kingaa at umich.edu>
URL: http://pomp.r-forge.r-project.org
Modified: pkg/R/sannbox.R
===================================================================
--- pkg/R/sannbox.R 2011-05-13 15:02:48 UTC (rev 478)
+++ pkg/R/sannbox.R 2011-05-16 14:55:37 UTC (rev 479)
@@ -32,7 +32,7 @@
control$sched <- function (k) control$temp/log(((k-1)%/%control$tmax)*control$tmax+exp(1))
if (is.function(control$sched))
- temps <- sapply(seq.int(from=1,to=control$maxit,by=1),control$sched)
+ temps <- vapply(seq_len(control$maxit),control$sched,numeric(1))
else if (is.numeric(control$sched))
temps <- control$sched
Modified: pkg/R/sobol.R
===================================================================
--- pkg/R/sobol.R 2011-05-13 15:02:48 UTC (rev 478)
+++ pkg/R/sobol.R 2011-05-16 14:55:37 UTC (rev 479)
@@ -5,11 +5,12 @@
stop("sobol error: each entry in ",sQuote("vars")," must specify a range")
d <- length(vars)
x <- .Call("sobol_sequence",as.integer(c(d,n)))
- y <- sapply(
- seq(length=d),
+ y <- vapply(
+ seq_len(d),
function (k) {
vars[[k]][1]+(vars[[k]][2]-vars[[k]][1])*x[k,]
- }
+ },
+ numeric(n)
)
colnames(y) <- names(vars)
as.data.frame(y)
Modified: pkg/R/spect-match.R
===================================================================
--- pkg/R/spect-match.R 2011-05-13 15:02:48 UTC (rev 478)
+++ pkg/R/spect-match.R 2011-05-16 14:55:37 UTC (rev 479)
@@ -151,7 +151,7 @@
if ((length(weights)!=length(ds$freq)))
stop("if ",sQuote("weights")," is provided as a vector, it must have length ",length(ds$freq))
} else if (is.function(weights)) {
- weights <- sapply(ds$freq,weights)
+ weights <- vapply(ds$freq,weights,numeric(1))
} else {
stop(sQuote("weights")," must be specified as a vector or as a function")
}
Modified: pkg/R/spect.R
===================================================================
--- pkg/R/spect.R 2011-05-13 15:02:48 UTC (rev 478)
+++ pkg/R/spect.R 2011-05-16 14:55:37 UTC (rev 479)
@@ -187,9 +187,10 @@
## L-2 distance between data and mean simulated spectrum
datdist <- sum((datspec[,j]-mean.simspec[,j])^2)
## L-2 distance betw. each sim. and mean simulated spectrum
- simdist <- sapply(
+ simdist <- vapply(
seq_len(nsim),
- function(k)sum((simspec[k,,j]-mean.simspec[,j])^2)
+ function(k)sum((simspec[k,,j]-mean.simspec[,j])^2),
+ numeric(1)
)
pvals[j] <- (nsim+1-sum(simdist<datdist))/(nsim+1)
totdatdist <- totdatdist+datdist
More information about the pomp-commits
mailing list