|
|
|
||||
|
|
|||||
Note: This data analysis example needs Stata 10 or later.
Example 1. A researcher has collected data on three psychological variables, four academic variables (standardized test scores) and gender for 600 college freshman. She is interested in how the set of psychological variables relates to the academic variables and gender. In particular, the researcher is interested in how many dimensions are necessary to understand the association between the two sets of variables.
Example 2. There is Fisher's (1936) classic example of discriminant analysis involving three varities of iris and four predictor variables (petal width, petal length, sepal width, and sepal length). Fisher not only wanted to determine if the varieties differed significantly on the four continuous variables but he was also interested in predicting variety classification for unknown individual plants.
We have a data file, discrim.dta, with 244 observations on four variables. The psychological variables are outdoor interests, social and conservative. The categorical variable is job type with three levels; 1) customer service, 2) mechanic, and 3) dispatcher.
Let's look at the data.
use http://www.ats.ucla.edu/stat/stata/dae/discrim, clear
summarize outdoor social conservative
Variable | Obs Mean Std. Dev. Min Max
-------------+--------------------------------------------------------
outdoor | 244 15.63934 4.839933 0 28
social | 244 20.67623 5.479262 7 35
conservative | 244 10.59016 3.726789 0 20
tabstat outdoor social conservative, by(job) stat(n mean sd min max) col(stat)
Summary for variables: outdoor social conservative
by categories of: job
job | N mean sd min max
-----------------+--------------------------------------------------
customer service | 85 12.51765 4.648635 0 22
| 85 24.22353 4.335283 12 35
| 85 9.023529 3.143309 2 17
-----------------+--------------------------------------------------
mechanic | 93 18.53763 3.564801 11 28
| 93 21.13978 4.55066 9 29
| 93 10.13978 3.242354 0 17
-----------------+--------------------------------------------------
dispatch | 66 15.57576 4.110252 4 25
| 66 15.45455 3.766989 7 26
| 66 13.24242 3.69224 4 20
-----------------+--------------------------------------------------
Total | 244 15.63934 4.839933 0 28
| 244 20.67623 5.479262 7 35
| 244 10.59016 3.726789 0 20
--------------------------------------------------------------------
correlate outdoor social conservative
(obs=244)
| outdoor social conser~e
-------------+---------------------------
outdoor | 1.0000
social | -0.0713 1.0000
conservative | 0.0794 -0.2359 1.0000
tabulate job
job | Freq. Percent Cum.
-----------------+-----------------------------------
customer service | 85 34.84 34.84
mechanic | 93 38.11 72.95
dispatch | 66 27.05 100.00
-----------------+-----------------------------------
Total | 244 100.00
We will run the discriminant analysis using the new candisc procedure in Stata 10. We could also have run the discrim lad to get the same analysis with slightly different output. There is a lot of output so we will comment at various places along the way.
candisc outdoor social conservative, group(job)
Canonical linear discriminant analysis
| | Like-
| Canon. Eigen- Variance | lihood
Fcn | Corr. value Prop. Cumul. | Ratio F df1 df2 Prob>F
----+---------------------------------+------------------------------------
1 | 0.7207 1.08053 0.7712 0.7712 | 0.3640 52.382 6 478 0.0000 e
2 | 0.4927 .320504 0.2288 1.0000 | 0.7573 38.46 2 240 0.0000 e
---------------------------------------------------------------------------
Ho: this and smaller canon. corr. are zero; e = exact F
There are two discriminant dimensions both of which are statistically significant. The canonical correlations for the dimensions one and two are 0.72 and 0.49 respectively.
Standardized canonical discriminant function coefficients
| function1 function2
-------------+----------------------
outdoor | .3785725 .9261104
social | -.8306986 .2128593
conservative | .5171682 -.2914406
Canonical structure
| function1 function2
-------------+----------------------
outdoor | .3230982 .9372155
social | -.7653907 .2660298
conservative | .467691 -.2587426
The standardized discriminant coefficients function in a manner analogous to standardized regression coefficients in OLS regression. For example, a one standard deviation increase on the outdoor variable will result in a .32 standard deviation decrease in the predicted values on discriminant function 1. The canonical structure, also known as canonical loading or discriminant loadings, represent correlations between observed variables and the unob served discriminant functions (dimensions). The discriminat functions are a kind of latent variable and the correlations are loadings analgous to factor loadings.
Group means on canonical variables
| job
--------+------------------
group1 | customer service
group2 | mechanic
group3 | dispatch
| function1 function2
-------------+----------------------
group1 | -1.2191 -.3890039
group2 | .1067246 .7145704
group3 | 1.419669 -.5059049
Resubstitution classification summary
+---------+
| Key |
|---------|
| Number |
| Percent |
+---------+
| Classified
True | group1 group2 group3 | Total
-------------+------------------------+-------
group1 | 70 11 4 | 85
| 82.35 12.94 4.71 | 100.00
| |
group2 | 16 62 15 | 93
| 17.20 66.67 16.13 | 100.00
| |
group3 | 3 12 51 | 66
| 4.55 18.18 77.27 | 100.00
-------------+------------------------+-------
Total | 89 85 70 | 244
| 36.48 34.84 28.69 | 100.00
| |
Priors | 0.3333 0.3333 0.3333 |
The output includes the means on the discriminant functions for each of the three groups and a classification table. Values in the diagonal of the classification table reflect the correct classification of individuals into groups based on their scores on the discriminant dimensions.
Next, we will plot a graph of individuals on the discriminant dimensions. Due to the large number of subjects we will shorten the labels for the job groups to make the graph more legible. As long as we don't save the dataset these new lables will not be made permanent.
label define job 1 "c" 2 "m" 3 "d", modify scoreplot, msymbol(i)
As you can see the customer service people tend to be a the more social (negative) end of dimension 1 and dispatchers at the opposite end with mechanics in the middle. On dimension 2 the results are not as clear, however the mechanics tend to be higher on the outdoor dimension and customer service and dispatchers lower.
We can also plot the discriminant loadings for the variables onto the discriminant dimensions
loadingplot
And there is no surprise as the variable social is strong on the social dimension, i.e., it has a high negative loading and the outdoor variable is high on the outdoor dimension.
Table 1: Tests of Discriminant Dimensions
Canonical Mult.
Dimension Corr. F df1 df2 p
1 0.72 52.38 6 478 0.000
2 0.49 38.46 2 240 0.000
Table 2: Standardized Discriminant Coefficients
Dimension
1 2
outdoor 0.38 0.93
social -0.83 0.21
conservative 0.52 -0.29
Tests of dimensionality for the discriminant analysis, as shown in Table 1, indicate that both of the dimensions are statistically significant. The F-tests associated with each dimension are exact. Dimension 1 had a canonical correlation of 0.72 between the response variables and the job classification, while for dimension 2 the canonical correlation was lower at 0.49.
Table 2 presents the standardized canonical coefficients for both dimensions. The first discriminant dimension is positively weighted by outdoor (0.38) and conservation (0.52 and strongly negative on social (-0.83). The second discriminant dimenstion is dominated by the outdoor variable (0.93). These results are interpreted to indicate that the first dimension reflects a bipolar social/non-social dimension while the second is an outdoor/non-outdoor dimension.UCLA Researchers are invited to our Statistical Consulting Services
We recommend others to our list of Other Resources for Statistical Computing Help
These pages are Copyrighted (c) by UCLA Academic Technology Services