Learn R Programming

ProfileGLMM (version 1.0.2)

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 (Profile GLMM) using a blocked Gibbs sampling algorithm. It acts as an R wrapper, passing pre-processed data, initial values, and prior hyperparameters contained in the model object directly to the C++ 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

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 ready for post-processing with profileGLMM_postProcess.

Arguments

model

A list object containing all data, initial parameter values, model dimensions, prior hyperparameters, and model configuration (e.g., regression type). This object is typically the output of a data processing function like process_Data_outcome. Key components include:

d:

Data matrices (Y, XFE, XRE, XLat, UCont, UCat).

params:

Model dimension parameters (e.g., nC, qRE, qUCont).

theta:

Initial values for parameters (\(\beta_{FE}\), \(\sigma^2\), \(\Sigma_{RE}\), cluster means, cluster covariance, cluster prob. vectors, \(\Sigma_{Lat}\), \(\gamma_{Lat}\)).

prior:

Hyperparameters for all prior distributions (e.g., Normal, Inverse-Wishart, Dirichlet).

regType:

The type of regression being performed.

nIt

Integer, the total number of MCMC iterations *counting* the burn-in period. The sampler will run for 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 dataProfile, the result of profileGLMM_pREProcess()
data("examp")
dataProfile = examp$dataProfile
MCMC_Obj = profileGLMM_Gibbs(model = dataProfile,
   nIt = 100,
   nBurnIn = 10
 )

Run the code above in your browser using DataLab