26
Discriminant Analysis and Classification

Discriminant Analysis and Classification. Discriminant Analysis as a Type of MANOVA The good news about DA is that it is a lot like MANOVA; in fact

Embed Size (px)

Citation preview

Page 1: Discriminant Analysis and Classification. Discriminant Analysis as a Type of MANOVA  The good news about DA is that it is a lot like MANOVA; in fact

Discriminant Analysis and Classification

Page 2: Discriminant Analysis and Classification. Discriminant Analysis as a Type of MANOVA  The good news about DA is that it is a lot like MANOVA; in fact

Discriminant Analysis as a Type of MANOVA The good news about DA is that it is a lot like MANOVA;

in fact in the case of a factor with only two levels it is the same thing Has the same assumptions as MANOVA; multivariate

normality, independence of cases, homogeneity of group covariances

DA permits a multivariate analysis of variance hypothesis of the test that two or more groups (conditions, levels) differ significantly on a linear combination of discriminating variables. Another way to put this is: how well can the levels of the grouping variable be discriminated by scores on the discriminating variables? In general it’s good to use naturally occurring groups

that are mutually exclusive groups that are exhaustive of the domain, rather than median splits or arbitrary divisions

Page 3: Discriminant Analysis and Classification. Discriminant Analysis as a Type of MANOVA  The good news about DA is that it is a lot like MANOVA; in fact

Discriminant Analysis as a Type of MANOVA, cont’d In the case where there are more than two

groups, DA permits you to test the hypothesis that there is more than one significant way of describing how the groups differ on a weighted linear combination of the discriminating variables, and you can think of these combinations, called canonical variables, as “dimensions” of difference. These variables will be uncorrelated with each other

This way of using DA is called descriptive discriminant analysis

Page 4: Discriminant Analysis and Classification. Discriminant Analysis as a Type of MANOVA  The good news about DA is that it is a lot like MANOVA; in fact

Discriminant Analysis as Part of a System for Classifying Cases Usually discriminant analysis is presented conceptually

in an upside down sort of way, where what you would traditionally think of as dependent variables are actually the predictor variables, and group membership rather than being the levels of the IV are groups whose membership is being predicted When it is used in this way, the hypothesis you are

testing is that there is a linear combination of variables which when appropriately weighted (like beta weights) will maximally discriminate between members of two or more groups and permit new cases to be classified into the groups

In this mode, called predictive discriminant analysis, DA is used to develop a classification rule that will permit things like classifying people as potential Republican voters or not, or to predict their future status as able to complete four years of college or not, or to be able to pay their car loan

Page 5: Discriminant Analysis and Classification. Discriminant Analysis as a Type of MANOVA  The good news about DA is that it is a lot like MANOVA; in fact

Discriminant Analysis as Part of a System for Classifying Cases, con’td

Discriminant analysis is part of the general linear model and combines some of the features familiar to you from multiple regression and some from MANOVA. It’s basically multiple regression where the criterion variable is nominal rather than interval/ratio level

When DA is used in this predictive way it is usually followed up by classification procedures to classify new cases based on the obtained discriminant function(s)

Page 6: Discriminant Analysis and Classification. Discriminant Analysis as a Type of MANOVA  The good news about DA is that it is a lot like MANOVA; in fact

Discriminant Analysis and MANOVA

Let’s work through an example of discriminant analysis, and show how it can approach a question from two sides: testing a MANOVA hypothesis and predicting group membership

First let’s consider the hypothesis that a nation’s level of concentration of wealth (in the hands of a few, more widely distributed, or somewhere in between) has a significant impact on four dependent variables: human development score, political rights score, the gini (inequality) index, and civil liberties score

Page 7: Discriminant Analysis and Classification. Discriminant Analysis as a Type of MANOVA  The good news about DA is that it is a lot like MANOVA; in fact

Discriminant Analysis and MANOVA, cont’d

Note. In creating these three wealth concentration “groups” out of interval level data I am not advocating this practice but only creating “groups” for purposes of illustration. Naturally occurring, clearly separated groups, e.g., males and females, people who survived after five years of diagnosis and people who didn’t) are preferred for the grouping variable

