Rev 8404 | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed
% File nlme/man/groupedData.Rd% Part of the nlme package for R% Distributed under GPL 2 or later: see nlme/LICENCE.note\name{groupedData}\title{Construct a groupedData Object}\usage{groupedData(formula, data, order.groups, FUN, outer, inner,labels, units)\method{update}{groupedData}(object, formula, data, order.groups, FUN,outer, inner, labels, units, \dots)}\alias{groupedData}\alias{[.groupedData}\alias{as.data.frame.groupedData}\alias{update.groupedData}\arguments{\item{object}{an object inheriting from class \code{groupedData}.}\item{formula}{a formula of the form \code{resp ~ cov | group} where\code{resp} is the response, \code{cov} is the primary covariate, and\code{group} is the grouping factor. The expression \code{1} can beused for the primary covariate when there is no other suitablecandidate. Multiple nested grouping factors can be listed separatedby the \code{/} symbol as in \code{fact1/fact2}. In an expressionlike this the \code{fact2} factor is nested within the \code{fact1}factor.}\item{data}{a data frame in which the expressions in \code{formula} canbe evaluated. The resulting \code{groupedData} object will consistof the same data values in the same order but with additionalattributes.}\item{order.groups}{an optional logical value, or list of logicalvalues, indicating if the grouping factors should be converted toordered factors according to the function \code{FUN} applied to theresponse from each group. If multiple levels of grouping are present,this argument can be either a single logical value (which will berepeated for all grouping levels) or a list of logical values. If nonames are assigned to the list elements, they are assumed in the sameorder as the group levels (outermost to innermost grouping). Orderingwithin a level of grouping is done within the levels of the groupingfactors which are outer to it. Changing the grouping factor to anordered factor does not affect the ordering of the rows in the dataframe but it does affect the order of the panels in a trellis displayof the data or models fitted to the data. Defaults to \code{TRUE}.}\item{FUN}{an optional summary function that will be applied to thevalues of the response for each level of the grouping factor, when\code{order.groups = TRUE}, to determine the ordering. Defaults tothe \code{max} function.}\item{outer}{an optional one-sided formula, or list of one-sidedformulas, indicating covariates that are outer to the groupingfactor(s). If multiple levels of grouping are present,this argument can be either a single one-sided formula, or a list ofone-sided formulas. If no names are assigned to the list elements,they are assumed in the same order as the group levels (outermost toinnermost grouping). An outer covariate is invariant within the setsof rows defined by the grouping factor. Ordering of the groups isdone in such a way as to preserve adjacency of groups with the samevalue of the outer variables. When plotting a \code{groupedData} object,the argument \code{outer = TRUE} causes the panels to be determinedby the \code{outer} formula. The points within the panels areassociated by level of the grouping factor. Defaults to \code{NULL},meaning that no outer covariates are present.}\item{inner}{an optional one-sided formula, or list of one-sidedformulas, indicating covariates that are inner to the groupingfactor(s). If multiple levels of grouping are present,this argument can be either a single one-sided formula, or a list ofone-sided formulas. If no names are assigned to the list elements,they are assumed in the same order as the group levels (outermost toinnermost grouping). An inner covariate can changewithin the sets of rows defined by the grouping factor. An innerformula can be used to associate points in a plot of a \code{groupedData}object. Defaults to \code{NULL}, meaning that no inner covariatesare present.}\item{labels}{an optional list of character strings giving labels forthe response and the primary covariate. The label for the primarycovariate is named \code{x} and that for the response is named\code{y}. Either label can be omitted.}\item{units}{an optional list of character strings giving the units forthe response and the primary covariate. The units string for theprimary covariate is named \code{x} and that for the response isnamed \code{y}. Either units string can be omitted.}\item{\dots}{some methods for this generic require additionalarguments. None are used in this method.}}\description{An object of the \code{groupedData} class is constructed from the\code{formula} and \code{data} by attaching the \code{formula} as anattribute of the data, along with any of \code{outer}, \code{inner},\code{labels}, and \code{units} that are given. If\code{order.groups} is \code{TRUE} the grouping factor is converted toan ordered factor with the ordering determined by\code{FUN}. Depending on the number of grouping levels and the type ofprimary covariate, the returned object will be of one of threeclasses: \code{nfnGroupedData} - numeric covariate, single level ofnesting; \code{nffGroupedData} - factor covariate, single level ofnesting; and \code{nmGroupedData} - multiple levels ofnesting. Several modeling and plotting functions can use the formulastored with a \code{groupedData} object to construct default plots andmodels.}\value{an object of one of the classes \code{nfnGroupedData},\code{nffGroupedData}, or \code{nmGroupedData}, and also inheritingfrom classes \code{groupedData} and \code{data.frame}.}\references{Bates, D.M. and Pinheiro, J.C. (1997), "Software Design for LongitudinalData Analysis", in "Modelling Longitudinal and Spatially Correlated Data:Methods, Applications and Future Directions", T.G. Gregoire (ed.),Springer-Verlag, New York.\doi{10.1007/978-1-4612-0699-6_4}%% Pinheiro, J.C. and Bates, D.M. (1997) "Future Directions in%% Mixed-Effects Software: Design of NLME 3.0" (talk)%% originally available at http://nlme.stat.wisc.edu/Pinheiro, J.C., and Bates, D.M. (2000) "Mixed-Effects Modelsin S and S-PLUS", Springer.}\author{Douglas Bates and José Pinheiro}\seealso{\code{\link{formula}}, \code{\link{gapply}},\code{\link{gsummary}},\code{\link{lme}},\code{\link{plot.nffGroupedData}},\code{\link{plot.nfnGroupedData}},\code{\link{plot.nmGroupedData}},\code{\link{reStruct}}}\examples{Orth.new <- # create a new copy of the groupedData objectgroupedData( distance ~ age | Subject,data = as.data.frame( Orthodont ),FUN = mean,outer = ~ Sex,labels = list( x = "Age",y = "Distance from pituitary to pterygomaxillary fissure" ),units = list( x = "(yr)", y = "(mm)") )plot( Orth.new ) # trellis plot by Subjectformula( Orth.new ) # extractor for the formulagsummary( Orth.new ) # apply summary by Subjectfm1 <- lme( Orth.new ) # fixed and groups formulae extracted from objectOrthodont2 <- update(Orthodont, FUN = mean)}\keyword{manip}\keyword{attribute}