Learn R Programming

bayesSurv (version 0.1)

bayesDensity: Summary for the density estimate based on the Bayesian model.

Description

Compute the conditional (given the number of mixture components) and unconditional estimate of the density function based on the values sampled using the reversible jumps McMC (McMC average evaluated in a grid of values). Give also the values of each sampled density evaluated at that grid (returned as the attribute of the resulting object). Methods for printing and plotting are also provided.

Usage

bayesDensity(dir = getwd(), stgrid, grid,
    n.grid = 100, skip = 0, standard = TRUE, unstandard = TRUE)

Arguments

dir
directory where to search for files (`mixmoment.sim', `mweight.sim', mmean.sim', mvariance.sim') with the McMC sample.
stgrid
grid of values at which the sampled standardized densities are to be evaluated. If missing, the grid is automatically computed.
grid
grid of values at which the sampled densities are to be evaluated. If missing, the grid is guessed from the first 20 sampled mixtures as the sequence starting with the minimal sampled mixture mean minus 3 standard deviations of
n.grid
the length of the grid if grid = NULL.
skip
number of rows that should be skipped at the beginning of each file with the stored sample.
standard
if TRUE then also standardized (zero mean, unit variance) sampled densities are evaluated.
unstandard
of TRUE then also original (unstandardized) sampled densities are evaluated.

Value

  • An object of class bayesDensity is returned. This object is a list and has potentially two components: standard and unstandard. Each of these two components is a data.frame with as many rows as number of grid points at which the density was evaluated and with columns called `grid', `unconditional' and `k = 1', ..., `k = k.max' giving a predictive errr density, either averaged over all sampled $k$s (unconditional) or averaged over a psecific number of mixture components.

    Additionally, the object of class bayesDensity has three attributes:

  • sample.sizea vector of length 1 + kmax giving the frequency of each $k$ in the sample.
  • momentsa data.frame with columns called `intercept' and `scale' giving the mean and variance of the sampled mixture at each iteration of the McMC.
  • ka data.frame with one column called `k' giving number of mixture components at each iteration.
  • There exists methods to print and plot objects of the class bayesDensity.