ciFun: Calculates and plots confidence intervals for random effects.

Description Usage Arguments Details Value Examples

Description

Calculates and plots confidence intervals for random effects of lme4 models using REsim

Usage

1
2
3
ciFun(model, model.variable, data = NULL, col.variable = NULL, plot = T,
  stat = "median", level = 0.95, oddsRatio = F, nsim = 1000,
  sig.only = FALSE, group.variable, ...)

Arguments

model

A merMod object from lme4.

model.variable

Character. The name of the random effect variable to be computed.

data

An optional data frame used in model

col.variable

An optional variable name used to colour the plotted values

plot

Logical. Should a plot be produced?

stat

Character. median or mean

level

Numeric. Confidence interval to return

oddsRatio

Logical. should paramters be converted to odds ratios?

nsim

Numeric.Number of simulations to use

sig.only

Logical. Should only significant random effect levels be plotted?

group.variable

Character. Grouping variable for plots

...

other arguments passed to REsim.

Details

Use the Gelman sim technique to build empirical Bayes estimates. Uses the sim function in the arm package

Value

A data frame and plot of confidence intervals.

Examples

1
2
3
4
5
6
7
8
require(lme4)
m1 <- lmer(Reaction ~ 1 + (Days | Subject), sleepstudy)
ci1 <- ciFun(model=m1, model.variable= "Days")
d1<-cbpp
d1$period<-as.numeric(as.character(cbpp$period))
d1$response<-d1$incidence/d1$size
gm1 <- glmer(response ~ 1 + (period | herd), data = d1, weights=d1$size, family = binomial)
ci2 <- ciFun(model=gm1, model.variable= "period")

p-schaefer/psUtilities documentation built on May 24, 2019, 5:56 p.m.