Code covered by the BSD License  

Highlights from
Non-parametric error/confidence intervals

Be the first to rate this file! 5 Downloads (last 30 days) File Size: 1.86 KB File ID: #27067

Non-parametric error/confidence intervals

by Matthew Nelson

 

24 Mar 2010

Calc standard error of the mean or non-parametric confidence intervals for samples of a time series

| Watch this File

File Information
Description

The entire function is as follows:

function Err = DataSeriesNonParamErr(Dat,Type,alpha)
%function Err = DataSeriesNonParamErr(Dat,Type,'alpha)
%
% Calculate non-parametric error bars at every point in the input array
% Dat, based on Type. If Type is 0, the program will calculate the standard
% error of the mean. If Type is 1 it will calculate (conservative)
% confidence intervals based on the Vysochanskij–Petunin inequality using
% the standard error of the mean, or if Type is 2 it will use the Chebyshev
% inequality to produce even more conservative confidnece intervals.
%
% Inputs: Dat- Input data series (nSamp x nTimePoints). An error
% estimate is given for each time point. NaNs in the input.
% Type- What type of an error estimate to use. Options are 0
% (default) for the standard error of the mean, 1 for
% Vysochanskij–Petunin confidence intervals, or 2 for
% Chebyshev confidence intervals.
% alpha- The alpha level used for the confidence intervals. This
% value is ignored if plotting the standard error of the
% mean.
%
% Outputs: CHi- A 2 x nTimePoints array of error estimates, where the
% first row stores the High error estimate, and the
% second row stored the Low error estimate.
%
% According to: http://en.wikipedia.org/wiki/Vysochanski%C3%AF-Petunin_inequality
% the Vysochanskij–Petunin inequality is like the Chebyshev inequality, but
% can be slightly less conservative because of an assumption that the
% underlying distribution is unimodal.
%
% 100322 by Matthew Nelson
% nelsonmj@caltech.edu

if nargin<3 || isempty(alpha); alpha = 0.05; end
if nargin<2 || isempty(Type); Type = 0; end

switch Type
    case 0
        lam=1;
    case 1 %Vysochanskij–Petunin
        lam=sqrt(4/(9*alpha));
    case 2 %Chebyshev
        lam=sqrt(1/alpha);
end

sem= nanstd(Dat,1) ./ sqrt( sum(~isnan(Dat),1) ) * lam;
tmpmn=nanmean(Dat,1);

Err=[tmpmn + sem; tmpmn-sem];

Required Products Statistics Toolbox
MATLAB release MATLAB 7.9 (2009b)
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Please login to add a comment or rating.
Tag Activity for this File
Tag Applied By Date/Time
statistics Matthew Nelson 24 Mar 2010 12:44:55
nonparametric Matthew Nelson 24 Mar 2010 12:44:55
chebyshev Matthew Nelson 24 Mar 2010 12:44:55
vysochanskij–petunin Matthew Nelson 24 Mar 2010 12:44:55
standard error Matthew Nelson 24 Mar 2010 12:44:56
confidence intervals Matthew Nelson 24 Mar 2010 12:44:56

Contact us at files@mathworks.com