I am working on the panel data of a large number of countries.
I have to use PCA on three variable namely inf to bdg by country. And have to make an index by combining these three variables.
Like the results for country 3 are given below.
-> country = 3
Principal components/correlation Number of obs = 21
Number of comp. = 3
Trace = 3
Rotation: (unrotated = principal) Rho = 1.0000
--------------------------------------------------------------------------
Component | Eigenvalue Difference Proportion Cumulative
-------------+------------------------------------------------------------
Comp1 | 1.49128 .514823 0.4971 0.4971
Comp2 | .976458 .444197 0.3255 0.8226
Comp3 | .532261 . 0.1774 1.0000
--------------------------------------------------------------------------
Principal components (eigenvectors)
----------------------------------------------------------
Variable | Comp1 Comp2 Comp3 | Unexplained
-------------+------------------------------+-------------
to | -0.6853 0.1973 0.7010 | 0
inf | 0.2206 0.9736 -0.0584 | 0
bdg | 0.6940 -0.1146 0.7108 | 0
----------------------------------------------------------
. the formula for the index will be
P=-0.6853*to +0.2206 * inf +| 0.6940 *bdg
For country 2
-> country = 2
Principal components/correlation Number of obs = 21
Number of comp. = 3
Trace = 3
Rotation: (unrotated = principal) Rho = 1.0000
--------------------------------------------------------------------------
Component | Eigenvalue Difference Proportion Cumulative
-------------+------------------------------------------------------------
Comp1 | 2.03907 1.48791 0.6797 0.6797
Comp2 | .55116 .141388 0.1837 0.8634
Comp3 | .409772 . 0.1366 1.0000
--------------------------------------------------------------------------
Principal components (eigenvectors)
----------------------------------------------------------
Variable | Comp1 Comp2 Comp3 | Unexplained
-------------+------------------------------+-------------
to | 0.5499 0.8304 -0.0894 | 0
inf | 0.5947 -0.3141 0.7400 | 0
bdg | -0.5864 0.4601 0.6666 | 0
----------------------------------------------------------
. the formula for the index for country 2 will be
P=-0. 5499 *to +0.5947 * inf - 0.5864*bdg
And so on for other countries.
How I can do this in stata through do file.
The data for the three countries is attached with the email.
I have to use PCA on three variable namely inf to bdg by country. And have to make an index by combining these three variables.
Like the results for country 3 are given below.
-> country = 3
Principal components/correlation Number of obs = 21
Number of comp. = 3
Trace = 3
Rotation: (unrotated = principal) Rho = 1.0000
--------------------------------------------------------------------------
Component | Eigenvalue Difference Proportion Cumulative
-------------+------------------------------------------------------------
Comp1 | 1.49128 .514823 0.4971 0.4971
Comp2 | .976458 .444197 0.3255 0.8226
Comp3 | .532261 . 0.1774 1.0000
--------------------------------------------------------------------------
Principal components (eigenvectors)
----------------------------------------------------------
Variable | Comp1 Comp2 Comp3 | Unexplained
-------------+------------------------------+-------------
to | -0.6853 0.1973 0.7010 | 0
inf | 0.2206 0.9736 -0.0584 | 0
bdg | 0.6940 -0.1146 0.7108 | 0
----------------------------------------------------------
. the formula for the index will be
P=-0.6853*to +0.2206 * inf +| 0.6940 *bdg
For country 2
-> country = 2
Principal components/correlation Number of obs = 21
Number of comp. = 3
Trace = 3
Rotation: (unrotated = principal) Rho = 1.0000
--------------------------------------------------------------------------
Component | Eigenvalue Difference Proportion Cumulative
-------------+------------------------------------------------------------
Comp1 | 2.03907 1.48791 0.6797 0.6797
Comp2 | .55116 .141388 0.1837 0.8634
Comp3 | .409772 . 0.1366 1.0000
--------------------------------------------------------------------------
Principal components (eigenvectors)
----------------------------------------------------------
Variable | Comp1 Comp2 Comp3 | Unexplained
-------------+------------------------------+-------------
to | 0.5499 0.8304 -0.0894 | 0
inf | 0.5947 -0.3141 0.7400 | 0
bdg | -0.5864 0.4601 0.6666 | 0
----------------------------------------------------------
. the formula for the index for country 2 will be
P=-0. 5499 *to +0.5947 * inf - 0.5864*bdg
And so on for other countries.
How I can do this in stata through do file.
The data for the three countries is attached with the email.
Comment