<< nan_geomean Descriptive Statistics nan_harmmean >>

NaN Toolbox >> NaN Toolbox > Descriptive Statistics > nan_grpstats

nan_grpstats

Summary statistics by group.

Calling Sequence

MEANS = nan_grpstats(X,groups)
nan_grpstats(X,groups,ALPHA) displays a plot of the means versus index with  100(1 - ALPHA)% confidence intervals around each mean.
[MEANS,SEM,COUNTS,GNAME] = nan_grpstats(X,groups)
[A,B,...] = nan_grpstats(X,groups,whichstats)
[...] = nan_grpstats(X,groups,whichstats,ALPHA)

Parameters

X:

matrix of observations

groups:

grouping variable defined as a vector, string array, or list of strings.

MEANS:

means of each column of X by groups

SEM:

standard error of the mean

COUNTS:

number of elements in each group

GNAME:

name of each group

ALPHA:

specifies the confidence level as 100(1-ALPHA)% for the 'meanci' and 'predci' options.

whichstats:

a list of single function handles or names (strings)

the following strings are allowed for whichstats:

'mean' :

mean

'sem' :

standard error of the mean

'numel':

count, or number of elements

'gname':

group name

'std' :

standard deviation

'var' :

variance

'min' :

minimum

'max' :

maximum

'range':

maximum - minimum

'meanci':

95% confidence interval for the mean

'predci':

95% prediction interval for a new observation

A,B:

statistics specified by whichstats, The number of outputs [A,B,...] must match the number function handles and names in whichstats.

Description

nan_grpstats computes groupwise summary statistics, for data in a matrix or dataset array.

nan_grpstats treats NaNs as missing values, and removes them.

Functions in whichstats must accept a matrix and give out one values for each columns.

Examples

loadmatfile("demos/data/iris.mat");
[m,p,g] = nan_grpstats(meas,species,list('mean','predci','gname'))
n = size(m,1)
plot2d((1:n)',m)
nan_errorbar(ones(1,4) .*. (1:n)',m,p(:,:,2)-m,p(:,:,2)-m)
h=gca();
h.data_bounds(:,1)=[0.9;3.1];
title('95% prediction intervals for mean iris size by species')
scf()
nan_grpstats(meas,species,0.05)

See also

<< nan_geomean Descriptive Statistics nan_harmmean >>