[Pomp-commits] r97 - pkg/R
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Thu Apr 16 22:11:12 CEST 2009
Author: kingaa
Date: 2009-04-16 22:11:12 +0200 (Thu, 16 Apr 2009)
New Revision: 97
Modified:
pkg/R/mif-methods.R
pkg/R/mif.R
Log:
use rowMeans and colMeans in place of apply where appropriate
Modified: pkg/R/mif-methods.R
===================================================================
--- pkg/R/mif-methods.R 2009-04-16 12:24:10 UTC (rev 96)
+++ pkg/R/mif-methods.R 2009-04-16 20:11:12 UTC (rev 97)
@@ -61,7 +61,7 @@
npv <- pred.var(object,pars)/(object at random.walk.sd[pars]^2)
if (!is.null(dim(npv))) npv <- t(npv)
if (mean && !is.null(dim(npv)))
- npv <- apply(npv,1,mean)
+ npv <- rowMeans(npv)
if (!is.null(dim(npv))) {
matplot(time(object),npv,type=type,ylab='prediction variance',xlab='time',...)
legend(x='topright',legend=pars,col=1:length(pars),lty=1:length(pars),bty='n')
Modified: pkg/R/mif.R
===================================================================
--- pkg/R/mif.R 2009-04-16 12:24:10 UTC (rev 96)
+++ pkg/R/mif.R 2009-04-16 20:11:12 UTC (rev 97)
@@ -202,10 +202,10 @@
v <- x$pred.var[pars,,drop=FALSE] # the prediction variance
v1 <- cool.sched$gamma*(1+var.factor^2)*sigma[pars]^2
theta.hat <- cbind(theta[pars],x$filter.mean[pars,,drop=FALSE])
- theta[pars] <- theta[pars]+apply(apply(theta.hat,1,diff)/t(v),2,sum)*v1
+ theta[pars] <- theta[pars]+colSums(apply(theta.hat,1,diff)/t(v))*v1
} else { # unweighted (flat) average
theta.hat <- x$filter.mean[pars,,drop=FALSE]
- theta[pars] <- apply(theta.hat,1,mean)
+ theta[pars] <- rowMeans(theta.hat)
}
## update the IVPs using fixed-lag smoothing
More information about the pomp-commits
mailing list