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,GROUP)
nan_grpstats(X,GROUP,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,GROUP)
[A,B,...] = nan_grpstats(X,GROUP,WHICHSTATS)
[...] = nan_grpstats(X,GROUP,WHICHSTATS,ALPHA)

Parameters

X:

matrix of observations

GROUP:

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

MEANS:

means of each column of X by GROUP

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)

A,B:

statistics specified by WHICHSTATS, The number of outputs [A,B,...] must match the

Description

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

GRPSTATS treats NaNs as missing values, and removes them.

Names in WHICHSTATS can be chosen from among the following:

'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

Functions in WHICHTSTATS 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