Linear Discriminant Function in MANOVA
*************************************************************;
* discfunc.sas -- Study of the discriminant function. *;
*************************************************************;
Options PS=55 LS=90 PageNo=1 NoDate
FORMCHAR='|----|+|---+=|-/\<>*';
GOptions
CText=Black HText=1 FText=SwissX
CTitle=Black HTitle=1 FTitle=SwissX
CBack=White Colors=(Black) NoPrompt;
Title1 'Table 5.7 -- Bird Data of Female Hook-billed Kites';
Data Fkites;
retain sex "F";
input x1 x2 @@;
obs+1;
label x1='Tail Length'
x2='Wing Length';
Datalines;
191 284 186 266 173 271 197 285 197 285 194 280
208 288 201 295 198 300 180 273 190 282 180 272
180 275 209 305 190 292 188 280 187 285 191 286
210 283 207 297 196 285 196 288 178 268 207 286
191 271 202 271 209 303 179 257 205 285 179 261
208 289 190 280 186 262 202 285 189 277 174 245
200 272 211 310 181 250 192 282 216 305 189 262
199 280 189 274 188 258
;
Title1 'Table 6.7 -- Bird Data of Male Hook-billed Kites';
Data Mkites;
retain sex "M";
input x1 x2 @@;
obs+1;
label x1='Tail Length'
x2='Wing Length';
Datalines;
180 278 185 282 184 277 186 277 195 285 176 281
206 308 183 276 185 287 184 290 202 308 191 295
177 273 177 254 177 267 177 284 177 268 197 310
176 267 170 260 199 299 200 281 186 274 190 273
191 287 177 272 180 278 193 271 178 266 189 280
212 302 192 281 194 290 181 254 204 276 186 287
195 297 191 290 191 286 187 281 178 265 187 288
190 284 177 275 186 275
;
Title1 'Tables 5.7 and 6.7 -- Hook-billed Kite Data';
Data ALLkites;
Set Fkites Mkites;
Run;
*************************************************************;
* Construct a Bivariate Scatter Plot of the Data *;
*************************************************************;
Proc GPlot Data=ALLkites;
Plot x1*x2=sex;
Symbol1 C=Black V=Dot H=1 I=None;
Symbol2 C=Black V=Circle H=1 I=None;
Run;
*************************************************************;
* Use GLM to find the discriminant function *;
*************************************************************;
Title2 'MANOVA';
Proc GLM Data=ALLkites;
Class sex;
Model x1 x2 = sex;
Output out=errors r=e1 e2;
Manova H=sex / PrintE PrintH;
Run; Quit;
*************************************************************;
* Using the coefficients produced by GLM, construct the *;
* discriminant function linear combination. *;
*************************************************************;
Title2 "Study Discriminant Function";
Data Two;
Set Allkites;
Discrim=-0.01585641*X1+0.00941385*X2;
Run;
*************************************************************;
* Sort and print the data ordered by the discriminant *;
* function. *;
*************************************************************;
Proc Sort Data=Two;
By discrim;
Run;
Title3 "Observations Ordered Along Discriminant Function";
Proc Print Data=Two;
Var discrim sex x1 x2;
Id obs;
Run;
*************************************************************;
* Use SAS/INSIGHT to compare the data according to the *;
* various functions. *;
*************************************************************;
Proc Insight File;
OPEN WORK.TWO;
BAR X1 X2 DISCRIM SEX;
BOX X1 DISCRIM X2 * SEX;
Run;
Tables 5.7 and 6.7 -- Hook-billed Kite Data 1
MANOVA
General Linear Models Procedure
Class Level Information
Class Levels Values
SEX 2 F M
Number of observations in data set = 90
Tables 5.7 and 6.7 -- Hook-billed Kite Data 2
MANOVA
General Linear Models Procedure
Dependent Variable: X1 Tail Length
Source DF Sum of Squares Mean Square F Value Pr > F
Model 1 960.40000000 960.40000000 9.27 0.0031
Error 88 9120.22222222 103.63888889
Corrected Total 89 10080.62222222
R-Square C.V. Root MSE X1 Mean
0.095272 5.348054 10.18031870 190.35555556
Source DF Type I SS Mean Square F Value Pr > F
SEX 1 960.40000000 960.40000000 9.27 0.0031
Source DF Type III SS Mean Square F Value Pr > F
SEX 1 960.40000000 960.40000000 9.27 0.0031
Tables 5.7 and 6.7 -- Hook-billed Kite Data 3
MANOVA
General Linear Models Procedure
Dependent Variable: X2 Wing Length
Source DF Sum of Squares Mean Square F Value Pr > F
Model 1 26.67777778 26.67777778 0.14 0.7080
Error 88 16622.97777778 188.89747475
Corrected Total 89 16649.65555556
R-Square C.V. Root MSE X2 Mean
0.001602 4.902928 13.74399777 280.32222222
Source DF Type I SS Mean Square F Value Pr > F
SEX 1 26.67777778 26.67777778 0.14 0.7080
Source DF Type III SS Mean Square F Value Pr > F
SEX 1 26.67777778 26.67777778 0.14 0.7080
E = Error SS&CP Matrix
X1 X2
X1 9120.2222222 9265.7555556
X2 9265.7555556 16622.977778
Tables 5.7 and 6.7 -- Hook-billed Kite Data 4
MANOVA
General Linear Models Procedure
Multivariate Analysis of Variance
Partial Correlation Coefficients from the Error SS&CP Matrix / Prob > |r|
DF = 88 X1 X2
X1 1.000000 0.752530
0.0001 0.0001
X2 0.752530 1.000000
0.0001 0.0001
Tables 5.7 and 6.7 -- Hook-billed Kite Data 5
MANOVA
General Linear Models Procedure
Multivariate Analysis of Variance
H = Type III SS&CP Matrix for SEX
X1 X2
X1 960.4 -160.0666667
X2 -160.0666667 26.677777778
Characteristic Roots and Vectors of: E Inverse * H, where
H = Type III SS&CP Matrix for SEX E = Error SS&CP Matrix
Characteristic Percent Characteristic Vector V'EV=1
Root
X1 X2
0.29161967 100.00 -0.01585641 0.00941385
0.00000000 0.00 0.00117955 0.00707728
Manova Test Criteria and Exact F Statistics for the Hypothesis of no Overall SEX Effect
H = Type III SS&CP Matrix for SEX E = Error SS&CP Matrix
S=1 M=0 N=42.5
Statistic Value F Num DF Den DF Pr > F
Wilks' Lambda 0.77422172 12.6855 2 87 0.0001
Pillai's Trace 0.22577828 12.6855 2 87 0.0001
Hotelling-Lawley Trace 0.29161967 12.6855 2 87 0.0001
Roy's Greatest Root 0.29161967 12.6855 2 87 0.0001
Tables 5.7 and 6.7 -- Hook-billed Kite Data 6
Study Discriminant Function
Observations Ordered Along Discriminant Function
OBS DISCRIM SEX X1 X2
19 -0.66573 F 210 283
26 -0.65184 F 202 271
35 -0.63649 M 204 276
37 -0.61071 F 200 272
24 -0.58992 F 207 286
7 -0.58694 F 208 288
31 -0.57753 F 208 289
29 -0.56762 F 205 285
41 -0.55376 F 216 305
45 -0.55223 F 188 258
42 -0.53043 F 189 262
22 -0.52599 M 200 281
34 -0.52005 F 202 285
43 -0.51955 F 199 280
31 -0.51858 M 212 302
39 -0.51655 F 181 250
28 -0.50913 M 193 271
20 -0.48636 F 207 297
33 -0.48286 F 186 262
34 -0.47889 M 181 254
25 -0.47742 F 191 271
27 -0.46159 F 209 303
36 -0.45262 F 174 245
2 -0.44521 F 186 266
14 -0.44277 F 209 305
24 -0.44274 M 190 273
4 -0.44077 F 197 285
5 -0.44077 F 197 285
6 -0.44027 F 194 280
38 -0.42741 F 211 310
21 -0.42491 F 196 285
28 -0.41894 F 179 257
44 -0.41747 F 189 274
14 -0.41547 M 177 254
8 -0.41005 F 201 295
5 -0.40905 M 195 285
32 -0.39914 M 192 281
22 -0.39667 F 196 288
40 -0.38973 F 192 282
35 -0.38923 F 189 277
30 -0.38128 F 179 261
32 -0.37684 F 190 280
23 -0.36990 M 186 274
7 -0.36695 M 206 308
30 -0.36098 M 189 280
45 -0.36048 M 186 275
11 -0.35801 F 190 282
1 -0.35504 F 191 284
33 -0.34613 M 194 290
Tables 5.7 and 6.7 -- Hook-billed Kite Data 7
Study Discriminant Function
Observations Ordered Along Discriminant Function
OBS DISCRIM SEX X1 X2
16 -0.34513 F 188 280
4 -0.34166 M 186 277
21 -0.34068 M 199 299
43 -0.33918 M 190 284
18 -0.33621 F 191 286
39 -0.33621 M 191 286
41 -0.32777 M 178 265
25 -0.32680 M 191 287
40 -0.31986 M 187 281
29 -0.31836 M 178 266
9 -0.31541 F 198 300
3 -0.30994 M 184 277
11 -0.30353 M 202 308
8 -0.30350 M 183 276
23 -0.29953 F 178 268
38 -0.29856 M 191 290
37 -0.29609 M 195 297
12 -0.29359 F 180 272
15 -0.29309 M 177 267
10 -0.28417 F 180 273
17 -0.28367 M 177 268
17 -0.28220 F 187 285
2 -0.27873 M 185 282
19 -0.27723 M 176 267
13 -0.26535 F 180 275
15 -0.26387 F 190 292
42 -0.25396 M 187 288
12 -0.25149 M 191 295
20 -0.24799 M 170 260
36 -0.24752 M 186 287
26 -0.24602 M 177 272
1 -0.23710 M 180 278
27 -0.23710 M 180 278
13 -0.23660 M 177 273
9 -0.23166 M 185 287
44 -0.21778 M 177 275
18 -0.20542 M 197 310
3 -0.19201 F 173 271
10 -0.18756 M 184 290
6 -0.14544 M 176 281
16 -0.13305 M 177 284
Tables 5.7 and 6.7 -- Hook-billed Kite Data
Study Discriminant Function
Female Observations are Highlighted
Tables 5.7 and 6.7 -- Hook-billed Kite Data
Study Discriminant Function
Male Observations are Highlighted
Tables 5.7 and 6.7 -- Hook-billed Kite Data
Study Discriminant Function
Side-by-side Box Plots