[Pomp-commits] r609 - pkg/tests

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Thu Feb 9 20:48:08 CET 2012


Author: kingaa
Date: 2012-02-09 20:48:08 +0100 (Thu, 09 Feb 2012)
New Revision: 609

Added:
   pkg/tests/ou2-mif-fp.R
   pkg/tests/ou2-mif-fp.Rout.save
Log:
- some unit tests for new 'mif' functionality


Added: pkg/tests/ou2-mif-fp.R
===================================================================
--- pkg/tests/ou2-mif-fp.R	                        (rev 0)
+++ pkg/tests/ou2-mif-fp.R	2012-02-09 19:48:08 UTC (rev 609)
@@ -0,0 +1,44 @@
+library(pomp)
+
+data(ou2)
+
+set.seed(64857673L)
+
+pdf(file="ou2-mif-fp.pdf")
+
+p.truth <- coef(ou2)
+guess2 <- guess1 <- p.truth
+guess1[c('x1.0','x2.0','alpha.2','alpha.3')] <- 0.25*guess1[c('x1.0','x2.0','alpha.2','alpha.3')]
+guess2[c('x1.0','x2.0','alpha.2','alpha.3')] <- 4*guess1[c('x1.0','x2.0','alpha.2','alpha.3')]
+
+mif1 <- mif(ou2,Nmif=100,start=guess1,
+	    pars=c('alpha.2','alpha.3'),ivps=c('x1.0','x2.0'),
+	    rw.sd=c(
+	    x1.0=5,x2.0=5,
+	    alpha.2=0.1,alpha.3=0.1
+	    ),
+	  Np=1000,
+	  var.factor=1,
+	  ic.lag=10,
+	  cooling.factor=0.95,
+	  max.fail=100,
+	  method="fp"
+	  )
+	  
+mif2 <- mif(ou2,Nmif=100,start=guess2,
+	    pars=c('alpha.2','alpha.3'),ivps=c('x1.0','x2.0'),
+	    rw.sd=c(
+	    x1.0=5,x2.0=5,
+	    alpha.2=0.1,alpha.3=0.1
+	    ),
+	  Np=1000,
+	  var.factor=1,
+	  ic.lag=10,
+	  cooling.factor=0.95,
+	  max.fail=100,
+	  method="fp"
+	  )
+	  
+compare.mif(list(mif1,mif2))
+
+dev.off()

Added: pkg/tests/ou2-mif-fp.Rout.save
===================================================================
--- pkg/tests/ou2-mif-fp.Rout.save	                        (rev 0)
+++ pkg/tests/ou2-mif-fp.Rout.save	2012-02-09 19:48:08 UTC (rev 609)
@@ -0,0 +1,68 @@
+
+R version 2.14.1 (2011-12-22)
+Copyright (C) 2011 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(ou2)
+> 
+> set.seed(64857673L)
+> 
+> pdf(file="ou2-mif-fp.pdf")
+> 
+> p.truth <- coef(ou2)
+> guess2 <- guess1 <- p.truth
+> guess1[c('x1.0','x2.0','alpha.2','alpha.3')] <- 0.25*guess1[c('x1.0','x2.0','alpha.2','alpha.3')]
+> guess2[c('x1.0','x2.0','alpha.2','alpha.3')] <- 4*guess1[c('x1.0','x2.0','alpha.2','alpha.3')]
+> 
+> mif1 <- mif(ou2,Nmif=100,start=guess1,
++ 	    pars=c('alpha.2','alpha.3'),ivps=c('x1.0','x2.0'),
++ 	    rw.sd=c(
++ 	    x1.0=5,x2.0=5,
++ 	    alpha.2=0.1,alpha.3=0.1
++ 	    ),
++ 	  Np=1000,
++ 	  var.factor=1,
++ 	  ic.lag=10,
++ 	  cooling.factor=0.95,
++ 	  max.fail=100,
++ 	  method="fp"
++ 	  )
+> 	  
+> mif2 <- mif(ou2,Nmif=100,start=guess2,
++ 	    pars=c('alpha.2','alpha.3'),ivps=c('x1.0','x2.0'),
++ 	    rw.sd=c(
++ 	    x1.0=5,x2.0=5,
++ 	    alpha.2=0.1,alpha.3=0.1
++ 	    ),
++ 	  Np=1000,
++ 	  var.factor=1,
++ 	  ic.lag=10,
++ 	  cooling.factor=0.95,
++ 	  max.fail=100,
++ 	  method="fp"
++ 	  )
+> 	  
+> compare.mif(list(mif1,mif2))
+> 
+> dev.off()
+null device 
+          1 
+> 



More information about the pomp-commits mailing list