Ana səhifə

# Two-Sample Multivariate Tests

Yüklə 24.26 Kb.
 tarix 27.06.2016 ölçüsü 24.26 Kb.
 Two-Sample Multivariate Tests Mahon & Campbell (1974) recorded data on 200 specimens of Leptograpsus variegatus crabs on the shore of Western Australia. This occurs in two color forms, blue and orange, and they collected 50 of each form and sex. The measurements were: carapace (shell) length CL, carapace width CW, the size the frontal lobe FL, rear width RW, and body depth BD. Assess the multivariate normality of the data contained in the data frame Crabs.  The species is contained in the data set. Be sure to take into consideration the fact that there are two species and two sexes of crabs present in these data. We will perform tests to contrast the differences between male and female crabs within species, and also contrast the differences between orange and blue crabs within sex. We first will form two subsets of the original data. One subset will contain the data on the blue crabs and theother will contain the data on orange crabs. > attach(Crabs) > Blue.Crabs <- Crabs[sp=="B",] > Orange.Crabs <- Crabs[sp=="O",] > names(Blue.Crabs) [1] "cgrp" "sex" "sp" "FL" "RW" "CL" "CW" "BD" > Blue.Crabs <- Blue.Crabs[,-c(1,3)]  # Remove columns for crab group and species > Orange.Crabs<- Orange.Crabs[,-c(1,3)] # Remove columns for crab group and species > detach("Crabs") > attach(Blue.Crabs) > BC.mat <- Blue.Crabs[,2:6] # Extract the columns containing measurements > BC.mat[1:4,]    FL  RW   CL   CW  BD 1 8.1 6.7 16.1 19.0 7.0 2 8.8 7.7 18.1 20.8 7.4 3 9.2 7.8 19.0 22.4 7.7 4 9.6 7.9 20.1 23.1 8.2 > MVttest2(BC.mat,sex,pv=T,box=T,lcp=T) Perform two-sample T2 test. The required arguments to the function are the data matrix and the variable used to classify the two groups. In this case BC.mat contains the measurements and sex contains and indicator for the sex of the crab (F = female, M = male). The other options are not required. Setting pv = T indicates that you wish the two sample variance covariance matrices to be printed (default = F). Setting box = T creates comparative boxplots for each of the variables (default = F). Setting lcp = T plots the values of the maximizing linear combination for both groups (default = F). Look for a great deal of separation between the linear combination scores when the null hypothesis is rejected. Output from MVttest2 function (Blue Crabs) Difference in mean vectors ==================================================================    FL    RW    CL    CW     BD 1.572 -0.42 3.912 4.186 1.534 =========================================== S1 ( M ) ======================================================================       FL   RW    CL     CW    BD FL 10.26 6.54 23.30  26.61 10.17 RW  6.54 4.46 15.08  17.26  6.55 CL 23.30 15.08 53.42 60.98 23.24 CW 26.61 17.26 60.98 69.78 26.59 BD 10.17  6.55 23.24 26.59 10.24   S2 ( F ) ======================================================================      FL   RW    CL    CW     BD FL 6.91 6.28 15.47  17.80  7.10 RW 6.28 5.95 14.25  16.39  6.56 CL 15.47 14.25 35.04 40.21 16.14 CW 17.80 16.39 40.21 46.29 18.53 BD  7.10  6.56 16.14 18.53  7.58 Test for Equality of Means ======================================================================= Hotelling's T2 = 241.969 Critical Value = 12.048 p-value= 0 The linear combination most responsible for rejection of the null hypothesis lin.comb FL -2.785 RW -5.205 CL 2.822 CW 0.401 BD -0.552 95% Simultaneous C.I. for Mean Differences (T^2) ===========================================================          LCL       UCL FL -0.4615290 3.605529 RW -2.0035212 1.163521 CL -0.7048465 8.528846 CW -1.1025639 9.474564 BD -0.5379137 3.605914   95% Simultaneous C.I. for Mean Differences (Bonferroni) =========================================================== FL  0.03299663 3.1110034 RW -1.61843114 0.7784311 CL  0.41790554 7.4060945 CW  0.18354035 8.1884597 BD -0.03405348 3.1020535 Graphs for Selected Options (Blue Crabs) Comparative Boxplots for Each Variable Now consider the similar tests for the orange crabs. > detach("Blue.Crabs") > attach(Orange.Crabs) > OC.mat <- Orange.crabs[,2:6] > Mvttest2(OC.mat,sex,pv=T,box=T,lcp=T) Output from MVttest2 function (Orange Crabs) Difference in mean vectors ==================================================================    FL     RW    CL      CW     BD -0.968 -2.574 -0.93 -1.848 -0.308 Sample Variance-Covariance Matrices ======================================= S1 ( M ) ===================================================================       FL   RW    CL    CW    BD FL 12.36 7.60 26.62 29.31  12.32 RW  7.60 4.82 16.53  18.23  7.65 CL 26.62 16.53 57.93 63.77 26.76 CW 29.31 18.23 63.77 70.35 29.49 BD 12.32  7.65 26.76 29.49 12.44   S2 ( F ) ===================================================================      FL   RW    CL    CW    BD FL  8.84 6.73 17.17 19.25  8.01 RW  6.73 5.52 13.40 15.05  6.21 CL 17.17 13.40 34.07 38.08 15.91 CW 19.25 15.05 38.08 42.80 17.76 BD  8.01  6.21 15.91 17.76 7.58   Test for Equality of Means =============================================================== Hotelling's T2 = 447.033 Critical Value = 12.048 p-value= 0   The linear combination most responsible for rejection of the null hypothesis lin.comb FL -1.121 RW -7.121 CL 3.968 CW -1.258 BD 0.550 95% Simultaneous C.I. for Mean Differences (T^2) =========================================================== FL -3.228160 1.2921598 RW -4.152142 -0.9958583 CL -5.638423 3.7784227 CW -7.069558 3.3735580 BD -2.504263 1.8882631   95% Simultaneous C.I. for Mean Differences (Bonf) ===========================================================          LCL        UCL FL -2.678521 0.7425208 RW -3.768360 -1.3796401 CL -4.493401 2.6334006 CW -5.799749 2.1037486 BD -1.970163 1.3541629 Graphs from Selected Options (Orange Crabs) Comparative Boxplots for each Variable We now consider testing differences between species within a given sex. To do this we again first form subsets of our data, this time corresponding to sex. > detach("Orange.Crabs") > attach(Crabs) > Male.Crabs <- Crabs[sex=="M",] > Female.Crabs <- Crabs[sex=="F",] > detach("Crabs") > attach(Male.Crabs) > MC.mat <- Male.Crabs[,4:8] > MVttest2(MC.mat,sp,pv=T,box=T,lcp=T) Output from MVttest2 (Male Crabs) Difference in mean vectors ==================================================================    FL     RW      CL     CW     BD -1.784 -0.544 -1.674 -0.378 -1.974 Sample Variance-Covariance Matrices =========================================== S1 ( B ) ======================================================================       FL   RW    CL    CW    BD FL 10.26 6.54 23.30 26.61 10.17 RW  6.54 4.46 15.08 17.26  6.55 CL 23.30 15.08 53.42 60.98 23.24 CW 26.61 17.26 60.98 69.78 26.59 BD 10.17 6.55 23.24 26.59 10.24   S2 ( O ) ======================================================================       FL   RW    CL     CW    BD FL 12.36 7.60 26.62 29.31  12.32 RW 7.60  4.82 16.53 18.23   7.65 CL 26.62 16.53 57.93 63.77 26.76 CW 29.31 18.23 63.77 70.35 29.49 BD 12.32 7.65 26.76 29.49  12.44 Test for Equality of Means =============================================================== Hotelling's T2 = 916.162 Critical Value = 12.048 p-value= 0 The linear combination most responsible for rejection of the null hypothesis lin.comb FL -5.408 RW -3.766 CL -3.762 CW 11.087 BD -11.573   95% Simultaneous C.I. for Mean Differences (T^2) ===========================================================          LCL       UCL FL -4.118179 0.5501790 RW -2.039355 0.9513555 CL -6.853814 3.5058136 CW -6.188841 5.4328413 BD -4.311756 0.3637559   95% Simultaneous C.I. for Mean Differences (Bonf) ===========================================================          LCL         UCL FL -3.550540 -0.01746044 RW -1.675706  0.58770610 CL -5.594156  2.24615589 CW -4.775727  4.01972655 BD -3.743247 -0.20475340 Output for Selected Options (Male Crabs) Repeat for female crabs. > detach("Male.Crabs") > attach(Female.Crabs) > FC.mat <- Female.Crabs[,4:8] > MVttest2(FC.mat,spec,pv=T,box=T,lcp=T) Output and graphs not shown.

Verilənlər bazası müəlliflik hüququ ilə müdafiə olunur ©atelim.com 2016
rəhbərliyinə müraciət