This sounds like a hypothesis that could be tested with MANOVA, and it is, but it can also be tested with discriminant analysis

First let’s look at what MANOVA will tell us about this hypothesis

Page 8: Discriminant Analysis and Classification. Discriminant Analysis as a Type of MANOVA  The good news about DA is that it is a lot like MANOVA; in fact

MANOVA test of the Hypothesis

Multivariate Testsd

.980 467.961b 4.000 39.000 .000 .980 1871.844 1.000

.020 467.961b 4.000 39.000 .000 .980 1871.844 1.000

47.996 467.961b 4.000 39.000 .000 .980 1871.844 1.000

47.996 467.961b 4.000 39.000 .000 .980 1871.844 1.000

.880 7.857 8.000 80.000 .000 .440 62.852 1.000

.205 11.793b 8.000 78.000 .000 .547 94.344 1.000

3.468 16.473 8.000 76.000 .000 .634 131.787 1.000

3.344 33.443c 4.000 40.000 .000 .770 133.772 1.000

Pillai's Trace

Wilks' Lambda

Hotelling's Trace

Roy's Largest Root

Pillai's Trace

Wilks' Lambda

Hotelling's Trace

Roy's Largest Root

EffectIntercept

WCONCENT

Value F Hypothesis df Error df Sig.Partial EtaSquared

Noncent.Parameter

ObservedPower

a

Computed using alpha = .05a.

Exact statisticb.

The statistic is an upper bound on F that yields a lower bound on the significance level.c.

Design: Intercept+WCONCENTd.

Here we see that the hypothesis is confirmed: Country’s wealth concentration has a significant main effect on the set of four indicators

Page 9: Discriminant Analysis and Classification. Discriminant Analysis as a Type of MANOVA  The good news about DA is that it is a lot like MANOVA; in fact

Univariate F Tests of the Four Variables

As you can note from the output, the univariate F tests for each of the four variables are all significant at p < .001. But what this output doesn’t tell us is what sort of combination of these four variables the countries differ on, or if there is more than one combination on which they are significantly different

Page 10: Discriminant Analysis and Classification. Discriminant Analysis as a Type of MANOVA  The good news about DA is that it is a lot like MANOVA; in fact

More than MANOVA: Additional Information from Discriminant Analysis Here is some of the additional information we can get from a

discriminant analysis to help us understand the relationship between a country’s concentration of wealth and the four variables DA transforms the original variables into one or more new

variables, called canonical variables, that combine the four separate variables, appropriately weighted, into a new, single index which maximally discriminates between the countries in terms of concentration of wealth. That is, the procedure looks for a set of weights (the discriminant function) to apply to the discriminating variables that produces as much separation as possible among the levels of the grouping variable

In the case of more than two levels of the grouping variable (for instance, concentration of wealth), there may be one or more additional ways of weighting and combining the variables (resulting in one or more canonical variables) that will maximize how the groups differ

Page 11: Discriminant Analysis and Classification. Discriminant Analysis as a Type of MANOVA  The good news about DA is that it is a lot like MANOVA; in fact

Number of Functions Extracted in DA

Eigenvalues

3.344a 96.4 96.4 .877

.124a 3.6 100.0 .332

Function1

2

Eigenvalue % of Variance Cumulative %CanonicalCorrelation

First 2 canonical discriminant functions were used in theanalysis.

a.

Wilks' Lambda

.205 64.215 8 .000

.890 4.726 3 .193

Test of Function(s)1 through 2

2

Wilks'Lambda Chi-square df Sig.

The discriminant analysis procedure “extracts” a maximum of m (number of discriminating variables) or k-1 underlying dimensions or canonical discriminant functions (whichever is smaller), where k is the number of groups or categories of the nominal level variable. For example, we have three categories of country’s wealth concentration, so two of these functions are extracted. Think of the idea of a total amount of variation in country’s wealth concentration that you could predict with one or more different combinations of the four variables (gini index, civil liberties score, etc) as 100%. The first new canonical variable (weighted combination of the four) accounts for 96.4 % of it, and the second canonical variable for the remaining 3.6 %. Combining these two improves the prediction

Here’s Wilks’ lambda again. Combining both discriminant functions allows you to predict all but .205 of the variation in level of wealth concentration

