Lecture 15

We demonstrated how to draw a probability plot of the generalized distances against a Chi-Square distribution using the bone density data below. We discussed tests of equal variances and covariances using the lizard data below.

An example of a macro for determining generalized distances for plotting a Chi-Square probability plot for assessing multivariate normality follows:

GMacro 
GeneralizedDistances


# First, make a column of means of the variables
# by putting them into separate rows and then transposing the rows into a column
Statistics '<>Dradius'-'<>ulna';
Mean c20-c25.
Transpose  c20-c25;
STORE c27.

#Clean up the worksheet
Erase c20-c25.
Name c20 "means".
Let c20 = c27
Erase c26-c27.

# Second, make a column of data for each individual

Transpose '<>Dradius'-'<>ulna';
STORE c21-c44.

# Third, store the variance-covariance matrix
Name m1 "COVARIANCE"
Covariance '<>Dradius'-'<>ulna' 'COVARIANCE'.

# Fourth, Invert the variance-covariance matrix
name m2 "Inverse"
Inverse 'COVARIANCE' 'INVERSE'.

#Fifth, copy each column of data for each individual into a matrix
#subtract the mean and calculate its generalized distance:

Name m3 "data"
Name m4 "dataT"
Name k2 'answer'
Name c45 "distances"

DO k1 = 21:44
copy ck1 'data'
subtract 'means' 'data' 'data'
Transpose 'data' 'dataT' 
Multiply 'dataT' 'Inverse' M6
Multiply M6 'data' 'answer'
let k3 = k1 - 20
let 'distances'(k3) = 'answer'

ENDDO

#sort distances in place

Sort 'distances' 'distances';
By 'distances'.

# form a column of probability ranks
Let k1 = N('distances')
Name c46 "Ranks"
Set 'Ranks'
1( 1 : k1 / 1 )1
End.
Let 'Ranks' = ('Ranks' - .5)/k1

# Find the chisquare for each probability.
# Since there are 6 responses, we have 6 d.f. for the distribution

Name C47 "ChiSq"
InvCDF 'Ranks' 'ChiSq';
ChiSquare 6.

#plot
Fitline 'ChiSq' 'distances';
Confidence 95.0.
 

EndMacro

These examples are taken from Johnson and Wichern: Applied Multivariate Statistical Analysis. The first set of data consists of measurements of body size in male and female Cophosaurus texanus lizards. The data were provided by Kevin E, Bonine. The second set of data consists of bone mineral content before and after treatment for bone loss and were provided by Everett Smith.

