For longitudinal data with a numeric outcome, I can use spaghetti plots to visualize the data. For example something like this (taken from the UCLA Stats site):
tolerance<-read.table("http://www.ats.ucla.edu/stat/r/faq/tolpp.csv",sep=",", header=T)
head(tolerance, n=10)
interaction.plot(tolerance$time, tolerance$id, tolerance$tolerance,
xlab="time", ylab="Tolerance", legend=F)
But what if my outcome is binary 0 or 1? For example, in the "ohio" data in R the binary "resp" Variable indicates the presence of a respiratory disease:
library(geepack)
ohio2 <- ohio[2049:2148,]
head(ohio2, n=12)
resp id age smoke
2049 1 512 -2 1
2050 0 512 -1 1
2051 0 512 0 1
2052 0 512 1 1
2053 1 513 -2 1
2054 0 513 -1 1
2055 0 513 0 1
2056 1 513 1 1
2057 1 514 -2 1
2058 0 514 -1 1
2059 0 514 0 1
2060 1 514 1 1
interaction.plot(ohio2$age+9, ohio2$id, ohio2$resp,
xlab="age", ylab="Wheeze status", legend=F)
The spaghetti plot gives a nice figure, but is not very informative and does not tell me much. What would be a suitable way to visualize this kind of data? Maybe something that includes a probability-value on the y-axis?
ohio
data (2.15) (at least not as part of base). Is it in a newer version or via some other library? This would be an interesting application for a heat-map with individuals on the Y axis and outcomes on the X axis, then plot 1 responses as black and 0 responses as white. Sorting the matrix will then provide an overview of how prevalent different patterns are. $\endgroup$geepack
package. $\endgroup$