[Pomp-commits] r632 - in pkg: R inst man
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Tue Mar 27 17:17:20 CEST 2012
Author: kingaa
Date: 2012-03-27 17:17:19 +0200 (Tue, 27 Mar 2012)
New Revision: 632
Modified:
pkg/R/bsmc.R
pkg/inst/TODO
pkg/man/bsmc.Rd
Log:
- fix bug in plot method for 'bmscd.pomp'
- parameter posterior means are now stored in the 'params' slot of 'bsmcd.pomp' objects
Modified: pkg/R/bsmc.R
===================================================================
--- pkg/R/bsmc.R 2012-03-27 14:20:08 UTC (rev 631)
+++ pkg/R/bsmc.R 2012-03-27 15:17:19 UTC (rev 632)
@@ -334,6 +334,9 @@
## prior <- partrans(object,prior,dir="forward")
## }
+ ## replace parameters with point estimate (posterior mean)
+ coef(object,transform=transform) <- apply(params,1,mean)
+
new(
"bsmcd.pomp",
object,
@@ -354,10 +357,9 @@
setMethod("$",signature(x="bsmcd.pomp"),function (x,name) slot(x,name))
-bsmc.plot <- function (prior, post, est, nbreaks, thin, ...) {
- if (missing(thin)) thin <- Inf
- prior <- t(prior[est,sample.int(n=nrow(prior),size=min(thin,nrow(prior)))])
- post <- t(post[est,sample.int(n=nrow(post),size=min(thin,nrow(post)))])
+bsmc.plot <- function (prior, post, est, breaks, thin, ...) {
+ prior <- t(prior[est,sample.int(n=ncol(prior),size=min(thin,ncol(prior)))])
+ post <- t(post[est,sample.int(n=ncol(post),size=min(thin,ncol(post)))])
all <- rbind(prior,post)
pairs(
all,
@@ -372,12 +374,12 @@
},
diag.panel=function (x, ...) { ## marginal posterior histogram
i <- which(x[1]==all[1,])
- breaks <- hist(c(post[,i],prior[,i]),breaks=nbreaks,plot=FALSE)$breaks
- y1 <- hist(post[,i],breaks=breaks,plot=FALSE)$counts
+ bks <- hist(c(post[,i],prior[,i]),breaks=breaks,plot=FALSE)$breaks
+ y1 <- hist(post[,i],breaks=bks,plot=FALSE)$counts
usr <- par('usr')
op <- par(usr=c(usr[1:2],0,1.5*max(y1)))
on.exit(par(op))
- rect(head(breaks,-1),0,tail(breaks,-1),y1,col=rgb(0,0,1,0.5),border=NA,...)
+ rect(head(bks,-1),0,tail(bks,-1),y1,col=rgb(0,0,1,1),border=NA,...)
}
)
}
@@ -385,6 +387,9 @@
setMethod(
"plot",
signature(x="bsmcd.pomp"),
- function (x, ..., thin, breaks) bsmc.plot(prior=x at prior,post=x at post,est=x at est,
- nbreaks=breaks,thin=thin,...)
+ function (x, ..., breaks, thin) {
+ if (missing(thin)) thin <- Inf
+ if (missing(breaks)) breaks <- 30
+ bsmc.plot(prior=x at prior,post=x at post,est=x at est,breaks=breaks,thin=thin,...)
+ }
)
Modified: pkg/inst/TODO
===================================================================
--- pkg/inst/TODO 2012-03-27 14:20:08 UTC (rev 631)
+++ pkg/inst/TODO 2012-03-27 15:17:19 UTC (rev 632)
@@ -7,7 +7,7 @@
* native C routine for vectorfield evaluation inside lsoda
* parameter transformations: put 'transform' option into each estimation routine
- (bsmc, mif, pmcmc, nlf, *.match)
+ (spect.match)
* unit tests for above
Modified: pkg/man/bsmc.Rd
===================================================================
--- pkg/man/bsmc.Rd 2012-03-27 14:20:08 UTC (rev 631)
+++ pkg/man/bsmc.Rd 2012-03-27 15:17:19 UTC (rev 632)
@@ -78,6 +78,7 @@
}
\value{
An object of class \dQuote{bsmcd.pomp}.
+ The \dQuote{params} slot of this object will hold the parameter posterior means.
The slots of this class include:
\item{post}{
A matrix containing draws from the approximate posterior distribution.
More information about the pomp-commits
mailing list