[Pomp-commits] r630 - pkg/tests
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Tue Mar 27 14:03:58 CEST 2012
Author: kingaa
Date: 2012-03-27 14:03:57 +0200 (Tue, 27 Mar 2012)
New Revision: 630
Added:
pkg/tests/ricker-bsmc.R
pkg/tests/ricker-bsmc.Rout.save
Log:
- units tests for new 'bsmc' facilities
Added: pkg/tests/ricker-bsmc.R
===================================================================
--- pkg/tests/ricker-bsmc.R (rev 0)
+++ pkg/tests/ricker-bsmc.R 2012-03-27 12:03:57 UTC (rev 630)
@@ -0,0 +1,24 @@
+library(pomp)
+
+data(ricker)
+
+pdf(file="ricker-bsmc.pdf")
+
+set.seed(6457673L)
+
+po <- ricker
+
+Np <- 10000
+params <- parmat(coef(ricker),nrep=Np)
+params["log.r",] <- runif(n=Np,min=2,max=5)
+params["sigma",] <- runif(n=Np,min=0.1,max=1)
+
+fit <- bsmc(ricker,params=params,est=c("log.r","log.sigma"),transform=TRUE,smooth=0.2)
+
+print(apply(fit$prior[c("log.r","log.sigma"),],1,mean))
+
+print(apply(fit$post[c("log.r","log.sigma"),],1,mean))
+
+plot(fit,breaks=30,thin=300)
+
+dev.off()
Added: pkg/tests/ricker-bsmc.Rout.save
===================================================================
--- pkg/tests/ricker-bsmc.Rout.save (rev 0)
+++ pkg/tests/ricker-bsmc.Rout.save 2012-03-27 12:03:57 UTC (rev 630)
@@ -0,0 +1,55 @@
+
+R version 2.14.2 (2012-02-29)
+Copyright (C) 2012 The R Foundation for Statistical Computing
+ISBN 3-900051-07-0
+Platform: x86_64-unknown-linux-gnu (64-bit)
+
+R is free software and comes with ABSOLUTELY NO WARRANTY.
+You are welcome to redistribute it under certain conditions.
+Type 'license()' or 'licence()' for distribution details.
+
+R is a collaborative project with many contributors.
+Type 'contributors()' for more information and
+'citation()' on how to cite R or R packages in publications.
+
+Type 'demo()' for some demos, 'help()' for on-line help, or
+'help.start()' for an HTML browser interface to help.
+Type 'q()' to quit R.
+
+> library(pomp)
+Loading required package: mvtnorm
+Loading required package: subplex
+Loading required package: deSolve
+>
+> data(ricker)
+>
+> pdf(file="ricker-bsmc.pdf")
+>
+> set.seed(6457673L)
+>
+> po <- ricker
+>
+> Np <- 10000
+> params <- parmat(coef(ricker),nrep=Np)
+> params["log.r",] <- runif(n=Np,min=2,max=5)
+> params["sigma",] <- runif(n=Np,min=0.1,max=1)
+>
+> fit <- bsmc(ricker,params=params,est=c("log.r","log.sigma"),transform=TRUE,smooth=0.2)
+Warning message:
+In sample.int(n = Np, size = Np, replace = TRUE, prob = g) :
+ Walker's alias method used: results are different from R < 2.2.0
+>
+> print(apply(fit$prior[c("log.r","log.sigma"),],1,mean))
+ log.r log.sigma
+ 3.4894675 -0.7495206
+>
+> print(apply(fit$post[c("log.r","log.sigma"),],1,mean))
+ log.r log.sigma
+ 3.890965 -1.766350
+>
+> plot(fit,breaks=30,thin=300)
+>
+> dev.off()
+null device
+ 1
+>
More information about the pomp-commits
mailing list