sampleGlm: Produce posterior samples from one GLM / Cox model

Description Usage Arguments Value

View source: R/sampleGlm.R

Description

Based on the result list from glmBayesMfp, for the first model in the list MCMC samples are produced. In parallel to the sampling of coefficients and FP curve points, optionally the marginal likelihood of the model is estimated with MCMC samples. This provides a check of the integrated Laplace approximation used in the model sampling. If TBF methodology is used, then no MCMC is necessary, instead ordinary Monte Carlo samples from an approximate posterior distribution are obtained.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
sampleGlm(
  object,
  mcmc = McmcOptions(),
  estimateMargLik = TRUE,
  gridList = list(),
  gridSize = 203L,
  newdata = NULL,
  fixedZ = NULL,
  marginalZApprox = NULL,
  verbose = TRUE,
  debug = FALSE,
  useOpenMP = TRUE,
  correctedCenter = FALSE
)

Arguments

object

the GlmBayesMfp object, from which only the first model will be processed (at least for now ...)

mcmc

MCMC options object with class McmcOptions. If TBF is used, each sample is accepted, and the number of samples is given by sampleSize(mcmc).

estimateMargLik

shall the marginal likelihood be estimated in parallel? (default) Only has an effect if full Bayes and not TBF is used.

gridList

optional list of appropriately named grid vectors for FP evaluation. Default is length (gridSize - 2) grid per covariate additional to the observed values (two are at the endpoints)

gridSize

see above (default: 203)

newdata

new covariate data.frame with exactly the names (and preferably ranges) as before (default: no new covariate data) Note that there is no option for offsets for new data at the moment. Just add the offsets to the predictions slot of samples in the return list yourself.

fixedZ

either NULL (default) or a (single) fixed z value to be used, in order to sample from the conditional posterior given this z. If object was constructed by the empirical Bayes machinery, this will default to the estimated z with maximum conditional marginal likelihood. If object was constructed with the option fixedg, then the fixed value will be used by default.

marginalZApprox

method for approximating the marginal density of the log covariance factor z, see getMarginalZ for the details (default: same preference list as in getMarginalZ) If TBF are used in conjunction with incomplete inverse gamma hyperprior on g = exp(z), then the posterior distribution of g is again of this form. Therefore this option does not have any effect in that case, because the samples are directly obtained from that posterior distribution.

verbose

should information on computation progress be given? (default)

debug

print debugging information? (not default)

useOpenMP

shall OpenMP be used to accelerate the computations? (default)

correctedCenter

If TRUE predict new data based on the centering of the original data.

Value

Returns a list with the following elements:

samples

an object of S4 class GlmBayesMfpSamples

coefficients

samples of all original coefficients in the model (nCoefs x nSamples)

acceptanceRatio

proportion of accepted Metropolis-Hastings proposals

logMargLik

if estimateMargLik is TRUE, this list is included: it contains the elements numeratorTerms and denominatorTerms for the numerator and denominator samples of the Chib Jeliazkov marginal likelihood estimate, highDensityPointLogUnPosterior is the log unnormalized posterior density at the fixed parameter and the resulting estimate and standardError.


glmBfp documentation built on July 2, 2020, 2:30 a.m.