Of the variance explained in wealth concentration, 96.4% was explained by the first function and 3.6% by the second one. Some variance of course remains unexplained.

Page 12: Discriminant Analysis and Classification. Discriminant Analysis as a Type of MANOVA  The good news about DA is that it is a lot like MANOVA; in fact

Statistics Associated with the Two Discriminant Functions

Eigenvalues

3.344a 96.4 96.4 .877

.124a 3.6 100.0 .332

Function1

2

Eigenvalue % of Variance Cumulative %CanonicalCorrelation

First 2 canonical discriminant functions were used in theanalysis.

a.

Wilks' Lambda

.205 64.215 8 .000

.890 4.726 3 .193

Test of Function(s)1 through 2

2

Wilks'Lambda Chi-square df Sig.

Note that associated with each of these two functions is a level of Wilks’ lambda. From the first table, we can see that the Wilks’lambda is big (.89) for just the second canonical discriminant function, and that means that using that combination of weights on the four dependent variables leaves about 89% of the variance in country’s wealth concentration unexplained. But when you add the first function to the predictive equation, you reduce the unexplained variance to only about 20% (.205). The second function isn’t significant, but the combination of the two is. This value of Wilks’ lambda is the onethat is tested for significance in the overall test in MANOVA (see slide 5)

Two other values that you see in the output are the eigenvalue and the canonical correlation. The eigenvalue is a value that can be interpreted as the variance of its respective discriminant function and the canonical correlation is the correlation between the new canonical variables formed by applying the weights from the discriminant function to the four predictors, and levels of wealth concentration

Page 13: Discriminant Analysis and Classification. Discriminant Analysis as a Type of MANOVA  The good news about DA is that it is a lot like MANOVA; in fact

Standardized and Unstandardized Canonical Discriminant Function Coefficients

Standardized Canonical Discriminant Function Coefficients

-.203 .689

-.528 -.437

.033 .641

.884 .482

human devel score:hi=more

Political rights score

Civil liberties score

Gini index:0=perfect $equality,100=perfectinequality

1 2

Function

Canonical Discriminant Function Coefficients

-1.240 4.207

-.366 -.303

.027 .535

.126 .069

-2.384 -7.167

human devel score:hi=more

Political rights score

Civil liberties score

Gini index:0=perfect $equality,100=perfectinequality

(Constant)

1 2

Function

Unstandardized coefficients

The standardized and unstandarized canonical discriminant function coefficients are like the b and the β weights in multiple regression. The ones on the right, with a constant, are like the beta weights and the intercept that you use with raw scores to classify new cases as to country’s wealth concentration. The ones on the left are the standardized coefficients, which means the variables are all measured on the same scale, and the weights can be compared to determine the relative importance of each of the variables to explaining “group separation” (differences in level of wealth concentration)

Page 14: Discriminant Analysis and Classification. Discriminant Analysis as a Type of MANOVA  The good news about DA is that it is a lot like MANOVA; in fact

Interpreting the Standardized Discriminant Function Coefficients

Standardized Canonical Discriminant Function Coefficients

-.203 .689

-.528 -.437

.033 .641

.884 .482

human devel score:hi=more

Political rights score

Civil liberties score

Gini index:0=perfect $equality,100=perfectinequality

1 2

Function

These coefficients or weights tell you how the four original variables combine to make a new one that maximally “separates” the countries based on their wealth concentration. You can interpret the standardized discriminant function coefficients as a measure of the relative importance of each of the original predictors. We will only interpret the first function since it explains so much more of the variance in country’s wealth concentration than the second one, and the second function was not significant. Function 1 could be labeled “inequality” since it is defined by the high positive “loading” of the gini index, and the high negative loading of political rights. The human development score and civil liberties score are comparatively unimportant in describing the “separation” among the categories of country’s wealth concentration

These coefficients can be used to classify new cases if the four discriminating variables are expressed in standard (z) scores

Page 15: Discriminant Analysis and Classification. Discriminant Analysis as a Type of MANOVA  The good news about DA is that it is a lot like MANOVA; in fact

Discriminant Functions at the Group Centroids

Functions at Group Centroids

-2.023 .148

-.022 -.792

1.828 .144

