Skip to content

Commit

Permalink
fix bug in bpfilter filter.traj
Browse files Browse the repository at this point in the history
  • Loading branch information
ionides committed Dec 12, 2023
1 parent cdd186b commit 68e0788
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 7 deletions.
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
Package: spatPomp
Type: Package
Title: Inference for Spatiotemporal Partially Observed Markov Processes
Version: 0.34.0
Date: 2023-12-03
Version: 0.34.1
Date: 2023-12-11
Authors@R: c(
person("Kidus", "Asfaw", email = "kidusasfaw1990@gmail.com", role = c("aut")),
person("Edward", "Ionides", email = "ionides@umich.edu",role = c("cre","aut")),
Expand Down
2 changes: 1 addition & 1 deletion R/bpfilter.R
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@ bpfilter.internal <- function (object, Np, block_list, save_states, filter_traj,
b <- sample.int(n=ncol(weights),size=1L,replace=TRUE)
filt.t[block_statenames,1L,ntimes+1] <- xparticles[ntimes,i][[1]][,b]
for (nt in seq.int(from=ntimes-1,to=1L,by=-1L)) {
b <- pedigree[nt+1,][[1]][b]
b <- pedigree[nt+1,i][[1]][b]
filt.t[block_statenames,1L,nt+1] <- xparticles[nt,i][[1]][,b]
}
if (times[2L] > times[1L]) {
Expand Down
3 changes: 2 additions & 1 deletion tests/bm.R
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ paste("check bpfilter on bpfilterd_spatPomp: ",
set.seed(5)
b_bpfilter_filter_traj <- bpfilter(b_bpfilter,filter_traj=TRUE)
paste("bpfilter filter trajectory final particle: ")
round(b_bpfilter_filter_traj@filter.traj[,1,N+1],3)
round(b_bpfilter_filter_traj@filter.traj[,1,],3)


set.seed(5)
Expand Down Expand Up @@ -335,6 +335,7 @@ b_rep1 <- spatPomp(b_model,params=coef(b_model))
for(slt in slotNames(b_model)) if(!identical(slot(b_model,slt),slot(b_rep1,slt))) print(slt)

# test an error message
print("The following delivers an error message, to test it")
try(spatPomp(data=as.data.frame(b_model),units=NULL),outFile=stdout())

# test parameter replacement
Expand Down
10 changes: 7 additions & 3 deletions tests/bm.Rout.save
Original file line number Diff line number Diff line change
Expand Up @@ -136,9 +136,11 @@ executing %dopar% sequentially: no parallel backend registered
> b_bpfilter_filter_traj <- bpfilter(b_bpfilter,filter_traj=TRUE)
> paste("bpfilter filter trajectory final particle: ")
[1] "bpfilter filter trajectory final particle: "
> round(b_bpfilter_filter_traj@filter.traj[,1,N+1],3)
X1 X2
2.349 0.796
> round(b_bpfilter_filter_traj@filter.traj[,1,],3)
time
name [,1] [,2] [,3]
X1 0 1.373 2.349
X2 0 2.035 0.796
>
>
> set.seed(5)
Expand Down Expand Up @@ -516,6 +518,8 @@ Slot "text":
[1] "states"
>
> # test an error message
> print("The following delivers an error message, to test it")
[1] "The following delivers an error message, to test it"
> try(spatPomp(data=as.data.frame(b_model),units=NULL),outFile=stdout())
Error in value[[3L]](cond) :
‘times’ should be a single name identifying the column of data that represents the observation times. ‘units’ should be likewise for column that represents the observation units.
Expand Down

0 comments on commit 68e0788

Please sign in to comment.