plot_mm function

Spaghetti plot and plot of the mean at each time

Spaghetti plot and plot of the mean at each time

plot_mm( formula, data, col.spag = 1, col.mean = 1, type = "spaghettis", tick.times = TRUE, xlab = NULL, ylab = NULL, main = "", lwd.spag = 1, lwd.mean = 4, ... )

Arguments

  • formula: obs~time+(group|id) or obs~time+(1|id)
  • data: data frame in which we can find obs, time, group and id
  • col.spag: vector of length nrow(data) with colors (one for each individual)
  • col.mean: vector of length length(levels(group)) with colors (one for each group)
  • type: "spaghettis", "mean" or "both"
  • tick.times: boolean, TRUE to display ticks at each observation time on the x-axis
  • xlab: character sring, label of the time axis
  • ylab: character string, label of the y axis
  • main: character string, main title
  • lwd.spag: numeric, width of the spaghetti lines, 1 by default
  • lwd.mean: numeric, width of the mean lines, 4 by default
  • ...: Other arguments to be passed in plot

Returns

None

Examples

N=10 time=rep(1:4,N) obs=1.1*time + rep(0:1,each=2*N) + rnorm(4*N) my.data=data.frame(id=rep(1:N,each=4),time,obs,group=rep(1:2,each=N*2)) par(xaxs="i",yaxs="i") plot_mm(obs~time+(group|id),my.data,col.spag=my.data$group, col.mean=c("blue","red"),type="both",main="Test plot_mm")

Author(s)

Hugo Varet on Anais Charles-Nelson's idea

  • Maintainer: Hugo Varet
  • License: GPL (>= 2)
  • Last published: 2025-03-24

Useful links