Skip to content

Commit 9051136

Browse files
committed
make additional arguments an error
1 parent e25844e commit 9051136

12 files changed

+79
-132
lines changed

DESCRIPTION

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
Package: pomp
22
Type: Package
33
Title: Statistical Inference for Partially Observed Markov Processes
4-
Version: 5.11.1.0
5-
Date: 2024-12-07
4+
Version: 6.0.0.0
5+
Date: 2024-12-08
66
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")),
77
person(given=c("Edward","L."),family="Ionides",role="aut",comment=c(ORCID="0000-0002-4190-0174")) ,
88
person(given="Carles",family="Bretó",role="aut",comment=c(ORCID="0000-0003-4695-4902")),

R/pomp.R

+6-8
Original file line numberDiff line numberDiff line change
@@ -477,16 +477,14 @@ pomp_internal <- function (
477477

478478
added.userdata <- list(...)
479479
if (length(added.userdata)>0L) {
480-
pWarn_("The provided ",
481-
ngettext(length(added.userdata),"object","objects")," ",
480+
pStop_("The ",
481+
ngettext(length(added.userdata),"argument","arguments")," ",
482482
paste(sQuote(names(added.userdata)),collapse=","),
483-
ngettext(length(added.userdata)," is"," are"),
484-
" available for use by POMP basic components.\n",
485-
"This option is deprecated: use ",sQuote("userdata"),
486-
" to specify the list of such objects explicitly.\n",
487-
"In a future release, this warning will become an error."
483+
ngettext(length(added.userdata),"is","are"),
484+
" not recognized.\nUse the ",sQuote("userdata"),
485+
" argument to supply extra objects to basic model components.",
486+
" See ",sQuote("?userdata"),"."
488487
)
489-
.userdata[names(added.userdata)] <- added.userdata
490488
}
491489
.userdata[names(userdata)] <- userdata
492490

inst/NEWS

+10
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
11
_N_e_w_s _f_o_r _p_a_c_k_a_g_e '_p_o_m_p'
22

3+
_C_h_a_n_g_e_s _i_n '_p_o_m_p' _v_e_r_s_i_o_n _6._0._0:
4+
5+
• From version 5.8.4, the manner in which extra model elements
6+
(‘userdata’) are supplied has changed. As of that version,
7+
use of the old method generated a warning. As of this
8+
version, an error will be generated. To supply additional
9+
elements (i.e., beyond parameters, latent-state variables,
10+
observations, and covariates) to the basic model components,
11+
provide them as a list via the ‘userdata’ argument.
12+
313
_C_h_a_n_g_e_s _i_n '_p_o_m_p' _v_e_r_s_i_o_n _5._1_1._1:
414

515
• A new addition to the C API allows one to easily compute the

inst/NEWS.Rd

+8
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
\name{NEWS}
22
\title{News for package `pomp'}
3+
\section{Changes in \pkg{pomp} version 6.0.0}{
4+
\itemize{
5+
\item From version 5.8.4, the manner in which extra model elements (\code{userdata}) are supplied has changed.
6+
As of that version, use of the old method generated a warning.
7+
As of this version, an error will be generated.
8+
To supply additional elements (i.e., beyond parameters, latent-state variables, observations, and covariates) to the basic model components, provide them as a list via the \code{userdata} argument.
9+
}
10+
}
311
\section{Changes in \pkg{pomp} version 5.11.1}{
412
\itemize{
513
\item A new addition to the C API allows one to easily compute the expectation of the Euler-multinomial.

tests/kalman.R

+14-14
Original file line numberDiff line numberDiff line change
@@ -111,12 +111,12 @@ try(enkf(pf,Np=-10))
111111
try(enkf(pf,Np="10b"))
112112
try(enkf(pf,Np=100,emeasure=NULL))
113113
try(enkf(enkf,Np=100,vmeasure=NULL))
114-
try(enkf(enkf,C=matrix(1,2,4,dimnames=list(c("y2","y1"),NULL)),Np=100))
115-
try(enkf(enkf,C=matrix(1,3,4,dimnames=list(c("a","b","c"),NULL)),Np=100))
116-
try(enkf(enkf,R=matrix(1,1,1,dimnames=list(c("y1"),NULL)),Np=100))
117-
try(enkf(enkf,R=matrix(1,2,2,dimnames=list(c("y2","y1"),NULL)),Np=100))
118-
try(enkf(enkf,R=matrix(1,2,2,dimnames=list(c("a","b"),NULL)),Np=100))
119-
try(enkf(enkf,R=matrix(1,3,3,dimnames=list(c("a","b","c"),NULL)),Np=100))
114+
try(enkf(enkf,userdata=list(C=matrix(1,2,4,dimnames=list(c("y2","y1"),NULL))),Np=100))
115+
try(enkf(enkf,userdata=list(C=matrix(1,3,4,dimnames=list(c("a","b","c"),NULL))),Np=100))
116+
try(enkf(enkf,userdata=list(R=matrix(1,1,1,dimnames=list(c("y1"),NULL))),Np=100))
117+
try(enkf(enkf,userdata=list(R=matrix(1,2,2,dimnames=list(c("y2","y1"),NULL))),Np=100))
118+
try(enkf(enkf,userdata=list(R=matrix(1,2,2,dimnames=list(c("a","b"),NULL))),Np=100))
119+
try(enkf(enkf,userdata=list(R=matrix(1,3,3,dimnames=list(c("a","b","c"),NULL))),Np=100))
120120
enkf(enkf)
121121
enkf(enkf,Np=100)
122122

@@ -125,12 +125,12 @@ try(eakf(enkf,Np=-10))
125125
try(eakf(enkf,Np="10b"))
126126
try(eakf(enkf,Np=100,emeasure=NULL))
127127
try(eakf(enkf,Np=100,vmeasure=NULL))
128-
try(eakf(enkf,C=matrix(1,2,4,dimnames=list(c("y2","y1"),NULL)),Np=100))
129-
try(eakf(enkf,C=matrix(1,3,4,dimnames=list(c("a","b","c"),NULL)),Np=100))
130-
try(eakf(enkf,R=matrix(1,1,1,dimnames=list(c("y1"),NULL)),Np=100))
131-
try(eakf(enkf,R=matrix(1,2,2,dimnames=list(c("y2","y1"),NULL)),Np=100))
132-
try(eakf(enkf,R=matrix(1,2,2,dimnames=list(c("a","b"),NULL)),Np=100))
133-
try(eakf(enkf,R=matrix(1,3,3,dimnames=list(c("a","b","c"),NULL)),Np=100))
128+
try(eakf(enkf,userdata=list(C=matrix(1,2,4,dimnames=list(c("y2","y1"),NULL))),Np=100))
129+
try(eakf(enkf,userdata=list(C=matrix(1,3,4,dimnames=list(c("a","b","c"),NULL))),Np=100))
130+
try(eakf(enkf,userdata=list(R=matrix(1,1,1,dimnames=list(c("y1"),NULL))),Np=100))
131+
try(eakf(enkf,userdata=list(R=matrix(1,2,2,dimnames=list(c("y2","y1"),NULL))),Np=100))
132+
try(eakf(enkf,userdata=list(R=matrix(1,2,2,dimnames=list(c("a","b"),NULL)),Np=100)))
133+
try(eakf(enkf,userdata=list(R=matrix(1,3,3,dimnames=list(c("a","b","c"),NULL))),Np=100))
134134

135135
invisible(enkf(pf,Np=1000,params=as.list(coef(pf))))
136136
invisible(eakf(pf,Np=1000,params=as.list(coef(pf))))
@@ -161,11 +161,11 @@ eakf |>
161161
try({
162162
R <- matrix(c(1,0,1,0),2,2)
163163
rownames(R) <- rownames(C)
164-
enkf(pf,Np=1000,R=R)
164+
enkf(pf,Np=1000,userdata=list(R=R))
165165
})
166166

167167
try({
168-
eakf(pf,Np=1000,R=R)
168+
eakf(pf,Np=1000,userdata=list(R=R))
169169
})
170170

171171
try(enkf())

tests/kalman.Rout.save

+15-71
Original file line numberDiff line numberDiff line change
@@ -140,42 +140,18 @@ In enkf_internal(data, Np = Np, ..., verbose = verbose) :
140140
Error : in 'enkf': 'emeasure' is a needed basic component.
141141
> try(enkf(enkf,Np=100,vmeasure=NULL))
142142
Error : in 'enkf': 'vmeasure' is a needed basic component.
143-
> try(enkf(enkf,C=matrix(1,2,4,dimnames=list(c("y2","y1"),NULL)),Np=100))
143+
> try(enkf(enkf,userdata=list(C=matrix(1,2,4,dimnames=list(c("y2","y1"),NULL))),Np=100))
144144
Error : in 'enkf': rownames of matrix returned by 'vmeasure' do not match those returned by 'emeasure'.
145-
In addition: Warning message:
146-
The provided object 'C' is available for use by POMP basic components.
147-
This option is deprecated: use 'userdata' to specify the list of such objects explicitly.
148-
In a future release, this warning will become an error.
149-
> try(enkf(enkf,C=matrix(1,3,4,dimnames=list(c("a","b","c"),NULL)),Np=100))
145+
> try(enkf(enkf,userdata=list(C=matrix(1,3,4,dimnames=list(c("a","b","c"),NULL))),Np=100))
150146
Error : in 'enkf': number of observables returned by 'emeasure' does not match data.
151-
In addition: Warning message:
152-
The provided object 'C' is available for use by POMP basic components.
153-
This option is deprecated: use 'userdata' to specify the list of such objects explicitly.
154-
In a future release, this warning will become an error.
155-
> try(enkf(enkf,R=matrix(1,1,1,dimnames=list(c("y1"),NULL)),Np=100))
147+
> try(enkf(enkf,userdata=list(R=matrix(1,1,1,dimnames=list(c("y1"),NULL))),Np=100))
156148
Error : in 'enkf': rownames of matrix returned by 'vmeasure' do not match those returned by 'emeasure'.
157-
In addition: Warning message:
158-
The provided object 'R' is available for use by POMP basic components.
159-
This option is deprecated: use 'userdata' to specify the list of such objects explicitly.
160-
In a future release, this warning will become an error.
161-
> try(enkf(enkf,R=matrix(1,2,2,dimnames=list(c("y2","y1"),NULL)),Np=100))
149+
> try(enkf(enkf,userdata=list(R=matrix(1,2,2,dimnames=list(c("y2","y1"),NULL))),Np=100))
162150
Error : in 'enkf': rownames of matrix returned by 'vmeasure' do not match those returned by 'emeasure'.
163-
In addition: Warning message:
164-
The provided object 'R' is available for use by POMP basic components.
165-
This option is deprecated: use 'userdata' to specify the list of such objects explicitly.
166-
In a future release, this warning will become an error.
167-
> try(enkf(enkf,R=matrix(1,2,2,dimnames=list(c("a","b"),NULL)),Np=100))
151+
> try(enkf(enkf,userdata=list(R=matrix(1,2,2,dimnames=list(c("a","b"),NULL))),Np=100))
168152
Error : in 'enkf': rownames of matrix returned by 'vmeasure' do not match those returned by 'emeasure'.
169-
In addition: Warning message:
170-
The provided object 'R' is available for use by POMP basic components.
171-
This option is deprecated: use 'userdata' to specify the list of such objects explicitly.
172-
In a future release, this warning will become an error.
173-
> try(enkf(enkf,R=matrix(1,3,3,dimnames=list(c("a","b","c"),NULL)),Np=100))
153+
> try(enkf(enkf,userdata=list(R=matrix(1,3,3,dimnames=list(c("a","b","c"),NULL))),Np=100))
174154
Error : in 'enkf': rownames of matrix returned by 'vmeasure' do not match those returned by 'emeasure'.
175-
In addition: Warning message:
176-
The provided object 'R' is available for use by POMP basic components.
177-
This option is deprecated: use 'userdata' to specify the list of such objects explicitly.
178-
In a future release, this warning will become an error.
179155
> enkf(enkf)
180156
<object of class 'kalmand_pomp'>
181157
> enkf(enkf,Np=100)
@@ -194,42 +170,18 @@ In eakf_internal(data, Np = Np, ..., verbose = verbose) :
194170
Error : in 'eakf': 'emeasure' is a needed basic component.
195171
> try(eakf(enkf,Np=100,vmeasure=NULL))
196172
Error : in 'eakf': 'vmeasure' is a needed basic component.
197-
> try(eakf(enkf,C=matrix(1,2,4,dimnames=list(c("y2","y1"),NULL)),Np=100))
173+
> try(eakf(enkf,userdata=list(C=matrix(1,2,4,dimnames=list(c("y2","y1"),NULL))),Np=100))
198174
Error : in 'eakf': rownames of matrix returned by 'vmeasure' do not match those returned by 'emeasure'.
199-
In addition: Warning message:
200-
The provided object 'C' is available for use by POMP basic components.
201-
This option is deprecated: use 'userdata' to specify the list of such objects explicitly.
202-
In a future release, this warning will become an error.
203-
> try(eakf(enkf,C=matrix(1,3,4,dimnames=list(c("a","b","c"),NULL)),Np=100))
175+
> try(eakf(enkf,userdata=list(C=matrix(1,3,4,dimnames=list(c("a","b","c"),NULL))),Np=100))
204176
Error : in 'eakf': number of observables returned by 'emeasure' does not match data.
205-
In addition: Warning message:
206-
The provided object 'C' is available for use by POMP basic components.
207-
This option is deprecated: use 'userdata' to specify the list of such objects explicitly.
208-
In a future release, this warning will become an error.
209-
> try(eakf(enkf,R=matrix(1,1,1,dimnames=list(c("y1"),NULL)),Np=100))
177+
> try(eakf(enkf,userdata=list(R=matrix(1,1,1,dimnames=list(c("y1"),NULL))),Np=100))
210178
Error : in 'eakf': rownames of matrix returned by 'vmeasure' do not match those returned by 'emeasure'.
211-
In addition: Warning message:
212-
The provided object 'R' is available for use by POMP basic components.
213-
This option is deprecated: use 'userdata' to specify the list of such objects explicitly.
214-
In a future release, this warning will become an error.
215-
> try(eakf(enkf,R=matrix(1,2,2,dimnames=list(c("y2","y1"),NULL)),Np=100))
216-
Error : in 'eakf': rownames of matrix returned by 'vmeasure' do not match those returned by 'emeasure'.
217-
In addition: Warning message:
218-
The provided object 'R' is available for use by POMP basic components.
219-
This option is deprecated: use 'userdata' to specify the list of such objects explicitly.
220-
In a future release, this warning will become an error.
221-
> try(eakf(enkf,R=matrix(1,2,2,dimnames=list(c("a","b"),NULL)),Np=100))
179+
> try(eakf(enkf,userdata=list(R=matrix(1,2,2,dimnames=list(c("y2","y1"),NULL))),Np=100))
222180
Error : in 'eakf': rownames of matrix returned by 'vmeasure' do not match those returned by 'emeasure'.
223-
In addition: Warning message:
224-
The provided object 'R' is available for use by POMP basic components.
225-
This option is deprecated: use 'userdata' to specify the list of such objects explicitly.
226-
In a future release, this warning will become an error.
227-
> try(eakf(enkf,R=matrix(1,3,3,dimnames=list(c("a","b","c"),NULL)),Np=100))
181+
> try(eakf(enkf,userdata=list(R=matrix(1,2,2,dimnames=list(c("a","b"),NULL)),Np=100)))
182+
Error : in 'eakf': argument "Np" is missing, with no default
183+
> try(eakf(enkf,userdata=list(R=matrix(1,3,3,dimnames=list(c("a","b","c"),NULL))),Np=100))
228184
Error : in 'eakf': rownames of matrix returned by 'vmeasure' do not match those returned by 'emeasure'.
229-
In addition: Warning message:
230-
The provided object 'R' is available for use by POMP basic components.
231-
This option is deprecated: use 'userdata' to specify the list of such objects explicitly.
232-
In a future release, this warning will become an error.
233185
>
234186
> invisible(enkf(pf,Np=1000,params=as.list(coef(pf))))
235187
> invisible(eakf(pf,Np=1000,params=as.list(coef(pf))))
@@ -292,22 +244,14 @@ In a future release, this warning will become an error.
292244
> try({
293245
+ R <- matrix(c(1,0,1,0),2,2)
294246
+ rownames(R) <- rownames(C)
295-
+ enkf(pf,Np=1000,R=R)
247+
+ enkf(pf,Np=1000,userdata=list(R=R))
296248
+ })
297249
Error : in 'enkf': degenerate 'vmeasure': the leading minor of order 2 is not positive
298-
In addition: Warning message:
299-
The provided object 'R' is available for use by POMP basic components.
300-
This option is deprecated: use 'userdata' to specify the list of such objects explicitly.
301-
In a future release, this warning will become an error.
302250
>
303251
> try({
304-
+ eakf(pf,Np=1000,R=R)
252+
+ eakf(pf,Np=1000,userdata=list(R=R))
305253
+ })
306254
Error : in 'eakf': degenerate 'vmeasure': Lapack routine dgesv: system is exactly singular: U[2,2] = 0
307-
In addition: Warning message:
308-
The provided object 'R' is available for use by POMP basic components.
309-
This option is deprecated: use 'userdata' to specify the list of such objects explicitly.
310-
In a future release, this warning will become an error.
311255
>
312256
> try(enkf())
313257
Error : in 'enkf': 'data' is a required argument.

tests/mif2.R

+6-1
Original file line numberDiff line numberDiff line change
@@ -85,9 +85,14 @@ try(mif2(po,Nmif=2,Np=100,rw.sd=rw_sd(sigma=0.01,X_0=ivp(0.01)),
8585
cooling.fraction.50=0.1,dmeasure=function(log,...)stop("blop")))
8686
try(mif2(po,Nmif=2,Np=100,rw.sd=rw_sd(sigma=0.01,X_0=ivp(0.01)),
8787
cooling.fraction.50=0.1,dmeasure=function(log,...)NA))
88+
try(
89+
mif2(po,Nmif=2,Np=50,rw.sd=rw_sd(sigma=0.01),
90+
cooling.type="hyper",cooling.fraction.50=0.1,
91+
drpocess="oops",
92+
dmeasure=function(log,...)0) -> mf3
93+
)
8894
mif2(po,Nmif=2,Np=50,rw.sd=rw_sd(sigma=0.01),
8995
cooling.type="hyper",cooling.fraction.50=0.1,
90-
drpocess="oops",
9196
dmeasure=function(log,...)0) -> mf3
9297
try(mif2(po,Nmif=2,Np=50,rw.sd=rw_sd(sigma=0.01),cooling.fraction.50=0.1,dmeasure=NULL))
9398
try(mif2(po,Nmif=2,Np=50,rw.sd=rw_sd(sigma=0.01),cooling.fraction.50=0.1,rprocess=NULL))

tests/mif2.Rout.save

+8-5
Original file line numberDiff line numberDiff line change
@@ -179,14 +179,17 @@ loglik: NA
179179
sigma: 0.0996772
180180
tau: 0.1
181181
X_0: 0.990808
182+
> try(
183+
+ mif2(po,Nmif=2,Np=50,rw.sd=rw_sd(sigma=0.01),
184+
+ cooling.type="hyper",cooling.fraction.50=0.1,
185+
+ drpocess="oops",
186+
+ dmeasure=function(log,...)0) -> mf3
187+
+ )
188+
Error : in 'mif2': The argument 'drpocess'is not recognized.
189+
Use the 'userdata' argument to supply extra objects to basic model components. See '?userdata'.
182190
> mif2(po,Nmif=2,Np=50,rw.sd=rw_sd(sigma=0.01),
183191
+ cooling.type="hyper",cooling.fraction.50=0.1,
184-
+ drpocess="oops",
185192
+ dmeasure=function(log,...)0) -> mf3
186-
Warning message:
187-
The provided object 'drpocess' is available for use by POMP basic components.
188-
This option is deprecated: use 'userdata' to specify the list of such objects explicitly.
189-
In a future release, this warning will become an error.
190193
> try(mif2(po,Nmif=2,Np=50,rw.sd=rw_sd(sigma=0.01),cooling.fraction.50=0.1,dmeasure=NULL))
191194
Error : in 'mif2': 'rprocess', 'dmeasure' are needed basic components.
192195
> try(mif2(po,Nmif=2,Np=50,rw.sd=rw_sd(sigma=0.01),cooling.fraction.50=0.1,rprocess=NULL))

tests/pomp.R

-3
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,6 @@ try(data.frame(a=1:10,b=1:10) |> pomp(times=1,t0=11))
2424
try(data.frame(a=1:10,b=1:10) |> pomp(times="a",t0=11))
2525
try(data.frame(a=1:10,b=1:10) |> pomp(times="b",t0=NULL))
2626
try(data.frame(a=1:10,b=1:10) |> pomp(times="a",t0=NA))
27-
stopifnot(data.frame(a=1:10,b=1:10) |>
28-
pomp(covar=covariate_table(c=0:10,d=0:10,times="c"),
29-
covarnames="d",times="a",t0=0,bob=3) |> class() == "pomp")
3027
stopifnot(data.frame(a=1:10,b=1:10) |>
3128
pomp(covar=covariate_table(c=0:10,d=0:10,times="c"),
3229
covarnames="d",times="a",t0=0,userdata=list(bob=3)) |> class() == "pomp")

tests/pomp.Rout.save

-7
Original file line numberDiff line numberDiff line change
@@ -65,13 +65,6 @@ Error : 't0' must be a single number not greater than 'times[1]'.
6565
Error : 't0' must be a single number not greater than 'times[1]'.
6666
> stopifnot(data.frame(a=1:10,b=1:10) |>
6767
+ pomp(covar=covariate_table(c=0:10,d=0:10,times="c"),
68-
+ covarnames="d",times="a",t0=0,bob=3) |> class() == "pomp")
69-
Warning message:
70-
The provided object 'bob' is available for use by POMP basic components.
71-
This option is deprecated: use 'userdata' to specify the list of such objects explicitly.
72-
In a future release, this warning will become an error.
73-
> stopifnot(data.frame(a=1:10,b=1:10) |>
74-
+ pomp(covar=covariate_table(c=0:10,d=0:10,times="c"),
7568
+ covarnames="d",times="a",t0=0,userdata=list(bob=3)) |> class() == "pomp")
7669
> try(data.frame(a=1:10,b=1:10) |>
7770
+ pomp(covar=covariate_table(c=1:10,d=1:10,d=1:10,times="c"),

tests/spy.R

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ library(pomp)
44

55
gompertz() -> po
66

7-
pomp(po,partrans=NULL,bob=3,
7+
pomp(po,partrans=NULL,userdata=list(bob=3),
88
covar=covariate_table(a=0:20,b=0:20,times="a")) -> po1
99
spy(po1)
1010

@@ -29,7 +29,7 @@ try(spy(list()))
2929
pomp(
3030
data=NULL,
3131
t0=0,times=1:10,
32-
x0=as.double(1),
32+
userdata=list(x0=as.double(1)),
3333
params=c(x_0=1,a=22),
3434
rinit=Csnippet(r"{x = *get_userdata_double("x0");}"),
3535
statenames="x",
@@ -40,7 +40,7 @@ pomp(
4040
pomp(
4141
data=NULL,
4242
t0=0,times=1:10,
43-
x0=as.double(1),
43+
userdata=list(x0=as.double(1)),
4444
params=c(x_0=1,a=22),
4545
globals=Csnippet("static double X0;"),
4646
rinit=Csnippet(r"{x = X0;}"),

0 commit comments

Comments
 (0)