next up previous contents
Next: Kernel smoothing Up: Exploring longitudinal data Previous: Customising your plot

Using trellis graphics for longitudinal data

S-plus provides Trellis Graphics: a powerful tool for plotting complex data sets which can be applied to longitudinal data. To make use of this facility, the data must be stored in data frame format (so ldframe objects work without modification) so that the standard Trellis functions may be used to display longitudinal data. For example, we may wish to plot the milk data for each group, adding a loess curve (as shown in Figure 6):


  
Figure 6: Trellis plot of the milk data, with a loess curve for each group
\begin{figure}
\begin{center}
 \leavevmode
 
\psfig {figure=trellis1.ps}

 \end{center}\end{figure}


\begin{Example}
\gt milk.df <- na.omit(milk.ldf)
\gt trellis.device(motif)
\gt x...
 ...unction(x,y) \{ 
+ panel.xyplot(x,y)
+ panel.loess(x,y,span=0.2)\})\end{Example}

OSWALD provides an additional Trellis function specifically for plotting longitudinal data. ldaplot creates a similar plot to plot.ldframe with differing line styles between groups and shadows (if the p argument is less than 1). It does not, however, highlight missing values or dropout like plot.ldframe. For example, the following two statements produce similar plots:
\begin{Example}
\gt ldaplot(y ~ Time, data=milk.ldf, p=0.2)
\gt plot(milk, p=0.2, drop=F, miss=F)\end{Example}

The reader is referred to Becker & Cleveland (1996) for further information.



David Smith
4/2/1998