Concentration of Wealthin Hands of FewLowWealthConcentr

ModerateWealthConcentr

HighWealthConcentr

1 2

Function

Unstandardized canonical discriminant functionsevaluated at group means

This table shows the group centroids (vector of means) on the two new canonical variables formed by applying the discriminant function weights. Notice how well function 1 separates the low wealth concentration countries from the high wealth countries. You can think of the centroid for each group or level as that group’s average discriminant score on that function (where for raw scores the discriminant score is -2.384 -1.240 human development score -.366 political rights score + .027 civil liberties + .126 gini index). New cases would be classified into groups depending on the group whose centroid their own vector of scores was closest to.

Canonical Discriminant Function Coefficients

-1.240 4.207

-.366 -.303

.027 .535

.126 .069

-2.384 -7.167

human devel score:hi=more

Political rights score

Civil liberties score

Gini index:0=perfect $equality,100=perfectinequality

(Constant)

1 2

Function

Unstandardized coefficients

Page 16: Discriminant Analysis and Classification. Discriminant Analysis as a Type of MANOVA  The good news about DA is that it is a lot like MANOVA; in fact

Territorial Map from Discriminant Analysis This territorial map plots off the

location of cases based on their discriminant scores. Note for example that most of the low wealth concentration cases (the 1’s) are concentrated on the negative end of function 1 (i.e., they are “negative” on “inequality)) and the high wealth concentration cases (the 3’s) are on the positive end (i.e., they are “positive” on inequality), consistent with the location of their group means (centroids) on the function (see arrows)

Functions at Group Centroids

-2.023 .148

-.022 -.792

1.828 .144

Concentration of Wealthin Hands of FewLowWealthConcentr

ModerateWealthConcentr

HighWealthConcentr

1 2

Function

Unstandardized canonical discriminant functionsevaluated at group means

Low wealthconcentration

High

Medium

Page 17: Discriminant Analysis and Classification. Discriminant Analysis as a Type of MANOVA  The good news about DA is that it is a lot like MANOVA; in fact

Quadratic ClassificationOne way of handling the problem of unequal covariances across groups (i.e., you flunked the Box’s M test) is to base the classification not on the combined covariance matrices but on the separate ones (this is an option in SPSS). Notice that you get a bit of a different result.

Low Wealth Concen-tration

High

Medium

Page 18: Discriminant Analysis and Classification. Discriminant Analysis as a Type of MANOVA  The good news about DA is that it is a lot like MANOVA; in fact

Using Classification Results to Evaluate the Discriminant Functions

Classification Resultsa

17 1 0 18

1 4 2 7

0 3 17 20

4 15 9 28

94.4 5.6 .0 100.0

14.3 57.1 28.6 100.0

.0 15.0 85.0 100.0

14.3 53.6 32.1 100.0

Concentration of Wealthin Hands of FewLowWealthConcentr

ModerateWealthConcentr

HighWealthConcentr

Ungrouped cases

LowWealthConcentr

ModerateWealthConcentr

HighWealthConcentr

Ungrouped cases

Count

%

Original

LowWealthConcentr

ModerateWealthConcentr

HighWealthConcentr

Predicted Group Membership

Total

84.4% of original grouped cases correctly classified.a.

Recall that the new canonical variables created by applying the discriminant function weights to the four original variables could be used to classify cases. It’s best to have a “holdout sample” to use to test the new canonical variables as to how well they classify cases that weren’t part of the development or training sample, but we can go back and reclassify the existing cases to see how well we do at using the new canonical variables to classify cases back into the groups they belong to. According to the table above when the discriminant functions were used to “predict” what a country’s level of wealth concentration was from the four variables, 84.4% of the original grouped cases were correctly reclassifed back into their original categories (p(2), the hit rate). You can note that the largest proportion of errors were in reclassifying the middle category (moderate wealth concentration) while the classification was nearly perfect in reclassifying the low wealth concentration countries (only one error)

Page 19: Discriminant Analysis and Classification. Discriminant Analysis as a Type of MANOVA  The good news about DA is that it is a lot like MANOVA; in fact

Classification Rules Decision rules developed from discriminant analysis

