File: spaghetti.Rd

package info (click to toggle)
r-cran-lava 1.8.1%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,816 kB
  • sloc: sh: 13; makefile: 2
file content (117 lines) | stat: -rw-r--r-- 2,329 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/spaghetti.R
\name{spaghetti}
\alias{spaghetti}
\title{Spaghetti plot}
\usage{
spaghetti(
  formula,
  data = NULL,
  id = "id",
  group = NULL,
  type = "o",
  lty = 1,
  pch = NA,
  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,
  trend.jitter = 0,
  legend = NULL,
  by = NULL,
  xlab = "Time",
  ylab = "",
  add = FALSE,
  ...
)
}
\arguments{
\item{formula}{Formula (response ~ time)}

\item{data}{data.frame}

\item{id}{Id variable}

\item{group}{group variable}

\item{type}{Type (line 'l', stair 's', ...)}

\item{lty}{Line type}

\item{pch}{Colour}

\item{col}{Colour}

\item{alpha}{transparency (0-1)}

\item{lwd}{Line width}

\item{level}{Confidence level}

\item{trend.formula}{Formula for trendline}

\item{tau}{Quantile to estimate (trend)}

\item{trend.lty}{Trend line type}

\item{trend.join}{Trend polygon}

\item{trend.delta}{Length of limit bars}

\item{trend}{Add trend line}

\item{trend.col}{Colour of trend line}

\item{trend.alpha}{Transparency}

\item{trend.lwd}{Trend line width}

\item{trend.jitter}{Jitter amount}

\item{legend}{Legend}

\item{by}{make separate plot for each level in 'by' (formula, name of column, or vector)}

\item{xlab}{Label of X-axis}

\item{ylab}{Label of Y-axis}

\item{add}{Add to existing device}

\item{...}{Additional arguments to lower level arguments}
}
\description{
Spaghetti plot for longitudinal data
}
\examples{
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"
N <- 50
d <- sim(m,N); d$z <- rbinom(N,1,0.5)
dd <- mets::fast.reshape(d); dd$num <- dd$num+3
spaghetti(y~num,dd,id="id",lty=1,col=Col(1,.4),
          trend.formula=~factor(num),trend=TRUE,trend.col="darkblue")
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")
spaghetti(y~num,dd,id="id",lty=1,col=Col(1,.4),
           trend.formula=~num+I(num^2),trend=TRUE,trend.col="darkblue")
}
}
\author{
Klaus K. Holst
}