[Pomp-commits] r613 - pkg/tests
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Tue Feb 14 20:25:35 CET 2012
Author: kingaa
Date: 2012-02-14 20:25:35 +0100 (Tue, 14 Feb 2012)
New Revision: 613
Added:
pkg/tests/partrans.R
pkg/tests/partrans.Rout.save
Log:
- add some units tests
Added: pkg/tests/partrans.R
===================================================================
--- pkg/tests/partrans.R (rev 0)
+++ pkg/tests/partrans.R 2012-02-14 19:25:35 UTC (rev 613)
@@ -0,0 +1,27 @@
+library(pomp)
+
+data(gompertz)
+
+pars <- coef(gompertz,transform=TRUE)
+tpars <- coef(gompertz,transform=FALSE)
+
+new.trans <- function (params, ...)
+{
+ params <- c(params[c("X.0","tau","sigma")], log(params[c("r","K")]))
+ names(params) <- c("X.0","tau","sigma","log.r","log.K")
+ params
+}
+
+new.inv.trans <- function (params, ...)
+{
+ params <- c(params[c("X.0","tau","sigma")], exp(params[c("log.r","log.K")]))
+ names(params) <- c("X.0","tau","sigma","r","K")
+ params
+}
+
+po <- pomp(gompertz,parameter.transform=new.trans,parameter.inv.transform=new.inv.trans)
+
+stopifnot(identical(pars,coef(po,transform=TRUE,names(pars))))
+
+print(tpars)
+print(coef(po))
Added: pkg/tests/partrans.Rout.save
===================================================================
--- pkg/tests/partrans.Rout.save (rev 0)
+++ pkg/tests/partrans.Rout.save 2012-02-14 19:25:35 UTC (rev 613)
@@ -0,0 +1,53 @@
+
+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(gompertz)
+>
+> pars <- coef(gompertz,transform=TRUE)
+> tpars <- coef(gompertz,transform=FALSE)
+>
+> new.trans <- function (params, ...)
++ {
++ params <- c(params[c("X.0","tau","sigma")], log(params[c("r","K")]))
++ names(params) <- c("X.0","tau","sigma","log.r","log.K")
++ params
++ }
+>
+> new.inv.trans <- function (params, ...)
++ {
++ params <- c(params[c("X.0","tau","sigma")], exp(params[c("log.r","log.K")]))
++ names(params) <- c("X.0","tau","sigma","r","K")
++ params
++ }
+>
+> po <- pomp(gompertz,parameter.transform=new.trans,parameter.inv.transform=new.inv.trans)
+>
+> stopifnot(identical(pars,coef(po,transform=TRUE,names(pars))))
+>
+> print(tpars)
+ X.0 log.r log.K log.tau log.sigma
+ 1.000000 -2.302585 0.000000 -2.302585 -2.302585
+> print(coef(po))
+ X.0 tau sigma log.r log.K
+ 1.000000 0.100000 0.100000 -2.302585 0.000000
+>
More information about the pomp-commits
mailing list