Appendix E MATLAB Statistics Toolbox The following tables list the functions that are available in the MATLAB Statistics Toolbox, Version 3.0. This toolbox is available for purchase from The MathWorks, Inc. TABL ABLE E.1 Functions for Parameter Estimation (fit) and Distribution Statistics Mean and Variance (stat) Function Purpose betafit, betastat Beta distribution. binofit, binostat Binomial distribution. expfit, expstat fstat gamfit, gamstat geostat Exponential distribution. F distribution Gamma distribution. Geometric distribution hygestat Hypergeometric distribution lognstat Lognormal distribution mle nbinstat Maximum likelihood parameter estimation. Negative binomial distribution ncfstat Noncentral F distribution nctstat Noncentral t distribution ncx2stat Noncentral Chi-square distribution normfit, normstat Normal distribution. poissfit, poisstat Poisson distribution. raylfit Rayleigh distribution. tstat unidstat T distribution Discrete uniform distribution unifit, unifstat Uniform distribution. weibfit, weibstat Weibull distribution. © 2002 by Chapman & Hall/CRC 548 Computational Statistics Handbook with MATLAB TABLE E.2 Probability Density Functions (pdf) and Cumulative Distribution Functions (cdf) Function Purpose betapdf, betacdf Beta distribution binopdf, binocdf Binomial distribution chi2pdf, chi2cdf Chi-square distribution exppdf, expcdf Exponential distribution fpdf, fcdf F distribution gampdf, gamcdf Gamma distribution geopdf, geocdf Geometric distribution hygepdf, hygecdf Hypergeometric distribution lognpdf, logncdf Log normal distribution nbinpdf, nbincdf Negative binomial distribution ncfpdf, ncfcdf Noncentral F distribution nctpdf, nctcdf Noncentral t distribution ncx2pdf, ncx2cdf Noncentral chi-square distribution normpdf, normcdf Normal distribution pdf, cdf Probability density/Cumulative distribution poisspdf, poisscdf Poisson distribution raylpdf, raylcdf Rayleigh distribution tpdf, tcdf T distribution unidpdf, unidcdf Discrete uniform distribution unifpdf, unifcdf Continuous uniform distribution weibpdf, weibcdf Weibull distribution © 2002 by Chapman & Hall/CRC Appendix E: MATLAB Statistics Toolbox 549 TABLE E.3 Critical Values (inv) and Random Number Generation (rnd) for Probability Distribution Functions Function Purpose betainv, betarnd Beta distribution binoinv, binornd Binomial distribution chi2inv, chi2rnd Chi-square distribution expinv, exprnd Exponential distribution finv, frnd F distribution gaminv, gamrnd Gamma distribution geoinv, geornd Geometric distribution hygeinv, hygernd Hypergeometric distribution logninv, lognrnd Log normal distribution nbininv, nbinrnd Negative binomial distribution ncfinv, ncfrnd Noncentral F distribution nctinv, nctrnd Noncentral t distribution ncx2inv, ncx2rnd Noncentral chi-square distribution norminv, normrnd Normal distribution poissinv, poissrnd Poisson distribution raylinv, raylrnd Rayleigh distribution tinv, trnd T distribution unidinv, unidrnd Discrete uniform distribution unifinv, unifrnd Continuous uniform distribution weibinv, weibrnd Weibull distribution icdf Specified inverse cdf © 2002 by Chapman & Hall/CRC 550 Computational Statistics Handbook with MATLAB TABLE E.4 Descriptive Statistics Function Purpose bootstrp Bootstrap statistics for any function. corrcoef Correlation coefficient - also in standard MATLAB cov Covariance - also in standard MATLAB crosstab Cross tabulation geomean Geometric mean grpstats Summary statistics by group harmmean Harmonic mean iqr kurtosis mad mean Interquartile range Kurtosis Median absolute deviation Sample average - also in standard MATLAB median Second quartile (50th percentile) of a sample - also in standard MATLAB moment Moments of a sample nanmax, nanmin nanmean, nanmedian nanstd, namsum prctile range skewness std Maximum/minimum - ignoring NaNs Mean/median - ignoring NaNs Standard deviation/sum - ignoring NaNs Percentiles Range Skewness Standard deviation - also in standard MATLAB tabulate Frequency table trimmean Trimmed mean var © 2002 by Chapman & Hall/CRC Variance - also in standard MATLAB Appendix E: MATLAB Statistics Toolbox 551 TABLE E.5 Linear Models Function Purpose anova1 One-way analysis of variance anova2 Two-way analysis of variance anovan n-way analysis of variance aoctool Interactive tool for analysis of covariance dummyvar Dummy-variable coding friedman Friedman’s test glmfit kruskalwallis lscov Generalized linear model fitting Kruskal-Wallis test Least-squares estimates with known covariance matrix manoval One-way multivariate analysis of variance manovacluster Draw clusters of group means for manova1 multcompare polyconf Multiple comparisons of means and other estimates Polynomial evaluation and confidence interval estimation polyfit Least-squares polynomial fitting- also in standard MATLAB polyval Predicted values for polynomial functions- also in standard MATLAB rcoplot Residuals case order plot regress Multivariate linear regression regstats ridge robustfit rstool stepwise x2fx © 2002 by Chapman & Hall/CRC Regression diagnostics Ridge regression Robust regression model fitting Multidimensional response surface visualization Interactive tool for stepwise regression Factor setting matrix (x) to design matrix (fx) 552 Computational Statistics Handbook with MATLAB TABLE E.6 Nonlinear Models Function nlinfit Purpose Nonlinear least-squares data fitting (Newton’s Method) nlintool Interactive graphical tool for prediction in nonlinear models nlpredci Confidence intervals for prediction nlparci Confidence intervals for parameters nnls Non-negative least-squares TABLE E.7 Cluster Analysis Function pdist squareform linkage dendrogram inconsistent cophenet cluster clusterdata © 2002 by Chapman & Hall/CRC Purpose Pairwise distance between observations Square matrix formatted distance Hierarchical cluster information Generate dendrogram plot Inconsistent values of a cluster tree Cophenetic coefficient Construct clusters from linkage output Construct clusters from data Appendix E: MATLAB Statistics Toolbox 553 TABLE E.8 Design of Experiments (DOE) and Statistical Process Control (SPC) Function Purpose cordexch D-optimal design (coordinate exchange algorithm) daugment Augment D-optimal design dcovary ff2n D-optimal design with fixed covariates Two-level full-factorial design fracfact Two-level fractional factorial design fullfact Mixed-level full-factorial design hadamarad Hadamard matrices (orthogonal arrays) rowexch D-optimal (row exchange algorithm) capable Capability indices capaplot Capability plot ewmaplot Exponentially weighted moving average plot histfit Histogram with superimposed normal density normspec schart xbarplot Plot normal density between specification limits S chart for monitoring variability Xbar chart for monitoring the mean TABLE E.9 Multivariate Statistics and Principal Component Analysis Function classify mahal manova1 barttest Purpose Linear discriminant analysis Mahalanobis distance One-way multivariate analysis of variance Bartlett’s test for dimensionality pcacov Principal components from covariance matrix pcares Residuals from principal components princomp © 2002 by Chapman & Hall/CRC Principal component analysis from raw data 554 Computational Statistics Handbook with MATLAB TABLE E.1 E.10 Hypothesis Tests Function ranksum Purpose Wilcoxon rank sum test (independent samples) signrank Wilcoxon sign rank test (paired samples) signtest Sign test (paired samples) ztest Z test ttest One sample t test ttest2 Two sample t test jbtest Jarque-Bera test of normality kstest Kolmogorov-Smirnov test for one sample kstest2 Kolmogorov-Smirnov test for two samples lillietest Lilliefors test of normality TABLE E.1 E.11 Statistical Plotting Function Purpose cdfplot Plot of empirical cumulative distribution function fsurfht Interactive contour plot of a function gline Point, drag and click line drawing on figures gname Interactive point labeling in x-y plots gplotmatrix gscatter lsline normplot qqplot refcurve refline surfht weibplot © 2002 by Chapman & Hall/CRC Matrix of scatter plots grouped by a common variable Scatter plot of two variables grouped by a third Add least-square fit line to scatter plot Normal probability plot Quantile-quantile plot Reference polynomial curve Reference line Interactive contour plot of a data grid Weibull probability plot Appendix E: MATLAB Statistics Toolbox 555 TABLE E.1 E.12 Statistics Demos Function aoctool disttool glmdemo Purpose Interactive tool for analysis of covariance GUI tool for exploring probability distribution functions Generalized linear model slide show polytool Interactive graph for prediction of fitted polynomials randtool GUI tool for generating random numbers rsmdemo robustdemo Reaction simulation Interactive tool to compare robust and least squares fits TABLE E.1 E.13 File-based I/O Function tblread tblwrite tdfread caseread casewrite © 2002 by Chapman & Hall/CRC Purpose Read in data in tabular format Write out data in tabular format in file Read in text and numeric data from tab-delimited file Read in case names Write out case names to file