Click here to load reader

Multivariate Statistical functions in R

  • View
    1.407

  • Download
    1

Embed Size (px)

DESCRIPTION

Multivariate hypothesis testing, correlation and multivariate regression, multivariate discriminant analysis. In addition some other useful general functions. Functions for compositional data and directional data as well. All of these functions are written in R.

Text of Multivariate Statistical functions in R

Multivariate statistical functions in RMichail T. [email protected] of engineering and technology, American university of the middleeast, Egaila, KuwaitVersion 6.1Athens, Nottingham and Abu Halifa (Kuwait)7 November 2014Contents1 Mean vectors 11.1 Hotellings one-sample T2test . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11.2 Hotellings two-sample T2test . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21.3 Two two-sample tests without assuming equality of the covariance matrices . . 41.4 MANOVA without assuming equality of the covariance matrices . . . . . . . . 62 Covariance matrices 92.1 One sample covariance test . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92.2 Multi-sample covariance matrices . . . . . . . . . . . . . . . . . . . . . . . . . . 102.2.1 Log-likelihood ratio test . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102.2.2 Boxs M test . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 113 Regression, correlation and discriminant analysis 133.1 Correlation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 133.1.1 Correlation coefcient condence intervals and hypothesis testing us-ing Fishers transformation . . . . . . . . . . . . . . . . . . . . . . . . . . 133.1.2 Non-parametric bootstrap hypothesis testing for a zero correlation co-efcient . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 143.1.3 Hypothesis testing for two correlation coefcients . . . . . . . . . . . . . 153.2 Regression . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 153.2.1 Classical multivariate regression . . . . . . . . . . . . . . . . . . . . . . . 153.2.2 k-NN regression . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 173.2.3 Kernel regression . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 203.2.4 Choosing the bandwidth in kernel regression in a very simple way . . . 233.2.5 Principal components regression . . . . . . . . . . . . . . . . . . . . . . . 243.2.6 Choosing the number of components in principal component regression 263.2.7 The spatial median and spatial median regression . . . . . . . . . . . . . 273.2.8 Multivariate ridge regression . . . . . . . . . . . . . . . . . . . . . . . . . 293.3 Discriminant analysis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 313.3.1 Fishers linear discriminant function . . . . . . . . . . . . . . . . . . . . . 313.3.2 k-fold cross validation for linear and quadratic discriminant analysis . . 323.3.3 A simple model selection procedure in discriminant analysis . . . . . . . 343.3.4 Box-Cox transformation in discriminant analysis . . . . . . . . . . . . . . 363.3.5 Regularised discriminant analysis . . . . . . . . . . . . . . . . . . . . . . 373.3.6 Tuning the and parameters in regularised discriminant analysis . . . 393.4 Robust statistical analyses . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 403.4.1 Robust multivariate regression . . . . . . . . . . . . . . . . . . . . . . . . 403.4.2 Robust correlation analysis and other analyses . . . . . . . . . . . . . . . 42iii3.4.3 Detecting multivariate outliers graphically with the forward search . . . 434 Some other multivariate functions 474.1 Distributional related functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . 474.1.1 Multivariate standardization . . . . . . . . . . . . . . . . . . . . . . . . . 474.1.2 Generating from a multivariate normal distribution . . . . . . . . . . . . 484.1.3 Kullback-Leibler divergence between two multivariate normal popula-tions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 494.1.4 Generation of covariance matrices . . . . . . . . . . . . . . . . . . . . . . 494.1.5 Multivariate t distribution . . . . . . . . . . . . . . . . . . . . . . . . . . . 504.1.6 Random values generation from a multivariate t distribution . . . . . . 514.1.7 Contour plot of the bivariate normal, t and skew normal distribution . . 524.2 Matrix related functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 544.2.1 Choosing the number of principal components using SVD . . . . . . . . 544.2.2 Condence interval for the percentage of variance retained by the rst components . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 554.2.3 The Helmert matrix . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 574.2.4 A pseudoinverse matrix . . . . . . . . . . . . . . . . . . . . . . . . . . . . 584.2.5 Exponential of a symmetric matrix . . . . . . . . . . . . . . . . . . . . . . 585 Compositional data 605.1 Ternary plot . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 605.2 The spatial median for compositional data . . . . . . . . . . . . . . . . . . . . . . 635.3 The Dirichlet distribution . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 645.3.1 Estimating the parameters of the Dirichlet . . . . . . . . . . . . . . . . . 645.3.2 Symmetric Dirichlet distribution . . . . . . . . . . . . . . . . . . . . . . . 665.3.3 Kullback-Leibler divergence and Bhattacharyya distance between twoDirichlet distributions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 675.4 Contour plot of distributions on S2. . . . . . . . . . . . . . . . . . . . . . . . . . 685.4.1 Contour plot of the Dirichlet distribution . . . . . . . . . . . . . . . . . . 685.4.2 Log-ratio transformations . . . . . . . . . . . . . . . . . . . . . . . . . . . 705.4.3 Contour plot of the normal distribution in S2. . . . . . . . . . . . . . . . 715.4.4 Contour plot of the multivariate t distribution in S2. . . . . . . . . . . . 725.4.5 Contour plot of the skew-normal distribution in S2. . . . . . . . . . . . 745.5 Regression for compositional data . . . . . . . . . . . . . . . . . . . . . . . . . . 765.5.1 Regression using the additive log-ratio transformation . . . . . . . . . . 765.5.2 Dirichlet regression . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 785.5.3 OLS regression for compositional data . . . . . . . . . . . . . . . . . . . . 80iv6 Directional data 826.1 Circular statistics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 826.1.1 Summary statistics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 826.1.2 Circular-circular correlation I . . . . . . . . . . . . . . . . . . . . . . . . . 846.1.3 Circular-circular correlation II . . . . . . . . . . . . . . . . . . . . . . . . . 856.1.4 Circular-linear correlation . . . . . . . . . . . . . . . . . . . . . . . . . . . 866.1.5 Regression for circular or angular data using the von Mises distribution 866.1.6 Projected bivariate normal for circular

Search related