Closed sdwfrost closed 4 years ago
Good to hear from you, @sdwfrost!
Specifying dprocess
is somewhat more straightforward in versions 2+ than it was before. The user must write code that evaluates the likelihood of a single transition from arbitrary state x1
at arbitrary time t1
to arbitrary state x2
at arbitrary time t2
, where of course t2 >= t1
. It can be assumed that the transition is elementary if this is helpful.
You ask three questions; I'll take them in reverse order.
onestep.dens
is gone as of pomp version 2 because it is no longer needed. Instead, one furnishes the dprocess
code directly via the dprocess
argument.dprocess
, as with all other basic model components, if via a C snippet. Access the full documentation by executing ?dprocess_spec
. From those docs:
The goal of a
dprocess
C snippet is to fill the variableloglik
with the log probability density. In the context of such a C snippet, the parameters, and covariates will be defined, as will the timest_1
andt_2
. The state variables at timet_1
will have their usual name (seestatenames
) with a "_1
" appended. Likewise, the state variables at timet_2
will have a "_2
" appended.
dprocess
using an R function is sometimes useful for pedagogical or debugging purposes, though one ultimately wants to move to C snippets because of their much greater computational speed. As with all other basic model components in pomp versions >=2, one writes a function with arguments chosen from among the state variables, covariates, and parameters. The only wrinkle special to dprocess
is that the state variables will have _1
or _2
appended to their names according to whether they correspond to times t_1
or t_2
. Again, the ?dprocess_spec
page has all this spelled out.Because all of this may seem a bit abstract, here's an example for the simple case where we have a Brownian motion as our latent state process.
pomp(
...,
dprocess = function (t_1, t_2, x_1, x_2, sigma, ...) {
standdev <- sigma * sqrt(t_2 - t_1)
loglik <- dnorm(x=x_2, mean=x_1, sd=standdev, log=TRUE)
loglik
},
...
)
pomp(
...,
dprocess = Csnippet("
loglik = dnorm(x_2,x_1,sigma*sqrt(t_2-t_1),1);
"),
...,
statenames=c("x"),
paramnames=c("sigma"),
...
)
I hope this helps. If it does not, or if more is needed, please don't hesitate to reopen the issue. I hope to hear more about your experiences!
Thanks! I didn't know about dprocess_spec
- the _1
/_2
magic is precisely what I was looking for.
Hi @kingaa! While I understand that pomp mostly deals with models where the likelihood of the process is unknown, I'd like to use some pseudolikelihood approaches where I specify (or misspecify) dprocess. In going through the old materials on the
ou2
example, there is the following code:This calls the following C code:
I have a few questions:
dprocess
in vanilla R code?dprocess
in aCsnippet
.onestep.dens
is deprecated. Does this affect things?I can rewrite
rprocess
,rmeasure
, anddmeasure
in either R orCsnippet
, but I can't work out the syntax fordprocess
for theou2
example.