Editing variable labels for dotplot of (g)lmer object with R/Lattice -
i'm using glmer()
function lme4
package estimate complex mixed effects models multiple random effects. after model estimated, i'm using dotplot()
function lattice
package create dotplot of random effects, include varying slopes. inquiry concerns how edit variable labels in dotplot
a simple reproducible example of problem goes follows.
library(lattice) library(lme4) data(sleepstudy) sleepstudy$x <- rnorm(180) m1 <- lmer(reaction ~ days + x + (days + x | subject), sleepstudy) dotplot(ranef(m1, condvar=true), ylab="levels", main=false, scales = list(x =list(relation = 'free')))[["subject"]]
this produces following dotplot, approximates want.
what edit variable labels. namely, i'd remove parentheses "(intercept)", , change labels both varying slopes other variable names called glmer()
. possible? i'm sure , it's "strip" option, though i'm not sure be.
i'd open ggplot2
solution well. either/or fine long gets want. in fact, ggplot2
solution might better if allows me adjust bounds on conditional variance 1.645*se. don't think lattice
give me option.
thanks help.
one simple way assuming no native renaming functionality add intermediate variable assign ranef(m1,condvar=true)
to, call model
. can use colnames()
rename labels.
solution:
library(lattice) library(lme4) data(sleepstudy) sleepstudy$x <- rnorm(180) m1 <- lmer(reaction ~ days + x + (days + x | subject), sleepstudy) model <- ranef(m1,condvar=true) colnames(model[[1]]) <- c("intercept","days","x") # add labelshere dotplot(model, ylab="levels", main=false, scales = list(x =list(relation = 'free')))[["subject"]]
alternatively, coerce data.frame()
or data.table()
, use in ggplot2
mentioned.
Comments
Post a Comment