[Pomp-commits] r553 - in pkg: R tests

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Wed Aug 31 15:51:08 CEST 2011


Author: kingaa
Date: 2011-08-31 15:51:08 +0200 (Wed, 31 Aug 2011)
New Revision: 553

Modified:
   pkg/R/traj-match.R
   pkg/tests/ou2-trajmatch.R
   pkg/tests/ou2-trajmatch.Rout.save
Log:

- fix bug in 'traj.match' to do with parameters not being saved when the pomp object had an empty 'params' slot


Modified: pkg/R/traj-match.R
===================================================================
--- pkg/R/traj-match.R	2011-08-31 01:22:27 UTC (rev 552)
+++ pkg/R/traj-match.R	2011-08-31 13:51:08 UTC (rev 553)
@@ -45,7 +45,7 @@
 
   t0 <- timezero(object)
   obj <- as(object,"pomp")
-  coef(obj,names(start)) <- unname(start)
+  coef(obj) <- start
   pmat <- as.matrix(start)
 
   obj.fn <- function (x, object, params, t0, ind) {

Modified: pkg/tests/ou2-trajmatch.R
===================================================================
--- pkg/tests/ou2-trajmatch.R	2011-08-31 01:22:27 UTC (rev 552)
+++ pkg/tests/ou2-trajmatch.R	2011-08-31 13:51:08 UTC (rev 553)
@@ -37,3 +37,23 @@
 summary(traj.match(ou2,est=c('alpha.1','alpha.4','x1.0','x2.0','tau'),method="sannbox",trace=3,parscale=0.1,maxit=100))
 
 summary(traj.match(ou2,est=c('alpha.1','alpha.4','x1.0','x2.0','tau'),eval.only=T))
+
+data(ou2)
+p <- coef(ou2)
+ou2 at params <- numeric(0)
+res <- traj.match(
+                  ou2,
+                  start=p,
+                  est=c('alpha.1','alpha.4','x1.0','x2.0','tau'),
+                  eval.only=TRUE
+                  )
+print(coef(res),digits=4)
+res <- traj.match(
+                  ou2,
+                  start=p,
+                  est=c('alpha.1','alpha.4','x1.0','x2.0','tau'),
+                  maxit=2000,
+                  reltol=1e-8
+                  )
+print(coef(res),digits=4)
+print(coef(ou2),digist=4)

Modified: pkg/tests/ou2-trajmatch.Rout.save
===================================================================
--- pkg/tests/ou2-trajmatch.Rout.save	2011-08-31 01:22:27 UTC (rev 552)
+++ pkg/tests/ou2-trajmatch.Rout.save	2011-08-31 13:51:08 UTC (rev 553)
@@ -324,3 +324,30 @@
 [1] "no optimization performed"
 
 > 
+> data(ou2)
+> p <- coef(ou2)
+> ou2 at params <- numeric(0)
+> res <- traj.match(
++                   ou2,
++                   start=p,
++                   est=c('alpha.1','alpha.4','x1.0','x2.0','tau'),
++                   eval.only=TRUE
++                   )
+> print(coef(res),digits=4)
+alpha.1 alpha.2 alpha.3 alpha.4 sigma.1 sigma.2 sigma.3     tau    x1.0    x2.0 
+    0.8    -0.5     0.3     0.9     3.0    -0.5     2.0     1.0    -3.0     4.0 
+> res <- traj.match(
++                   ou2,
++                   start=p,
++                   est=c('alpha.1','alpha.4','x1.0','x2.0','tau'),
++                   maxit=2000,
++                   reltol=1e-8
++                   )
+> print(coef(res),digits=4)
+ alpha.1  alpha.2  alpha.3  alpha.4  sigma.1  sigma.2  sigma.3      tau 
+ 0.09353 -0.50000  0.30000  0.98212  3.00000 -0.50000  2.00000  5.36145 
+    x1.0     x2.0 
+-3.26255  2.17644 
+> print(coef(ou2),digist=4)
+numeric(0)
+> 



More information about the pomp-commits mailing list