simglmm | R Documentation |
Simulate data from linear and generalized linear mixed models. The coefficients of the two covariate are specified by beta
.
simglmm(family=c("binomial","gaussian","poisson","negative.binomial"),
beta=c(2,0),tau=1,n=200,m=10,balance=TRUE)
family |
the family of the distribution. |
beta |
regression coefficients (excluding the intercept which is set as zero). |
tau |
the variance of the random intercept. |
n |
the sample size. |
m |
the number of groups. |
balance |
simulate balanced data if TRUE, unbalanced data otherwise. |
The first covariate takes 1 in half of the observations, and 0 or -1 in the other half. When beta
gets larger, it is supposed to easier to predict the response variable.
Returned values include yx
, beta
, and u
.
yx |
a data frame including the response |
beta |
true values of the regression coefficients. |
u |
the random intercepts. |
Dabao Zhang, Department of Statistics, Purdue University
Zhang, D. (2020). Coefficients of determination for generalized linear mixed models. Technical Report, 20-01, Department of Statistics, Purdue University.
rsq, rsq.lmm, rsq.glmm, simglm
,
require(lme4)
# Linear mixed models
gdata <- simglmm(family="gaussian")
lmm1 <- lmer(y~x1+x2+(1|subject),data=gdata$yx)
rsq(lmm1)
# Generalized linear mixed models
bdata <- simglmm(family="binomial",n=400,m=20)
glmm1 <- glmer(y~x1+x2+(1|subject),family="binomial",data=bdata$yx)
rsq(glmm1)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.