Sex	weight(grams)	Snout-Vent-Length(mm)	Hind-Limb-Span(mm)
f	5.526	59.0	111.5
m	10.401	75.0	142.0
f	9.213	69.0	124.0
f	8.953	67.5	125.0
m	7.063	62.0	129.5
f	6.610	62.0	123.0
m	11.273	74.0	140.0
f	2.445	47.0	97.0
m	15.493	86.5	162.0
f	9.004	69.0	126.5
m	8.199	70.5	136.0
f	6.601	64.5	116.0
m	7.622	67.5	135.0
m	10.067	73.0	136.5
m	10.091	73.0	135.5
m	10.888	77.0	139.0
f	7.610	61.5	118.0
m	7.733	66.5	133.5
m	12.015	79.5	150.0
m	10.049	74.0	137.0
f	5.149	59.5	116.0
f	9.158	68.0	123.0
m	12.132	75.0	141.0
f	6.978	66.5	117.0
f	6.890	63.0	117.0
subject	Dradius	radius	Dhumerus	humerus	Dulna	ulna	1yrDradius	1yrradius	1yrDhumerus	1yrhumerus	1yrDulna	1yrulna	DR	r	Dh	h	DU	u
1	1.103	1.052	2.139	2.238	0.873	0.872	1.027	1.051	2.268	2.246	0.869	0.964	-0.076	-0.001	0.129	0.008	-0.004	0.092
2	0.842	0.859	1.873	1.741	0.590	0.744	0.857	0.817	1.718	1.710	0.602	0.689	0.015	-0.042	-0.155	-0.031	0.012	-0.055
3	0.925	0.873	1.887	1.809	0.767	0.713	0.875	0.880	1.953	1.756	0.765	0.738	-0.050	0.007	0.066	-0.053	-0.002	0.025
4	0.857	0.744	1.739	1.547	0.706	0.674	0.873	0.698	1.668	1.443	0.761	0.698	0.016	-0.046	-0.071	-0.104	0.055	0.024
5	0.795	0.809	1.734	1.715	0.549	0.654	0.811	0.813	1.643	1.661	0.551	0.619	0.016	0.004	-0.091	-0.054	0.002	-0.035
6	0.787	0.779	1.509	1.474	0.782	0.571	0.640	0.734	1.396	1.378	0.753	0.515	-0.147	-0.045	-0.113	-0.096	-0.029	-0.056
7	0.933	0.880	1.695	1.656	0.737	0.803	0.947	0.865	1.851	1.686	0.708	0.787	0.014	-0.015	0.156	0.030	-0.029	-0.016
8	0.799	0.851	1.740	1.777	0.618	0.682	0.886	0.806	1.742	1.815	0.687	0.715	0.087	-0.045	0.002	0.038	0.069	0.033
9	0.945	0.876	1.811	1.759	0.853	0.777	0.991	0.923	1.931	1.776	0.844	0.656	0.046	0.047	0.120	0.017	-0.009	-0.121
10	0.921	0.906	1.954	2.009	0.823	0.765	0.977	0.925	1.933	2.106	0.869	0.789	0.056	0.019	-0.021	0.097	0.046	0.024
11	0.792	0.825	1.624	1.657	0.686	0.668	0.825	0.826	1.609	1.651	0.654	0.726	0.033	0.001	-0.015	-0.006	-0.032	0.058
12	0.815	0.751	2.204	1.846	0.678	0.546	0.851	0.765	2.352	1.980	0.692	0.526	0.036	0.014	0.148	0.134	0.014	-0.020
13	0.755	0.724	1.508	1.458	0.662	0.595	0.770	0.730	1.470	1.420	0.670	0.580	0.015	0.006	-0.038	-0.038	0.008	-0.015
14	0.880	0.866	1.786	1.811	0.810	0.819	0.912	0.875	1.846	1.809	0.823	0.773	0.032	0.009	0.060	-0.002	0.013	-0.046
15	0.900	0.838	1.902	1.606	0.723	0.677	0.905	0.826	1.842	1.579	0.746	0.729	0.005	-0.012	-0.060	-0.027	0.023	0.052
16	0.764	0.757	1.743	1.794	0.586	0.541	0.756	0.727	1.747	1.860	0.656	0.506	-0.008	-0.030	0.004	0.066	0.070	-0.035
17	0.733	0.748	1.863	1.869	0.672	0.752	0.765	0.764	1.923	1.941	0.693	0.740	0.032	0.016	0.060	0.072	0.021	-0.012
18	0.932	0.898	2.028	2.032	0.836	0.805	0.932	0.914	2.190	1.997	0.883	0.785	0.000	0.016	0.162	-0.035	0.047	-0.020
19	0.856	0.786	1.390	1.324	0.578	0.610	0.843	0.782	1.242	1.228	0.577	0.627	-0.013	-0.004	-0.148	-0.096	-0.001	0.017
20	0.890	0.950	2.187	2.087	0.758	0.718	0.879	0.906	2.164	1.999	0.802	0.769	-0.011	-0.044	-0.023	-0.088	0.044	0.051
21	0.688	0.532	1.650	1.378	0.533	0.482	0.673	0.537	1.573	1.330	0.540	0.498	-0.015	0.005	-0.077	-0.048	0.007	0.016
22	0.940	0.850	2.334	2.225	0.757	0.731	0.949	0.900	2.130	2.159	0.804	0.779	0.009	0.050	-0.204	-0.066	0.047	0.048
23	0.493	0.616	1.037	1.268	0.546	0.615	0.463	0.637	1.041	1.265	0.570	0.634	-0.030	0.021	0.004	-0.003	0.024	0.019
24	0.835	0.752	1.509	1.422	0.618	0.664	0.776	0.743	1.442	1.411	0.585	0.640	-0.059	-0.009	-0.067	-0.011	-0.033	-0.024
25	0.915	0.936	1.971	1.869	0.869	0.868	*	*	*	*	*	*	*	*	*	*	*	*