[Pomp-commits] r549 - in pkg: R inst tests

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Wed Aug 31 00:15:29 CEST 2011


Author: kingaa
Date: 2011-08-31 00:15:28 +0200 (Wed, 31 Aug 2011)
New Revision: 549

Modified:
   pkg/R/pfilter.R
   pkg/inst/NEWS
   pkg/tests/filtfail.Rout.save
   pkg/tests/pfilter.R
   pkg/tests/pfilter.Rout.save
Log:

- Bug fix: when 'pfilter' is called with a single parameter vector supplied in the 'params' argument, these parameters are copied into the 'params' slot of the resulting 'pfilterd.pomp' object.


Modified: pkg/R/pfilter.R
===================================================================
--- pkg/R/pfilter.R	2011-08-29 19:52:10 UTC (rev 548)
+++ pkg/R/pfilter.R	2011-08-30 22:15:28 UTC (rev 549)
@@ -68,7 +68,7 @@
   
   if (is.null(dim(params))) {
     one.par <- TRUE               # there is only one parameter vector
-    coef(object,names(params)) <- unname(params) # set params slot to the parameters
+    coef(object) <- params        # set params slot to the parameters
     params <- matrix(
                      params,
                      nrow=length(params),
@@ -259,7 +259,7 @@
       pparticles[[nt]] <- params
     }
 
-    if (verbose && ((ntimes-nt)%%5==0))
+    if (verbose && (nt%%5==0))
       cat("pfilter timestep",nt,"of",ntimes,"finished\n")
 
   }

Modified: pkg/inst/NEWS
===================================================================
--- pkg/inst/NEWS	2011-08-29 19:52:10 UTC (rev 548)
+++ pkg/inst/NEWS	2011-08-30 22:15:28 UTC (rev 549)
@@ -3,6 +3,8 @@
      o	When 'po' is a 'pomp'-class object with covariates, 'as.data.frame(po)' and 'as(po,"data.frame")' now contain columns for the covariates. 
      	The latter are interpolated, if necessary, at the observation times.
 
+     o	Bug fix: when 'pfilter' is called with a single parameter vector supplied in the 'params' argument, these parameters are copied into the 'params' slot of the resulting 'pfilterd.pomp' object.
+
 0.39-1
      o	New facilities for parameter transformation are provided.
      	New optional arguments 'parameter.transform' and 'parameter.inv.transform' to 'pomp' allow the user to specify transformations between natural and internal parameter scalings.

Modified: pkg/tests/filtfail.Rout.save
===================================================================
--- pkg/tests/filtfail.Rout.save	2011-08-29 19:52:10 UTC (rev 548)
+++ pkg/tests/filtfail.Rout.save	2011-08-30 22:15:28 UTC (rev 549)
@@ -110,11 +110,10 @@
 +               verbose=TRUE
 +               )
 filtering failure at time t = 4
-pfilter timestep 4 of 19 finished
-pfilter timestep 9 of 19 finished
-pfilter timestep 14 of 19 finished
+pfilter timestep 5 of 19 finished
+pfilter timestep 10 of 19 finished
+pfilter timestep 15 of 19 finished
 filtering failure at time t = 16
 filtering failure at time t = 17
 filtering failure at time t = 18
-pfilter timestep 19 of 19 finished
 > 

Modified: pkg/tests/pfilter.R
===================================================================
--- pkg/tests/pfilter.R	2011-08-29 19:52:10 UTC (rev 548)
+++ pkg/tests/pfilter.R	2011-08-30 22:15:28 UTC (rev 549)
@@ -16,6 +16,14 @@
 print(round(c(loglik=ll.est,loglik.se=ll.se),digits=2))
 
 data(euler.sir)
-pf <- pfilter(euler.sir,Np=200,seed=394343L)
+pf <- pfilter(euler.sir,Np=100,seed=394343L)
+print(coef(pf,transform=TRUE))
 print(pf$loglik,digits=4)
 
+p <- coef(euler.sir)
+euler.sir at params <- numeric(0)
+p["iota"] <- log(1)
+pf <- pfilter(euler.sir,params=p,Np=100,seed=394343L)
+print(coef(pf,transform=TRUE))
+print(logLik(pf),digits=4)
+

Modified: pkg/tests/pfilter.Rout.save
===================================================================
--- pkg/tests/pfilter.Rout.save	2011-08-29 19:52:10 UTC (rev 548)
+++ pkg/tests/pfilter.Rout.save	2011-08-30 22:15:28 UTC (rev 549)
@@ -43,8 +43,29 @@
   -479.61      0.46 
 > 
 > data(euler.sir)
-> pf <- pfilter(euler.sir,Np=200,seed=394343L)
+> pf <- pfilter(euler.sir,Np=100,seed=394343L)
+> print(coef(pf,transform=TRUE))
+       gamma           mu         iota       nbasis       degree       period 
+2.600000e+01 2.000000e-02 1.000000e-02 3.000000e+00 3.000000e+00 1.000000e+00 
+       beta1        beta2        beta3      beta.sd          pop          rho 
+1.200000e+03 1.800000e+03 6.000000e+02 1.000000e-03 2.100000e+06 6.000000e-01 
+         S.0          I.0          R.0 
+2.166667e-02 1.000000e-03 9.773333e-01 
 > print(pf$loglik,digits=4)
-[1] -884.2
+[1] -892.7
 > 
+> p <- coef(euler.sir)
+> euler.sir at params <- numeric(0)
+> p["iota"] <- log(1)
+> pf <- pfilter(euler.sir,params=p,Np=100,seed=394343L)
+> print(coef(pf,transform=TRUE))
+       gamma           mu         iota       nbasis       degree       period 
+2.600000e+01 2.000000e-02 1.000000e+00 3.000000e+00 3.000000e+00 1.000000e+00 
+       beta1        beta2        beta3      beta.sd          pop          rho 
+1.200000e+03 1.800000e+03 6.000000e+02 1.000000e-03 2.100000e+06 6.000000e-01 
+         S.0          I.0          R.0 
+2.166667e-02 1.000000e-03 9.773333e-01 
+> print(logLik(pf),digits=4)
+[1] -907.6
 > 
+> 



More information about the pomp-commits mailing list