can be influenced by knowledge of or expectations about the relative size in the population of the levels of the grouping variable E.g., approximately 5% of the population of

mortgagees will default in a given year, so the “prior probabilities” are 5% for one group and 95% for the non-default group

In cases where these prior probabilities are not known they are often based on the sample sizes for the levels of the grouping variable if the sample is a random sample from the population

Some decision rules treat the prior probabilities as equal across all levels and let the discriminating variables do all the classification work

Page 20: Discriminant Analysis and Classification. Discriminant Analysis as a Type of MANOVA  The good news about DA is that it is a lot like MANOVA; in fact

Classification Rules As mentioned earlier, sometimes a decision

is made in advance to test a discriminant function by holding out a sample and then using the function obtained on the training sample to classify the new cases from the holdout sample

An alternative approach is the “leave-one-out” method which is an option in SPSS under the Classify button Each case is deleted in turn from the training

sample and is classified by means of the classification rule established on the remaining observations

Page 21: Discriminant Analysis and Classification. Discriminant Analysis as a Type of MANOVA  The good news about DA is that it is a lot like MANOVA; in fact

Stepwise Discriminant Analysis Recall that when we talked about regression we learned

about a variation of multiple regression called stepwise in which variables were “entered” into the regression equation based on the strength of their relationship with the criterion variable

You can perform this same sort of stepwise procedure with discriminant analysis. At each step in the analysis the variable which maximizes the overall Wilks’ lambda or some related criterion is entered, and if a variable doesn’t make a significant contribution according to the F to enter and F to remove criteria that you set up it will not be kept in the final equation

Stepwise DA is useful when the number of potential discriminating variables is large and you need to reduce the number

Page 22: Discriminant Analysis and Classification. Discriminant Analysis as a Type of MANOVA  The good news about DA is that it is a lot like MANOVA; in fact

Example of Stepwise Discriminant Analysis

Standardized Canonical Discriminant Function Coefficients

-.620 .804

.898 .472

Political rights score

Gini index:0=perfect $equality,100=perfectinequality

1 2

FunctionWilks' Lambda

.222 62.440 4 .000

.944 2.372 1 .124

Test of Function(s)1 through 2

2

Wilks'Lambda Chi-square df Sig.

Classification Resultsa

17 1 0 18

2 3 2 7

0 6 14 20

4 14 10 28

94.4 5.6 .0 100.0

28.6 42.9 28.6 100.0

.0 30.0 70.0 100.0

14.3 50.0 35.7 100.0

Concentration of Wealthin Hands of FewLowWealthConcentr

ModerateWealthConcentr

HighWealthConcentr

Ungrouped cases

LowWealthConcentr

ModerateWealthConcentr

HighWealthConcentr

Ungrouped cases

Count

%

Original

LowWealthConcentr

ModerateWealthConcentr

HighWealthConcentr

Predicted Group Membership

Total

75.6% of original grouped cases correctly classified.a.

The stepwise discriminant analysis tossed out two of the four variables for not measuring up, the two that seemed to have the lowest weights on the first function in the original DA. Note that these new canonical variables don’t explain quite as much variance (lambda is a little bigger than the .205 that it was in the original analysis, and the classification correctness rate is lower (75.6% compared to 84.4%)). The original seems better as long as it is not your goal to find the most parsimonious solution using the fewest predictors

Page 23: Discriminant Analysis and Classification. Discriminant Analysis as a Type of MANOVA  The good news about DA is that it is a lot like MANOVA; in fact

Writing up the Results of Your Discriminant Analysis “Discriminant analysis was used to conduct a multivariate analysis of variance

test of the hypothesis that countries with high, moderate, and low concentration of wealth would differ significantly on a linear combination of four variables, gini index, political rights score, civil liberties score, and human development score. The overall Chi-square test was significant (Wilks λ = .205, Chi-square = 64.215, df = 8, Canonical correlation = .877, p <. 001); the two functions extracted accounted for nearly 80% of the variance in country’s wealth concentration, confirming the hypothesis. Table 1 presents the standardized discriminant function coefficients. Function 1 was labeled “inequality”. The gini index, which measures inequality, was highly correlated with the function and the political rights score had a strong negative correlation. Table 2 shows the two functions at the group centroids. Reclassification of cases based on the new canonical variables was highly successful: 84.4% of the cases were correctly reclassified into their original categories.

