Learn R Programming

ProfileGLMM (version 1.1.0)

profileGLMM_Gibbs: R Wrapper for Profile GLMM Gibbs Sampler (C++ backend)

Description

This is the main function for fitting the Profile Generalized Linear Mixed Model using a blocked Gibbs sampling algorithm. It acts as an R wrapper, passing an object of class pglmm_data directly to the RCPP implementation GSLoopCPP. The function simulates the posterior distribution of all model parameters, including fixed effects, random effects variance, profile cluster parameters, latent effects, and cluster assignments.

Usage

profileGLMM_Gibbs(model, nIt, nBurnIn)

Value

An object of class pglmm_mcmc. This is a list containing the saved Gibbs-sampled MCMC chains for all model parameters (e.g., beta, Z, gamma, pvec, muClus, PhiClus, etc.) and the variable names from the original data. This output is intended for post-processing with profileGLMM_postProcess.

Arguments

model

An object of class glmm_data (the output of profileGLMM_preprocess). This contains the design matrices, initial values, dimensions, and prior hyperparameters.

nIt

Integer, the total number of MCMC iterations counting the burn-in period. The sampler will return nIt - nBurnIn iterations in total.

nBurnIn

Integer, the number of initial MCMC iterations that are discarded (not saved) to allow the chain to converge.

Examples

Run this code
# Load examp, which contains a pre-processed pglmm_data object
data("examp")
dataProfile = examp$dataProfile

# Run the Gibbs Sampler
MCMC_Obj = profileGLMM_Gibbs(
  model = dataProfile,
  nIt = 100,
  nBurnIn = 10
)

Run the code above in your browser using DataLab