Obtaining weights with Principal component analysis

For technical questions regarding estimation of single equations, systems, VARs, Factor analysis and State Space Models in EViews. General econometric questions and advice should go in the Econometric Discussions forum.

Moderators: EViews Gareth, EViews Moderator

nienkelangen1992
Posts: 1
Joined: Mon May 23, 2016 4:43 am

Obtaining weights with Principal component analysis

Postby nienkelangen1992 » Mon May 23, 2016 5:40 am

Hi all,

I am working with panel data (t=12, N=13) in order to obtain an index. There are 13 indicators that I want to include in this index. I divided these 13 indicators into 3 main subcategories based on economic theory. Now I want to perform PCA in order to test if I divided the indicators correctly and in order to decide upon the weight each subcategory and each indicator should get.

When I perform PCA, I obtain 13 components of which 3 determine 47% and 4 determine 58%, giving me the idea that I should use 4 categories. However, I do not know how to translate the PCA output into weights. For example, if variable x has the highest eigenvector (loading) in component 1, how do I know what its weight within component 1 will be. Just summing up the eigenvector loadings of all the variables that should be in component 1 does not equal 100%. I read something about rotating factors loadings but I am totally not familiar with this.

Can someone help me?
Many thanks,

Nienke

EViews Glenn
EViews Developer
Posts: 2671
Joined: Wed Oct 15, 2008 9:17 am

Re: Obtaining weights with Principal component analysis

Postby EViews Glenn » Tue May 24, 2016 10:02 am

I'm not entirely sure what it is you want to do, but my best guess from the question is that you want to make the component scores. You can use the group procedure Proc/Make Principal Components... to make the component scores. There are options to make variants of the scores which have different variance properties.

awatt43
Posts: 20
Joined: Mon Aug 21, 2017 12:19 am

Re: Obtaining weights with Principal component analysis

Postby awatt43 » Wed Sep 12, 2018 10:54 am

Hi there,

I have a very similar question on PCA to the original here so hopefully this is the right place to post this.

I have run covariance PCA on a set of normalised data and extracted the eigenvectors, eigenvalues and the first principle component. What I am struggling with is if I apply the following transformation: (1) take the first eigenvector and transpose this into a diagonal matrix (2) multiply this by the underlying data (3) sum the rows of this matrix to get back to the first principle component, the summed series is always consistently out by a factor versus the EViews computed PC1??

If I do the same process with correlation PCA then I end up with the summed rows being different to the EViews PC1 by a different amount each period.

Is there something that I am missing in the calculation of the principle components which would mean that the sum of the (evec*underlying data) does not equilibrate to the EViews estimated principle component?

For context I am trying to understand the contribution of each series to the PC1 in each time period so that I can see how the relevance of series in my dataset changes overtime.

Unfortunately I cannot share my work file due to data privileges but hopefully the explanation above is clear enough.

Thanks in advance,
Abi

EViews Glenn
EViews Developer
Posts: 2671
Joined: Wed Oct 15, 2008 9:17 am

Re: Obtaining weights with Principal component analysis

Postby EViews Glenn » Thu Sep 13, 2018 11:47 am

I must admit that I don't entirely understand what you are trying to do with your calculation. The following shows the equivalence between post-multiplying the data by the eigenvectors and the score series created using normalize loadings scaling. Note that as expected the average sum of the squared scores equals the corresponding eigenvalue.

Code: Select all

workfile u 1000

group group01
for !i = 1 to 3
   series a!i = nrnd
   a!i = (a!i - @mean(a!i))/@stdevp(a!i)
   group01.add a!i
next
stom(group01, yy)

freeze(pcomp) group01.pcomp(cov=cov, eigval=abc1, eigvec=abc2)
matrix v1 = yy*abc2

group01.makepcomp(cov=cov) v1a v1b v1c
group v1alt v1a v1b v1c

vector ev = @csumsq(v1)/@rows(v1)

awatt43
Posts: 20
Joined: Mon Aug 21, 2017 12:19 am

Re: Obtaining weights with Principal component analysis

Postby awatt43 » Tue Sep 18, 2018 11:38 pm

Thank you for your response Glenn - I have managed to obtain what i wanted to calculate from your code.

I did have another more general question - i understand that EViews can report both the loadings and the eigenvectors, why would these be the same when using the covariance method of PCA?

Thanks,
Abi

awatt43
Posts: 20
Joined: Mon Aug 21, 2017 12:19 am

Re: Obtaining weights with Principal component analysis

Postby awatt43 » Mon Nov 26, 2018 1:05 am

Hi there,

I would like to obtain the minimum average partial statistic for PCA so that I can ascertain the 'optimal' number of principle components to retain. I am aware that this is a built in function for choosing the optimal number of factors in the factor analysis tool but I was wondering how I would apply this to principle component analysis?

Will I need to write the code myself?

Thanks,
Abigail

EViews Mirza
Posts: 80
Joined: Sat Apr 22, 2017 8:23 pm

Re: Obtaining weights with Principal component analysis

Postby EViews Mirza » Mon Nov 26, 2018 5:16 pm

awatt43 wrote:I did have another more general question - i understand that EViews can report both the loadings and the eigenvectors, why would these be the same when using the covariance method of PCA?


The reason that loadings and eigenvectors can sometimes be identical is because a loading vector is just a scaled version of the eigenvector. Typically, this scaling is some kth root of the associated eigenvalue. However, when that scaling is unity, a loading vector is an eigenvector

awatt43 wrote:I would like to obtain the minimum average partial statistic for PCA...Will I need to write the code myself?


This is, at the moment, a yes. Beyond the scree plot analysis, EViews currently does not implement any data-driven protocol for dimension reduction.

If you would like to read more about the use of PCA using EViews, please see our two part blog post. There, we also implement a brief code to adapt the Bai and Ng factor selection protocol to PCA.

PCA Part I (Theory): http://blog.eviews.com/2018/10/principal-component-analysis-part-i.html
PCA Part II (Practice): http://blog.eviews.com/2018/11/principal-component-analysis-part-ii.html

kaix1231
Posts: 2
Joined: Mon Nov 08, 2021 2:22 am

Re: Obtaining weights with Principal component analysis

Postby kaix1231 » Fri Oct 21, 2022 2:21 am

awatt43 wrote:Thank you for your response Glenn - I have managed to obtain what i wanted to calculate from your code.

I did have another more general question - i understand that EViews can report both the loadings and the eigenvectors, why would these be the same when using the covariance method of PCA?

Thanks,
Abi




Hi awatt43, I am also trying to calculate my own PC value using (loading)^2 as the weight and multiplying my raw x1,x2, x3.. .data but it is not the same with the PC result shown in Eviews using the "Make Principal Component" function. Do you mind sharing how you did it?

EViews Glenn
EViews Developer
Posts: 2671
Joined: Wed Oct 15, 2008 9:17 am

Re: Obtaining weights with Principal component analysis

Postby EViews Glenn » Fri Oct 21, 2022 12:35 pm

viewtopic.php?f=4&t=19470&p=62455&hilit=principal+components#p62496

Note also for those reading this entire discussion, EViews now offers a variety of data-based methods of selecting the number of components.


Return to “Estimation”

Who is online

Users browsing this forum: No registered users and 37 guests