Skip to content

Commit

Permalink
enforce named arguments
Browse files Browse the repository at this point in the history
kingaa committed Dec 9, 2024
1 parent 9051136 commit 2a13c1b
Showing 48 changed files with 713 additions and 351 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: pomp
Type: Package
Title: Statistical Inference for Partially Observed Markov Processes
Version: 6.0.0.0
Version: 6.0.1.0
Date: 2024-12-08
Authors@R: c(person(given=c("Aaron","A."),family="King",role=c("aut","cre"),email="kingaa@umich.edu",comment=c(ORCID="0000-0001-6159-3207")),
person(given=c("Edward","L."),family="Ionides",role="aut",comment=c(ORCID="0000-0002-4190-0174")) ,
53 changes: 36 additions & 17 deletions R/abc.R
Original file line number Diff line number Diff line change
@@ -112,15 +112,19 @@ setMethod(
setMethod(
"abc",
signature=signature(data="data.frame"),
definition=function (data,
definition=function (
data,
...,
Nabc = 1, proposal, scale, epsilon,
probes,
params, rinit, rprocess, rmeasure, dprior,
..., verbose = getOption("verbose", FALSE)) {
verbose = getOption("verbose", FALSE)
) {

tryCatch(
abc_internal(
data,
...,
Nabc=Nabc,
proposal=proposal,
scale=scale,
@@ -131,7 +135,6 @@ setMethod(
rprocess=rprocess,
rmeasure=rmeasure,
dprior=dprior,
...,
verbose=verbose
),
error = function (e) pStop(who="abc",conditionMessage(e))
@@ -145,20 +148,23 @@ setMethod(
setMethod(
"abc",
signature=signature(data="pomp"),
definition=function (data,
definition=function (
data,
...,
Nabc = 1, proposal, scale, epsilon,
probes,
..., verbose = getOption("verbose", FALSE)) {
verbose = getOption("verbose", FALSE)
) {

tryCatch(
abc_internal(
data,
...,
Nabc=Nabc,
proposal=proposal,
scale=scale,
epsilon=epsilon,
probes=probes,
...,
verbose=verbose
),
error = function (e) pStop(who="abc",conditionMessage(e))
@@ -172,15 +178,19 @@ setMethod(
setMethod(
"abc",
signature=signature(data="probed_pomp"),
definition=function (data, probes, ...,
verbose = getOption("verbose", FALSE)) {
definition=function (
data,
...,
probes,
verbose = getOption("verbose", FALSE)
) {

if (missing(probes)) probes <- data@probes

abc(
as(data,"pomp"),
probes=probes,
...,
probes=probes,
verbose=verbose
)

@@ -192,10 +202,13 @@ setMethod(
setMethod(
"abc",
signature=signature(data="abcd_pomp"),
definition=function (data,
definition=function (
data,
...,
Nabc, proposal, scale, epsilon,
probes,
..., verbose = getOption("verbose", FALSE)) {
verbose = getOption("verbose", FALSE)
) {

if (missing(Nabc)) Nabc <- data@Nabc
if (missing(proposal)) proposal <- data@proposal
@@ -205,12 +218,12 @@ setMethod(

abc(
as(data,"pomp"),
...,
Nabc=Nabc,
proposal=proposal,
scale=scale,
epsilon=epsilon,
probes=probes,
...,
verbose=verbose
)

@@ -223,12 +236,16 @@ setMethod(
setMethod(
"continue",
signature=signature(object="abcd_pomp"),
definition=function (object, Nabc = 1, ...) {
definition=function (
object,
...,
Nabc = 1
) {

ndone <- object@Nabc
accepts <- object@accepts

obj <- abc(object,Nabc=Nabc,.ndone=ndone,.accepts=accepts,...)
obj <- abc(object,...,Nabc=Nabc,.ndone=ndone,.accepts=accepts)

obj@traces <- rbind(
object@traces[,colnames(obj@traces)],
@@ -242,11 +259,13 @@ setMethod(
}
)

abc_internal <- function (object,
Nabc, proposal, scale, epsilon, probes,
abc_internal <- function (
object,
...,
Nabc, proposal, scale, epsilon, probes,
verbose,
.ndone = 0L, .accepts = 0L, .gnsi = TRUE) {
.ndone = 0L, .accepts = 0L, .gnsi = TRUE
) {

verbose <- as.logical(verbose)

25 changes: 18 additions & 7 deletions R/bsmc2.R
Original file line number Diff line number Diff line change
@@ -88,14 +88,18 @@ setMethod(
setMethod(
"bsmc2",
signature=signature(data="data.frame"),
definition = function (data,
definition = function (
data,
...,
Np, smooth = 0.1,
params, rprior, rinit, rprocess, dmeasure, partrans,
..., verbose = getOption("verbose", FALSE)) {
verbose = getOption("verbose", FALSE)
) {

tryCatch(
bsmc2_internal(
data,
...,
Np=Np,
smooth=smooth,
params=params,
@@ -104,7 +108,6 @@ setMethod(
rprocess=rprocess,
dmeasure=dmeasure,
partrans=partrans,
...,
verbose=verbose
),
error = function (e) pStop(who="bsmc2",conditionMessage(e))
@@ -118,16 +121,19 @@ setMethod(
setMethod(
"bsmc2",
signature=signature(data="pomp"),
definition = function (data,
definition = function (
data,
...,
Np, smooth = 0.1,
..., verbose = getOption("verbose", FALSE)) {
verbose = getOption("verbose", FALSE)
) {

tryCatch(
bsmc2_internal(
data,
...,
Np=Np,
smooth=smooth,
...,
verbose=verbose
),
error = function (e) pStop(who="bsmc2",conditionMessage(e))
@@ -158,7 +164,12 @@ setMethod(
}
)

bsmc2_internal <- function (object, Np, smooth, ..., verbose, .gnsi = TRUE) {
bsmc2_internal <- function (
object,
...,
Np, smooth,
verbose, .gnsi = TRUE
) {

verbose <- as.logical(verbose)

66 changes: 48 additions & 18 deletions R/kalman.R
Original file line number Diff line number Diff line change
@@ -89,20 +89,24 @@ setMethod(
setMethod(
"enkf",
signature=signature(data="data.frame"),
function (data, Np,
function (
data,
...,
Np,
params, rinit, rprocess, emeasure, vmeasure,
..., verbose = getOption("verbose", FALSE)) {
verbose = getOption("verbose", FALSE)
) {

tryCatch(
enkf_internal(
data,
...,
Np=Np,
params=params,
rinit=rinit,
rprocess=rprocess,
emeasure=emeasure,
vmeasure=vmeasure,
...,
verbose=verbose
),
error = function (e) pStop(who="enkf",conditionMessage(e))
@@ -116,14 +120,18 @@ setMethod(
setMethod(
"enkf",
signature=signature(data="pomp"),
function (data, Np,
..., verbose = getOption("verbose", FALSE)) {
function (
data,
...,
Np,
verbose = getOption("verbose", FALSE)
) {

tryCatch(
enkf_internal(
data,
Np=Np,
...,
Np=Np,
verbose=verbose
),
error = function (e) pStop(who="enkf",conditionMessage(e))
@@ -137,14 +145,18 @@ setMethod(
setMethod(
"enkf",
signature=signature(data="kalmand_pomp"),
function (data, Np,
..., verbose = getOption("verbose", FALSE)) {
function (
data,
...,
Np,
verbose = getOption("verbose", FALSE)
) {
if (missing(Np)) Np <- data@Np
tryCatch(
enkf_internal(
as(data,"pomp"),
Np=Np,
...,
Np=Np,
verbose=verbose
),
error = function (e) pStop(who="enkf",conditionMessage(e))
@@ -167,7 +179,12 @@ setMethod(
## Updated ensemble: $X^u_{t}=X_t + K_t\,(O_t - Y_t)$
## Filter mean: $m_t=\langle X^u_t \rangle = \frac{1}{q} \sum\limits_{i=1}^q x^{u_i}_t$

enkf_internal <- function (object, Np, ..., verbose) {
enkf_internal <- function (
object,
...,
Np,
verbose
) {

verbose <- as.logical(verbose)

@@ -306,20 +323,24 @@ setMethod(
setMethod(
"eakf",
signature=signature(data="data.frame"),
function (data,
Np, params, rinit, rprocess, emeasure, vmeasure,
...,verbose = getOption("verbose", FALSE)) {
function (
data,
...,
Np,
params, rinit, rprocess, emeasure, vmeasure,
verbose = getOption("verbose", FALSE)
) {

tryCatch(
eakf_internal(
data,
...,
Np=Np,
params=params,
rinit=rinit,
rprocess=rprocess,
emeasure=emeasure,
vmeasure=vmeasure,
...,
verbose=verbose
),
error = function (e) pStop(who="eakf",conditionMessage(e))
@@ -333,14 +354,18 @@ setMethod(
setMethod(
"eakf",
signature=signature(data="pomp"),
function (data,
Np, ..., verbose = getOption("verbose", FALSE)) {
function (
data,
...,
Np,
verbose = getOption("verbose", FALSE)
) {

tryCatch(
eakf_internal(
data,
Np=Np,
...,
Np=Np,
verbose=verbose
),
error = function (e) pStop(who="eakf",conditionMessage(e))
@@ -361,7 +386,12 @@ setMethod(
## Filter mean: $m_t=M_t+K_t\,(y_t-C\,M_t)$
## Updated ensemble: $x_{t}=B\,(X_t-M_t\,\mathbb{1})+m_t\,\mathbb{1}$

eakf_internal <- function (object, Np, ..., verbose) {
eakf_internal <- function (
object,
...,
Np,
verbose
) {

verbose <- as.logical(verbose)

3 changes: 2 additions & 1 deletion R/kf.R
Original file line number Diff line number Diff line change
@@ -63,7 +63,8 @@
##
##' @export
kalmanFilter <- function (
object, X0 = rinit(object),
object,
X0 = rinit(object),
A, Q, C, R, tol = 1e-6
) {

Loading
Oops, something went wrong.

0 comments on commit 2a13c1b

Please sign in to comment.