d_fitted {BAMBI} | R Documentation |
Density and random deviates from an angmcmc object
Description
Density and random deviates from an angmcmc object
Usage
d_fitted(x, object, type = "point-est", fn = mean, log = FALSE, chain.no, ...)
r_fitted(n = 1, object, type = "point-est", fn = mean, chain.no, ...)
Arguments
x |
vector, if univariate or a two column matrix, if bivariate, with each row a 2-D vector, (can also be a data frame of similar dimensions) of points where the densities are to be computed. |
object |
angular MCMC object. The dimension of the model must match with |
type |
Method of estimating density/generating random deviates. Possible choices are
|
fn |
function, or a single character string specifying its name, to evaluate on MCMC samples to estimate
parameters. Defaults to |
log |
logical. Should the log density be returned instead? |
chain.no |
vector of chain numbers whose samples are to be be used. in the estimation. By default all chains are used. |
... |
additional arguments to be passed to the function. |
n |
number of observations to be generated. |
Details
If type = 'point-est'
, density is evaluated/random samples are generated at a point estimate of
the parameter values. To estimate the mixture density, first the parameter vector is estimated
by applying
fn
on the MCMC samples (using the function pointest), yielding the (consistent) Bayes estimate .
Then the mixture density
at any point
is (consistently) estimated by
. The random deviates are generated from the estimated mixture density
.
If type == 'post-pred'
, posterior predictive samples and densities are returned. That
is, the average density is returned in
d_fitted
,
where is the set posterior MCMC samples obtained from
object
. In
r_fitted
, first a random sub-sample of size
n
from the
set of posterior samples is drawn (with replacement if
n
> S). Then
the i-th posterior predictive data point is generated from the mixture density
for i = 1,..., n.
Value
d_fitted
gives a vector the densities computed at the given points and r_fitted
creates a vector (if univariate) or a matrix (if bivariate) with each row being a 2-D point, of random deviates.
Examples
set.seed(1)
# illustration only - more iterations needed for convergence
fit.vmsin.20 <- fit_vmsinmix(tim8, ncomp = 3, n.iter = 20,
n.chains = 1)
d_fitted(c(0,0), fit.vmsin.20, type = "post-pred")
d_fitted(c(0,0), fit.vmsin.20, type = "point-est")
r_fitted(10, fit.vmsin.20, type = "post-pred")
r_fitted(10, fit.vmsin.20, type = "point-est")