Spaghetti plot

Share:

Description

Spaghetti plot for longitudinal data

Usage

1
2
3
4
5
6
spaghetti(formula, data, id = "id", group = NULL, type = "l", lty = 1,
  col = 1:10, alpha = 0.3, lwd = 1, level = 0.95,
  trend.formula = formula, tau = NULL, trend.lty = 1, trend.join = TRUE,
  trend.delta = 0.2, trend = !is.null(tau), trend.col = col,
  trend.alpha = 0.2, trend.lwd = 3, legend = NULL, xlab = "Time",
  ylab = "", add = FALSE, ...)

Arguments

formula

Formula (response ~ time)

data

data.frame

id

Id variable

group

group variable

type

Type (line 'l', stair 's', ...)

lty

Line type

col

Colour

alpha

transparency (0-1)

lwd

Line width

level

Confidence level

trend.formula

Formula for trendline

tau

Quantile to estimate (trend)

trend.lty

Trend line type

trend.join

Trend polygon

trend.delta

Length of limit bars

trend

Add trend line

trend.col

Colour of trend line

trend.alpha

Transparency

trend.lwd

Trend line width

legend

Legend

xlab

Label of X-axis

ylab

Label of Y-axis

add

Add to existing device

...

Additional arguments to lower level arguments

Author(s)

Klaus K. Holst

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
if (interactive() & requireNamespace("mets")) {
K <- 5
y <- "y"%++%seq(K)
m <- lvm()
regression(m,y=y,x=~u) <- 1
regression(m,y=y,x=~s) <- seq(K)-1
regression(m,y=y,x=~x) <- "b"
d <- sim(m,500)
dd <- mets::fast.reshape(d);
dd$num <- dd$num+rnorm(nrow(dd),sd=0.5) ## Unbalance
spaghetti(y~num,dd,id="id",lty=1,col=Col(1,.4),trend=TRUE,trend.col="darkblue")
}

Want to suggest features or report bugs for rdrr.io? Use the GitHub issue tracker.