Multivariate Analysis
Q Factor Analysis


Q factor analysis involves factoring observations rather than variables. In many ways, it is more similar to cluster analysis than it is to factor analysis. Basically, you have to transpose the data matrix so that the rows are the variables and the columns are the observations.

In this example, we will use the same data that was in one of the cluster analysis examples, eight dental variables on 32 species of mammals.

Q Factor Analysis Example in Stata

input brnbat mole silbat pigbat houbat redbat pika rabbit beaver      /*
*/ grndhog grsquir houmouse porcupin wolf bear raccoon marten weasel     /*
*/ wolverin badger rivott seaott jaguar cougar furseal sealion grseal    /*
*/ eleseal reindeer elk deer moose
2 3 2 2 2 1 2 2 1 1 1 1 1 3 3 3 3 3 3 3 3 3 3 3 3 3 3 2 0 0 0 0
3 2 3 3 3 3 1 1 1 1 1 1 1 3 3 3 3 3 3 3 3 2 3 3 2 2 2 1 4 4 4 4
1 1 1 1 1 1 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0
1 0 1 1 1 1 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0
3 3 2 2 1 2 2 3 2 2 1 0 1 4 4 4 4 3 4 3 4 3 3 3 4 4 3 4 3 3 3 3
3 3 3 2 2 2 2 2 1 1 1 0 1 4 4 4 4 3 4 3 3 3 2 2 4 4 3 4 3 3 3 3
3 3 3 3 3 3 3 3 3 3 3 3 3 2 2 3 1 1 1 1 1 1 1 1 1 1 2 1 3 3 3 3
3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 2 2 2 2 2 2 2 1 1 1 1 2 1 3 3 3 3
end

factor brnbat-moose, ipf factor(3)
(obs=8)
(collinear variables specified)

            (iterated principal factors; 3 factors retained)
  Factor     Eigenvalue     Difference    Proportion    Cumulative
------------------------------------------------------------------
     1       17.44252         7.51757      0.5887         0.5887
     2        9.92494         7.66604      0.3350         0.9238
     3        2.25891         1.12029      0.0762         1.0000
     4        1.13862         0.81171      0.0384         1.0384
     5        0.32691         0.10448      0.0110         1.0495
     ...
     
[output omitted]

rotate, varimax

            (varimax rotation)
            Rotated Factor Loadings 
 Variable |      1           2           3     Uniqueness
----------+----------------------------------------------
   brnbat |   0.47177     0.58486*   -0.65675*    0.00405
     mole |   0.58140*    0.74506*   -0.20275     0.06576
   silbat |   0.27091     0.60037*   -0.67497*    0.11058
   pigbat |   0.09860     0.66601*   -0.67429*    0.09205
   houbat |  -0.11158     0.59375*   -0.59665*    0.27902
   redbat |  -0.05033     0.53801*   -0.84479*   -0.00566
     pika |   0.27102     0.94664*   -0.18404    -0.00346
   rabbit |   0.39959     0.87017*   -0.17291     0.05323
   beaver |   0.03043     0.90797*   -0.33436     0.06286
  grndhog |   0.03043     0.90797*   -0.33436     0.06286
  grsquir |  -0.13472     0.93302*   -0.34169    -0.00542
 houmouse |  -0.38545     0.83741*   -0.28219     0.07054
 porcupin |  -0.13472     0.93302*   -0.34169    -0.00542
     wolf |   0.88396*    0.31202    -0.31420     0.02254
     bear |   0.88396*    0.31202    -0.31420     0.02254
  raccoon |   0.82558*    0.31879    -0.31171     0.11962
   marten |   0.97446*   -0.01751    -0.20838     0.00669
   weasel |   0.92060*    0.00195    -0.23847     0.09562
 wolverin |   0.97446*   -0.01751    -0.20838     0.00669
   badger |   0.92060*    0.00195    -0.23847     0.09562
   rivott |   0.94969*    0.00255    -0.19976     0.05818
   seaott |   0.96756*    0.14172     0.03291     0.04265
   jaguar |   0.82872*   -0.15671    -0.14209     0.26848
   cougar |   0.82872*   -0.15671    -0.14209     0.26848
  furseal |   0.97573*   -0.05969     0.03729     0.04300
  sealion |   0.97573*   -0.05969     0.03729     0.04300
   grseal |   0.90758*    0.40037    -0.02060     0.01558
  eleseal |   0.85125*   -0.00919     0.06816     0.27064
 reindeer |   0.21917     0.28451    -0.89172*    0.07585
      elk |   0.21917     0.28451    -0.89172*    0.07585
     deer |   0.28260     0.34571    -0.87739*    0.03081
    moose |   0.28260     0.34571    -0.87739*    0.03081

[* added]

                         Factor Names
              factor1      factor2     factor3
              carnivore    rodent/bat  deer/bat 
              
Alternate Data Input

use http://www.gseis.ucla.edu/courses/data/mammal

xpose, clear

list v1

            v1 
  1.         .  
  2.         2  
  3.         3  
  4.         1  
  5.         1  
  6.         3  
  7.         3  
  8.         3  
  9.         3  

drop in 1
(1 observation deleted)

list v1

            v1 
  1.         2  
  2.         3  
  3.         1  
  4.         1  
  5.         3  
  6.         3  
  7.         3  
  8.         3

factor v1-v32, ipf factor(3)

rotate, varimax

and so on ...


Multivariate Course Page

Phil Ender, 26nov03