Blend

Robust Bayesian Longitudinal Regularized Semiparametric Mixed Models

CRAN CRAN RStudio mirror downloads CRAN RStudio mirror downloads

Our recently developed fully robust Bayesian semiparametric mixed-effect model for high-dimensional longitudinal studies with heterogeneous observations can be implemented through this package (Fan et al. (2026)). This model can distinguish between time-varying interactions and constant-effect-only cases to avoid model misspecifications. Facilitated by spike-and-slab priors, this model leads to superior performance in estimation, identification and statistical inference. In particular, robust Bayesian inferences in terms of valid Bayesian credible intervals on both parametric and nonparametric effects can be validated on finite samples. The Markov chain Monte Carlo algorithms of the proposed and alternative models are efficiently implemented in ‘C++’.

How to install

install.packages("devtools")
devtools::install_github("kunfa/Blend")
install.packages("Blend")

Examples

Example.1 (default method: robust structural with sparsity)

library(Blend)
data(dat)

truth = list(gamma0 = function(u) 2+2*sin(2*pi*u),
gamma1 = function(u) 2.5*exp(2.5*u-1),
gamma2 = function(u) 3*u^2-2*u+2,
gamma3 = function(u) -4*u^3+3,
gamma4 = function(u) 3-2*u,
gamma5 = 0.8,
gamma6 = -1.2,
gamma7 = 0.7,
gamma8 = -1.1,
gamma9 = 0,
gamma10 = 0,
gamma11 = 0,
gamma12 = 0,
gamma13 = 0,
gamma14 = 0,
gamma15 = 0)

fit = Blend(y,x,t,J,kn,degree)

## the posterior estimates of coefficients

fit$coefficient

## 95% empirical coverage probabilities

u = as.numeric(fit$basis$u)
rep=1000
CI_RBVSS_SI = matrix(NA, nrow=rep, ncol=length(truth))
colnames(CI_RBVSS_SI) = names(truth)
for(i in 1:rep){
 out = unlist(Coverage(fit, truth))
 CI_RBVSS_SI[i, ] = out
 cat("Replicate = ", i, "\n")
}
## the (varying) intercept has not been regularized
cp_RBVSS_SI =  colMeans(CI_RBVSS_SI) # 95% empirical coverage probabilities

## Plot the intercept function and the identified varying effects

plot_Blend(fit,sparse=TRUE)

Example.2 (alternative: robust non-structural with sparsity)

fit = Blend(y,x,t,J,kn,degree,structural=FALSE) 

Example.3 (alternative: non-robust structural with sparsity)

fit = Blend(y,x,t,J,kn,degree, robust=FALSE)

Example.4 (alternative: non-robust non-structural without sparsity)

fit = Blend(y,x,t,J,kn,degree, robust=FALSE, structural=FALSE, sparse = FALSE) 

Methods

This package provides implementation for methods proposed in