Principal Components Analysis

For questions regarding programming in the EViews programming language.

Moderators: EViews Gareth, EViews Jason, EViews Moderator, EViews Matt

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

Re: Principal Components Analysis

Postby EViews Glenn » Fri Jan 30, 2009 3:44 pm

There's an option when you run programs to continue even if you get errors up to a maximum number...It's set at 1 by default, make it bigger.

startz
Non-normality and collinearity are NOT problems!
Posts: 3775
Joined: Wed Sep 17, 2008 2:25 pm

Re: Principal Components Analysis

Postby startz » Fri Jan 30, 2009 3:52 pm

QMS Glenn wrote:There's an option when you run programs to continue even if you get errors up to a maximum number...It's set at 1 by default, make it bigger.


This appears to be a response to
Greentea wrote:
You’re a genius!!

Steady on, it'll go to his head....I have to work with him!


Which of them do you think was committing a program error, such that more such errors should be permitted? :P

Greentea
Posts: 19
Joined: Tue Jan 27, 2009 3:50 pm

Re: Principal Components Analysis

Postby Greentea » Fri Jan 30, 2009 4:09 pm

By increasing the number, I've got my the programme working! How can I ever thank you enough!

Without exaggeration that you've made my day! Thank you!!

Greentea
Posts: 19
Joined: Tue Jan 27, 2009 3:50 pm

Re: Principal Components Analysis

Postby Greentea » Thu Feb 05, 2009 10:57 am

I’m afraid that I have to trouble you again about the program which you kindly helped me out last time.

Is that possible to display these 848 principal component analysis results one by one within Eviews, please? Last time, I had all the eigenvalues, eigenvectors and the ordinary correlation matrixes saved in Excel format. However, every time when I opened these Excel files, there were error messages saying that “File errors. Some number formats may have been lost.”.

Thank you very much as always!

Greentea
Posts: 19
Joined: Tue Jan 27, 2009 3:50 pm

Re: Principal Components Analysis

Postby Greentea » Thu Feb 05, 2009 4:18 pm

I’m afraid that I found another problem about the results of principal components analysis (PCA). Using those 2 programs which are shown in the 10th post (posted by me at 3:50 pm, Tue Jan 27, 2009 ), I only managed to get 22 eigenvalues (V1) for each of the programs. Taking the first programme for example, when I run the first programe, which is to get PCA results across years with a given firm, I should get 848*22 different V1. However, I only get one file with V1. Could you please be so kind to look into this for me, please?

Thank you!

Greentea
Posts: 19
Joined: Tue Jan 27, 2009 3:50 pm

Re: Principal Components Analysis

Postby Greentea » Fri Feb 06, 2009 1:22 pm

I think that I know where went wrong regarding my last post. However, could kindly lend me a hand for the post before that(to display results on screen)? Thank you!

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

Re: Principal Components Analysis

Postby EViews Glenn » Fri Feb 06, 2009 2:24 pm

I'm afraid that I don't quite understand what it is you are trying to do. What exactly do you mean by displaying the results one by one?

Greentea
Posts: 19
Joined: Tue Jan 27, 2009 3:50 pm

Re: Principal Components Analysis

Postby Greentea » Fri Feb 06, 2009 4:12 pm

Thank you very much for the reply and sorry for the confusion I caused. I should have given you some background information!

I think that the aim of the 1st program in post 10 is to run a Principal Component Analysis (PCA) across years with a given firm using following 20 accounting measures.
group pclevel BOOKMV CACL CASHFLOWMV CASHFLOWTA CASHFLOWTLIABILITIES CREDITORMV CREDITORTA DY FIXATA IGEAR LTBORMV LTBORRATIO OPINCOMMV TAMV SALESTA SALESMV PMTA PMMV OPM OPINCOMTA
for !firm=1 to 848
smpl if crossid = !firm
pclevel.pcomp(cor, eigval=v1, eigvec=m1) pc1 pc2 pc3 pc4 pc5
v1.write v_1{!firm}.xls
m1.write m_1{!firm}.xls
group comps pc1 pc2 pc3 pc4 pc5
write comps_{!firm}.xls comps
next
At that moment, we showed the correlation matrixes and stored the results of eigenvalues (v1s), eigenvectors(m1) and the sores(comps) onto separated Excel firms. Since I have 848 firms in my data, I have 848 different files for v1, 848 files for m1 and 848 files for comps.
I’m wondering that is it possible to display the correlation matrixes, v1s, m1 and comps company by company, please? However, the program above only displays the correlation matrixes, v1s, m1 and comps of the last company in my data on the screen. I guess perhaps there is a way to pause the program and proceed again using each firm as a unit?

Thank you very much for your help!

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

Re: Principal Components Analysis

Postby EViews Glenn » Wed Feb 11, 2009 7:44 am

Possibly the best way for you is to, instead of storing everything onto disk in your loop, put your results in a spool object. Then you can look at individual results in EViews. You'll have to look at the docs for a discussion of how to do this...

Greentea
Posts: 19
Joined: Tue Jan 27, 2009 3:50 pm

Re: Principal Components Analysis

Postby Greentea » Thu Feb 12, 2009 9:39 am

Thank you so much for the advice. I'll certainly look into spool object and if I face any problems, I may have to trouble you again. Thanks!

abcd
Posts: 7
Joined: Fri Jan 17, 2014 9:59 am

Re: Principal Components Analysis

Postby abcd » Fri Jan 17, 2014 10:04 am

Hi Admin
I am do the same type of analysis.

I am woring on panel data, haveing time series form 1970 to 2008. and number of countries are 30. I have to generate the PCA for each country. first of all I have to generate the eigen vales for vountry one and store them in excel and generate the eigen vlaues for country two and save them in excel below the eigean values of first country eigen values. and so on

what chages in the program i have to do
thanks

saranya
Posts: 41
Joined: Wed Nov 16, 2016 5:51 am

Re: Principal Components Analysis

Postby saranya » Wed Feb 15, 2017 5:00 am

what if I want to store only the principal components that has an eigen value greater than 1? I have mentioned something like this:
freeze(tab) all.pcomp(cor, mineigen=1, eigval=eval, eigvec=evec)

however, the eval vector still has all the principal components ( which equals the number of variables)


Return to “Programming”

Who is online

Users browsing this forum: No registered users and 16 guests