next up previous contents
Next: The groups attribute for Up: Other data types for Previous: Coded missing values

Converting between ldamat and balanced objects

  Any ldamat object can be converted into a balanced object with the function as.balanced. If the component time series of the ldamat object had common t components to begin with, then that t component becomes the t component of the resulting balanced object. If not, then the union of all the time points in the ldamat object becomes the t component of the balanced object, and for each time series any time points not contained in that time series in the ldamat object appear in the time series in the balanced object, but with NA as the value.
Example 3.13: components of the ratmat object we created earlier had common time points, making it an ideal candidate to be converted into a balanced object:
\begin{Example}
\gt ratbal <- as.balanced(ratmat)
\gt ratbal
 [,1] [,2] [,3] [,4...
 ...57 86 114 139 172
 tmt.1 57 82 110 139 169
 tmt.2 61 86 109 120 129\end{Example}
Note that the common t component makes for a somewhat more compact printed representation.

For demonstration purposes, let's make the first time series in ratmat of a different length, and see what happens then.
\begin{Example}
\gt ratmat[1] <- ldats(c(tsy(rat.1),195))
\gt ratmat

 control :...
 ...139 172 195
 tmt.1 57 82 110 139 169 NA
 tmt.2 61 86 109 120 129 NA\end{Example}
The other two time series have been ``padded out'' with NA's to fit in the data matrix.

Incidentally, as.balanced is also useful with ordinary matrices; if X is a matrix then as.balanced(X) returns the same value as balanced(X).

An analogous function as.ldamat also exists to convert balanced objects into ldamat objects, although this is a rather less common procedure.


next up previous contents
Next: The groups attribute for Up: Other data types for Previous: Coded missing values
David Smith
4/2/1998