Standardized Canonical Discriminant Function Coefficients

-.203 .689

-.528 -.437

.033 .641

.884 .482

human devel score:hi=more

Political rights score

Civil liberties score

Gini index:0=perfect $equality,100=perfectinequality

1 2

Function

Functions at Group Centroids

-2.023 .148

-.022 -.792

1.828 .144

Concentration of Wealthin Hands of FewLowWealthConcentr

ModerateWealthConcentr

HighWealthConcentr

1 2

Function

Unstandardized canonical discriminant functionsevaluated at group means

Table 1 Table 2

Page 24: Discriminant Analysis and Classification. Discriminant Analysis as a Type of MANOVA  The good news about DA is that it is a lot like MANOVA; in fact

Now It’s Time for you to Do a Discriminant Analysis in SPSS Go here to download the file NationsoftheWorldmodified.sav Let’s test the hypothesis that Country’s Wealth Concentration is

significantly associated with a linear combination of three variables, number of peaceful political demonstrations, political rights, and number of strikes

Go to Analyze/ Classify/ Discriminant Move the Country’s Wealth Concentration Variable into the Grouping

window and set the range to a minimum of 1 and a maximum of 3 Move the Number of peaceful political demonstrations, Political rights,

and Number of strikes variables into the Independents box Select Enter Independents together (not stepwise for now) Click on the Classify button and under Prior Probabilities set All

Groups Equal and under Display select Summary table, and click Continue

Click on the Statistics button and check means, univariate Anovas, Box’s M, and unstandardized function coefficients, and click Continue

Click OK, and compare your output to the next several slides

Page 25: Discriminant Analysis and Classification. Discriminant Analysis as a Type of MANOVA  The good news about DA is that it is a lot like MANOVA; in fact

Important Statistics for this Discriminant Analysis

Wilks' Lambda

.605 29.616 6 .000

.990 .616 2 .735

Test of Function(s)1 through 2

2

Wilks'Lambda Chi-square df Sig.

Eigenvalues

.635a 98.4 98.4 .623

.010a 1.6 100.0 .102

Function1

2

Eigenvalue % of Variance Cumulative %CanonicalCorrelation

First 2 canonical discriminant functions were used in theanalysis.

a.

Standardized Canonical Discriminant Function Coefficients

.311 .330

1.009 .022

-.273 .856

Number of peacefulpolitical demonstrations

Political rights score

Number of strikes of>1,000 indust or serviceworkers

1 2

Function

Functions at Group Centroids

1.052 -.018

-.384 .180

-.658 -.079

Concentration of Wealthin Hands of FewLowWealthConcentr

ModerateWealthConcentr

HighWealthConcentr

1 2

Function

Unstandardized canonical discriminant functionsevaluated at group means

Classification Resultsa

21 1 0 22

5 1 8 14

7 4 16 27

14 7 28 49

95.5 4.5 .0 100.0

35.7 7.1 57.1 100.0

25.9 14.8 59.3 100.0

28.6 14.3 57.1 100.0

Concentration of Wealthin Hands of FewLowWealthConcentr

ModerateWealthConcentr

HighWealthConcentr

Ungrouped cases

LowWealthConcentr

ModerateWealthConcentr

HighWealthConcentr

Ungrouped cases

Count

%

Original

LowWealthConcentr

ModerateWealthConcentr

HighWealthConcentr

Predicted Group Membership

Total

60.3% of original grouped cases correctly classified.a.

Page 26: Discriminant Analysis and Classification. Discriminant Analysis as a Type of MANOVA  The good news about DA is that it is a lot like MANOVA; in fact

Lab #9, Question 2 Question 2. Duplicate the preceding data analysis in

SPSS. Write up the results (the tests of the hypothesis about the relationship of country’s wealth concentration and the three predictor variables of number of strikes, number of demonstrations and political rights score, as if you were writing for publication. Put your paragraph in a Word document, and illustrate your results with tables from the output as appropriate (for example, the overall Wilks’ lambda table, group centroids, classification results, etc. Use the writeup from the previous discriminant analysis as a template.