[Rcpp-commits] r4248 - in pkg/RcppSMC: . R

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Mon Feb 11 03:22:45 CET 2013


Author: edd
Date: 2013-02-11 03:22:41 +0100 (Mon, 11 Feb 2013)
New Revision: 4248

Modified:
   pkg/RcppSMC/ChangeLog
   pkg/RcppSMC/R/pfNonlinBS.R
Log:
corrected test for missing data in call of pfNonlinBS()
while at it, also (ahem) reindented to default Emacs preferences (a la R Core)


Modified: pkg/RcppSMC/ChangeLog
===================================================================
--- pkg/RcppSMC/ChangeLog	2013-02-10 11:07:33 UTC (rev 4247)
+++ pkg/RcppSMC/ChangeLog	2013-02-11 02:22:41 UTC (rev 4248)
@@ -1,3 +1,9 @@
+2013-02-10  Dirk Eddelbuettel  <edd at debian.org>
+
+	* DESCRIPTION: Version 0.1.1.1 as minor dev version, next release as 0.1.2
+
+	* R/pfNonlinBS.R: Corrected test for missing data in call
+
 2012-05-14  Dirk Eddelbuettel  <edd at debian.org>
 
 	* DESCRIPTION: Version 0.1.1

Modified: pkg/RcppSMC/R/pfNonlinBS.R
===================================================================
--- pkg/RcppSMC/R/pfNonlinBS.R	2013-02-10 11:07:33 UTC (rev 4247)
+++ pkg/RcppSMC/R/pfNonlinBS.R	2013-02-11 02:22:41 UTC (rev 4248)
@@ -1,17 +1,24 @@
-pfNonlinBS <- function(data=c(), particles=500, plot=FALSE) {
-    if (length(data == 0)) {
-       #Include some error handling here
-       return;        
+pfNonlinBS <- function(data, particles=500, plot=FALSE) {
+    if (missing(data)) {
+        warning("data argument contained no data, returning...")
+        return;
     }
     res <- .Call("pfNonlinBS", data, particles, package="RcppSMC")
 
     time <- 1:length(data);
     if (plot) {
-      with(res, plot(time,mean,type='l',main='Filtering Mean and +/- 1,2
-    standard deviation intervals', xlab='time',ylab='estimate',xlim = c(0,length(data)), ylim = c(min(mean-2.1*sd),max(mean+2.1*sd))))
-      with(res,polygon(c(time,seq(length(data),1,-1)),c(mean-2*sd,(mean+2*sd)[seq(length(data),1,-1)]),col='palegreen1',border=NA))
-      with(res,polygon(c(time,seq(length(data),1,-1)),c(mean-1*sd,(mean+1*sd)[seq(length(data),1,-1)]),col='palegreen3',border=NA))
-      with(res,lines(time,mean, lwd=2, col='darkblue'))
+        with(res, plot(time,mean,type='l',
+                       main='Filtering Mean and +/- 1,2 standard deviation intervals',
+                       xlab='time',ylab='estimate',
+                       xlim = c(0,length(data)),
+                       ylim = c(min(mean-2.1*sd),max(mean+2.1*sd))))
+        with(res,polygon(c(time,seq(length(data),1,-1)),
+                         c(mean-2*sd,(mean+2*sd)[seq(length(data),1,-1)]),
+                         col='palegreen1',border=NA))
+        with(res,polygon(c(time,seq(length(data),1,-1)),
+                         c(mean-1*sd,(mean+1*sd)[seq(length(data),1,-1)]),
+                         col='palegreen3',border=NA))
+        with(res,lines(time,mean, lwd=2, col='darkblue'))
     }
 
     invisible(res)



More information about the Rcpp-commits mailing list