next up previous contents
Next: For more information Up: Other data types for Previous: Converting between ldamat and

The groups attribute for ldamat and balanced objects

  A common goal in LDA is to investigate differences between groups of time series (control and treatments, for example). ldamat and balanced objects have a special attribute, groups, which is a factor as long as the number of time series, classing each time series into a group.

The groups attribute of an ldamat or balanced object can be accessed or modified with the groups function:

groups(obj) <- newgroups
Once the groups attribute is set, this is reflected in the print representation of the object. Furthermore, the plotting and analysis function take special note of the groups attribute (see below).
Example 3.14: cows data we read in earlier (using read.balanced) does not have a groups attribute. Of the 27 time series, however, the first 4 represent a control group, the next 4 represent cows with an iron supplement, the next 9 represent cows with an infection, and the remaining 10 represent cows with the supplement and an infection. We would like to represent this in the groups attribute:
\begin{Example}
\gt groups(cows)
NULL
\gt groups(cows) <- rep(c(''Control'',''Fe...
 ...6] Fe+Infection Fe+Infection
\gt class(groups(cows))
[1] ''factor''\end{Example}
Note that the groups function ensures that the groups attribute is made into a factor.
Objects may have only one groups attribute. To represent more complicated grouping structures (such as a two way classification), you must supply factor objects separately from the ldamat or balanced object.


next up previous contents
Next: For more information Up: Other data types for Previous: Converting between ldamat and
David Smith
4/2/1998