Specify the prior distribution
By default, the prior is assumed flat and improper.
In particular, dprior
returns 1
(0
if log = TRUE
) for every parameter set.
Since it is impossible to simulate from a flat improper prior, rprocess
returns missing values (NA
s).
Some Windows users report problems when using C snippets in parallel computations.
These appear to arise when the temporary files created during the C snippet compilation process are not handled properly by the operating system.
To circumvent this problem, use the cdir
and cfile
options (described here) to cause the C snippets to be written to a file of your choice, thus avoiding the use of temporary files altogether.
A prior distribution on parameters is specified by means of the rprior
and/or dprior
arguments to pomp
.
As with the other basic model components, it is preferable to specify these using C snippets.
In writing a C snippet for the prior sampler (rprior
), keep in mind that:
Within the context in which the snippet will be evaluated, only the parameters will be defined.
The goal of such a snippet is the replacement of parameters with values drawn from the prior distribution.
Hyperparameters can be included in the ordinary parameter list. Obviously, hyperparameters should not be replaced with random draws.
In writing a C snippet for the prior density function (dprior
), observe that:
Within the context in which the snippet will be evaluated, only the parameters and give_log
will be defined.
The goal of such a snippet is computation of the prior probability density, or the log of same, at a given point in parameter space.
This scalar value should be returned in the variable lik
.
When give_log == 1
, lik
should contain the log of the prior probability density.
Hyperparameters can be included in the ordinary parameter list.
General rules for writing C snippets can be found here.
Alternatively, one can furnish R functions for one or both of these arguments.
In this case, rprior
must be a function of prototype
f(params, \dots)
that makes a draw from the prior distribution given params
and returns a named vector of the same length and with the same set of names, as params
.
The dprior
function must be of prototype
f(params, log = FALSE, \dots).
Its role is to evaluate the prior probability density (or log density if log == TRUE
) and return that single scalar value.
More on implementing POMP models:
Csnippet
,
accumulators
,
basic_components
,
covariate_table()
,
distributions
,
dmeasure_spec
,
dprocess_spec
,
parameter_trans()
,
pomp-package
,
rinit_spec
,
rmeasure_spec
,
rprocess_spec
,
skeleton_spec
,
transformations
,
userdata