bayes_ridge_semi_v4: Bayesian ridge for longitudinal semiparemetric models

Description Usage Arguments Details Value

View source: R/semi2.R

Description

This is a Gibbs sampler v4 for fitting Bayesian longitudinal semiparametric models. It assumes that there are multiple populations in the model and each population is modelled by a population 'mean' curve. Within each population, they are multiple subjects, and each subject are modelled by a 'subject' curve. The subject curves are treated as deviations from their respective mean curves. On top of that, fixed or random effects can be added to the model. This is useful when, for example, a particular treatment was applied to some of the populations or subjects, and the user is interested in the effect of the treatment.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
bayes_ridge_semi_v4(
  y,
  Bmat,
  Xmat,
  prior = NULL,
  prec = NULL,
  init = NULL,
  burn = 0,
  size = 1000,
  debug = TRUE
)

Arguments

y

A vector of the response vector.

Bmat

A named list of design matrices (or a list of design matrices for each subject for the subject spline) for the splines terms with at least the following attributes: 'spl_dim', 'is_sub', 'level'. For subject-specific splines (i.e. is_sub = TRUE), it is a block-diagonal matrix and specified as a list of matrices corresponding to each diagonal element. The list should also have a 'block_dim' attribute. For other splines, it is a matrix and should have a 'penalty' attribute. At least an element of Bmat must be 'is_sub = TRUE'. See details.

Xmat

A named list of design matrices for the non-spline terms, e.g. fixed and random effects.

prior

unknown yet

prec

An optional named list with three elements 'spl', 'eff' and 'eps'. If supplied, the precisions of the model are fixed. Each of the 'spl' and 'eff' terms is a named list of precisions that correspond to 'Bmat' and 'Xmat' respectively, and the names of the list must match. All the elements are square matrices with the dimension matching 'spl_dim' of Xmat or Bmat, except 'eps' which is a number. A zero precision will imply that the term is fixed.

init

An initial values of the regression coefficients for the sampler...

burn

The number of samples to be burned before actual sampling.

size

The number of samples to be obtained from the samples.

Details

THIS FUNCTION IS FOR INTERNAL USE ONLY AND NEVER MEANT TO BE EXPORTED.

The mean and subject curves are modelled as linear (in statistical sence, not only stright lines). This includes polynomials and splines. The attributes of their design matrices (i.e. Bmat) are

'spl_dim' is the dimension of the splines. This is actually redundant (can be inferred from 'level' and the dims of Bmat), but is still included for verification and for easy query of the spline dimension.

'is_sub' is a boolean that specifies whether the spline term is a subject-specific deviations. One of the spline must be a subject spline.

'level' is the name of each population or subject. The order of the names should match the corresponding column entries in Bmat/list of Bmat. Use a dummy name if there is only one level.

'block_dim' is the dimension of the subject deviations where the precision should be considered as a block. See paper for more details.

'penalty' relates to the precision of the prior of the mean curve coefficient, which is a multiple of crossprod('penalty'), i.e. crossprod('penalty'

The semiparametric model is

y = Bmat[[1]]

y is a vector of observation, Bmat[[...]] constitute the mean curve, Xmat[[...]] effects, Bmat[[sub]] \epsilon are Gaussian errors.

The coefficients \theta, \delta, \beta and \epsilon are all Gaussian, but their covariance structures are not necessarily diagonal. Consult the manual/paper for more info.

The sampler first updates the coefficients, then the precisions. The joint conditional posterior of all the coefficients is often highly correlated, but fortunately a closed-form expression is available and is utilised here. This implies that the convergence of this Gibbs sampler is quick and does not require burning many samples in the beginning. The starting values of the sampler are precisions with a reasonably large value (hence a large penalty).

Value

A list of length two, posterior samples and means are stored in 'samples' and 'means' elements respectively. Within each elements, 'coef' are the regression coefficients and 'prec' the precisions. The coef samples are organised as a list of arrays (dim_spl * length(level) * size) and a list of matrices (ncol(Xmat) * size) for effects. The prec samples are arrays for splines and effects terms, and vector for epsilon. The samples are always populated along the last dimension of the array/matrix/vector.


weiyaw/flexss documentation built on June 16, 2021, 7:48 a.m.