mixedBayes: fit a Bayesian longitudinal regularized quantile mixed model

View source: R/mixedBayes.R

mixedBayesR Documentation

fit a Bayesian longitudinal regularized quantile mixed model

Description

fit a Bayesian longitudinal regularized quantile mixed model

Usage

mixedBayes(
  y,
  e,
  X,
  g,
  w,
  k,
  iterations = 10000,
  burn.in = 5000,
  slope = TRUE,
  robust = TRUE,
  quant = 0.5,
  sparse = TRUE,
  structure = "bi-level"
)

Arguments

y

a numeric vector of repeated-measure responses in long format. The current version only supports continuous response.

e

the long-format design matrix for environment/treatment effects. In applications, this is a group of dummy variables encoding treatment levels.

X

the long-format design matrix, including an intercept and optionally time-related covariates.

g

the long-format matrix of genetic predictors.

w

the long-format matrix of gene-environment interaction terms.

k

integer. Number of repeated measurements per subject.

iterations

the number of MCMC iterations. The default value is 10,000.

burn.in

the number of iterations for burn-in. If NULL, no burn-in is applied and all MCMC samples are retained. The default value is 5,000.

slope

logical flag. If TRUE, random intercept-and-slope model will be used. Otherwise, random intercept model will be used. The default value is TRUE.

robust

logical flag. If TRUE, robust methods will be used. Otherwise, non-robust methods will be used. The default value is TRUE.

quant

the quantile level specified by users. Required when robust = TRUE. Ignored (set to NULL) when robust = FALSE. The default value is 0.5.

sparse

logical flag. If TRUE, spike-and-slab priors will be adopted to impose exact sparsity on regression coefficients. Otherwise, Laplacian shrinkage will be adopted. The default value is TRUE.

structure

two choices are available. "bi-level" performs selection on both main effects and interaction effects corresponding to individual and group levels, whereas "individual" performs selections only on individual levels by ignoring the group structure.

Details

Data layout

Consider a longitudinal study with repeated measurements per subject. The response vector y and the design matrices X, e, g, and w must all be provided in long format and share the same row ordering. In practice, each row corresponds to one observation from a particular subject at a particular time point.

Model

Consider the data model described in "data":

\boldsymbol{Y_{ij}} = \boldsymbol{X^\top_{ij}}\boldsymbol{\gamma_{0}}+\boldsymbol{E^\top_{ij}}\boldsymbol{\gamma_{1}}+\boldsymbol{G^\top_{ij}}\boldsymbol{\gamma_{2}}+(\boldsymbol{G_{ij}}\bigotimes \boldsymbol{E_{ij}})^\top\boldsymbol{\gamma_{3}}+\boldsymbol{Z^\top_{ij}}\boldsymbol{\alpha_{i}}+\epsilon_{ij}.

Here \boldsymbol{\gamma_{0}} is the coefficient vector for \boldsymbol{X_{ij}}, \boldsymbol{\gamma_{1}} is the coefficient vector for \boldsymbol{E_{ij}}, \boldsymbol{\gamma_{2}} is the coefficient vector for the genetic variants, and \boldsymbol{\gamma_{3}} is the coefficient vector for the interactions of the genetic variants with environment factors.

where \boldsymbol{\gamma_{1}}=(\gamma_{11},\dots,\gamma_{1p})^\top, \boldsymbol{\gamma_{2}}=(\gamma_{21},\dots,\gamma_{2m})^\top, \boldsymbol{\gamma_{3}}=(\boldsymbol{\gamma_{31}},\dots,\boldsymbol{\gamma_{3m}})^\top where \boldsymbol{\gamma_{3l}}=(\gamma_{3l1},\dots,\gamma_{3lp})^\top for l=1,\dots,m.

The subject-specific random effects \boldsymbol{\alpha_i} capture within-subject correlation. For random intercept-and-slope model, \boldsymbol{Z^\top_{ij}} = (1,j) and \boldsymbol{\alpha_{i}} = (\alpha_{i1},\alpha_{i2})^\top. For random intercept model, Z_{ij} = 1 and \alpha_{i} = \alpha_{i1}.

When 'structure="bi-level"'(default), bi-level selection on main and interaction effects will be conducted corresponding to individual and group levels, respectively. When 'structure="individual"', selections only on individual levels by ignoring the group structure will be performed.

When 'slope=TRUE' (default), random intercept-and-slope model will be used as the mixed effects model. Otherwise, random intercept model will be used.

When 'sparse=TRUE' (default), spike-and-slab priors are imposed to identify important main and interaction effects. Otherwise, Laplacian shrinkage will be used.

When 'robust=TRUE' (default), the distribution of \epsilon_{ij} is defined as an asymmetric Laplace distribution with density.

f(\epsilon_{ij}|\theta,\tau) = \theta(1-\theta)\exp\left\{-\tau\rho_{\theta}(\epsilon_{ij})\right\} , (i=1,\dots,n,j=1,\dots,k ), which leads to a Bayesian formulation of quantile regression. Otherwise, \epsilon_{ij} follows a normal distribution.

Please check the references for more details about the prior distributions.

Value

an object of class ‘mixedBayes’ is returned, which is a list with component:

posterior

posterior samples for fixed effects and random effects.

coefficient

posterior median estimates of coefficients for fixed effects and random effects.

See Also

data

Examples

data(data)

## default method (robust sparse bi-level selection under random intercept-and-slope model)
fit = mixedBayes(y,e,X,g,w,k,structure="bi-level")
fit$coefficient

## Compute TP and FP
b = selection(fit,sparse=TRUE)
index = which(coeff!=0)
pos = which(b != 0)
tp = length(intersect(index, pos))
fp = length(pos) - tp
list(tp=tp, fp=fp)

## alternative: robust sparse individual level selections under random intercept-and-slope model
fit = mixedBayes(y,e,X,g,w,k,structure="individual")
fit$coefficient

## alternative: non-robust sparse bi-level selection under random intercept-and-slope model
fit = mixedBayes(y,e,X,g,w,k,robust=FALSE, quant = NULL, structure="bi-level")
fit$coefficient

## alternative: robust sparse bi-level selection under random intercept model
fit = mixedBayes(y,e,X,g,w,k,slope=FALSE, structure="bi-level")
fit$coefficient




mixedBayes documentation built on March 17, 2026, 1:07 a.m.