Statistics Toolbox    
grpstats

Summary statistics by group

Syntax

Description

means = grpstats(X,group) returns the means of each column of X by group, where X is a matrix of observations. group is an array that defines the grouping such that two elements of X are in the same group if their corresponding group values are the same. The grouping variable group can be a vector, string array, or cell array of strings. It can also be a cell array containing several grouping variables (such as {G1 G2 G3}); in that case observations are in the same group if they have common values of all grouping variables.

[means,sem,counts,name] = grpstats(x,group,alpha) supplies the standard error of the mean in sem, the number of elements in each group in counts, and the name of each group in name. name is useful to identify and label the groups when the input group values are not simple group numbers.

grpstats(x,group,alpha) plots 100(1-alpha)% confidence intervals around each mean.

Example

We assign 100 observations to one of four groups. For each observation we measure five quantities with true means from 1 to 5. grpstats allows us to compute the means for each group.

See Also
tabulate, crosstab


  gplotmatrix gscatter