Examples for 'emmeans::emmip'


Interaction-style plots for estimated marginal means

Aliases: emmip emmip.default emmip_ggplot emmip_lattice

Keywords:

### ** Examples

#--- Three-factor example
noise.lm = lm(noise ~ size * type * side, data = auto.noise)

# Separate interaction plots of size by type, for each side
emmip(noise.lm, type ~ size | side)
plot of chunk example-emmeans-emmip-1
# One interaction plot, using combinations of size and side as the x factor
# ... with added confidence intervals and some formatting changes
emmip(noise.lm, type ~ side * size, CIs = TRUE,
    linearg = list(linetype = "dashed"), CIarg = list(lwd = 1, alpha = 1))
plot of chunk example-emmeans-emmip-1
# One interaction plot using combinations of type and side as the trace factor
emmip(noise.lm, type * side ~ size)
plot of chunk example-emmeans-emmip-1
# Individual traces in panels
emmip(noise.lm, ~ size | type * side)
plot of chunk example-emmeans-emmip-1
# Example for the 'style' argument
fib.lm = lm(strength ~ machine * sqrt(diameter), data = fiber)
fib.rg = ref_grid(fib.lm, at = list(diameter = c(3.5, 4, 4.5, 5, 5.5, 6)^2))
emmip(fib.rg, machine ~ diameter)   # curves (because diameter is numeric)
plot of chunk example-emmeans-emmip-1
emmip(fib.rg, machine ~ diameter, style = "factor")  # points and lines
plot of chunk example-emmeans-emmip-1
# For an example using extra ggplot2 code, see 'vignette("messy-data")',
# in the section on nested models.

### Options with transformations or link functions
neuralgia.glm <- glm(Pain ~ Treatment * Sex + Age, family = binomial(),
                     data = neuralgia)

# On link scale:
emmip(neuralgia.glm, Treatment ~ Sex)
plot of chunk example-emmeans-emmip-1
# On response scale:
emmip(neuralgia.glm, Treatment ~ Sex, type = "response")
plot of chunk example-emmeans-emmip-1
# With transformed axis scale and custom scale divisions
emmip(neuralgia.glm, Treatment ~ Sex, type = "scale",
    breaks = seq(0.10, 0.90, by = 0.10))
plot of chunk example-emmeans-emmip-1

[Package emmeans version 1.7.4-1 Index]