glmm.nb | R Documentation |
This function sets up and fits negative binomial mixed models for analyzing overdispersed count responses with multilevel data structures (for example, clustered data and longitudinal studies).
glmm.nb(fixed, random, data, correlation,
niter = 30, epsilon = 1e-05, verbose = TRUE, ...)
fixed |
a formula for the fixed-effects part, including the outcome. This argument is the same as in the function |
random |
a formula for the random-effects part. It only contain the right-hand side part, e.g., ~ time | id, where time is a variable, and id the grouping factor. This argument is the same as in the function |
data |
a data.frame containing all the variables. |
correlation |
an optional correlation structure. It is the same as in the function |
niter |
maximum number of iterations. |
epsilon |
positive convergence tolerance. |
verbose |
logical. If |
... |
further arguments for |
This function is an alteration of the function glmmPQL
in the package MASS, which fits generalized linear mixed models using Penalized Quasi-Likelihood and works by repeated calls to the function lme
in the package nlme. It sets up and fits negative binomial mixed-effects models, which are the standard models for analyzing overdispersed count responses in mutilevel study designs, for example, clustered and longitudinal studies. The function allows for multiple and correlated group-specific (random) effects (the argument random
) and various types of within-group correlation structures (the argument correlation
) described by corStruct
in the package nlme.
A fitted model object of class lme
inheriting from lme
, which can be summarized by functions in the package nlme. The object also contains the estimate of the dispersion parameter theta
.
Nengjun Yi, nyi@uab.edu
Pinheiro, J.C., and Bates, D.M. (2000) "Mixed-Effects Models in S and S-PLUS", Springer.
Venables, W. N. and Ripley, B. D. (2002) "Modern Applied Statistics with S". Fourth edition. Springer.
Xinyan Zhang, Himel Mallick, Xiangqin Cui, Andrew K. Benson, and Nengjun Yi (2017) Negative Binomial Mixed Models for Analyzing Microbiome Count Data. BMC Bioinformatics 18(1):4.
Xinyan Zhang, Yu-Fang Pei, Lei Zhang, Boyi Guo, Amanda Pendegraft, Wenzhuo Zhuang and Nengjun Yi (2018) Negative Binomial Mixed Models for Analyzing Longitudinal Microbiome Data. Frontiers in Microbiology 9:1683.
Xinyan Zhang and Nengjun Yi 2020 NBZIMM: Negative Binomial and Zero-Inflated Mixed Models, with Applications to Microbiome Data Analysis. BMC Bioinformatics 21(1):488.
lme
, glmmPQL
library(NBZIMM)
# load data
data(Romero)
names(Romero)
otu = Romero$OTU; dim(otu)
sam = Romero$SampleData; dim(sam)
colnames(sam)
N = sam[, "Total.Read.Counts"]
Days = sam$GA_Days; Days = scale(Days)
Age = sam$Age; Age = scale(Age)
Race = sam$Race
preg = sam$pregnant; table(preg)
subject = sam[, "Subect_ID"]; table(subject)
# analyze one response
y = otu[, 1]
f = glmm.nb(y ~ Days + Age + Race + preg + offset(log(N)), random = ~ 1 | subject)
summary(f)
library(lme4) # compared with lme4
f0 = glmer.nb(y ~ Days + Age + Race + preg + offset(log(N)) + (1 | subject))
summary(f0)
library(mgcv) # compared with mgcv
f0 = gam(y ~ Days + Age + Race + preg + offset(log(N)) + s(subject, bs="re"),
family=nb(), method="REML")
summary(f0)
library(glmmTMB) # compared with glmmTMB
data = data.frame(y=y, Days=Days, Age=Age, Race=Race, preg=preg, N=N, subject=subject)
f0 = glmmTMB(y ~ Days + Age + Race + preg + offset(log(N)) + (1 | subject),
family = nbinom2)
summary(f0)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.