Page 1 of 2
Principal Components Analysis
Posted: Tue Jan 27, 2009 4:24 pm
by Greentea
I have a stacked 22 series in a workfile named local in Eviews’ 6.0. These 22 series include annual data for 848 firms from1988 to 2005. The 22 series are: DBOOKMV, DCACL, DCASHFLOWMV, DCASHFLOWTA, DCASHFLOWTLIABILITIES, DCREDITORMV, DCREDITORTA, DDY, DFIXATA, DIGEAR, DLTBORMV, DLTBORRATIO, DLTDEBTFA, DOPINCOMMV, DTAMV, DSTDEBTFA, DSALESTA, DSALESMV, DPMTA, DPMMV, DOPM and DOPINCOMTA. Additionally, Eviews automatically created 2 series: CROSSID and DATEID and a constant (C). Because DATEID is in the format of 1/1/1988, I also created another series which is called YEAR in the format of 1988.000.
I’d like to 1) to run a principal components analysis (using correlation matrix) for each firm in each year. 2) to display, save and print the results of the ordinary correlation, the eigenvalues and the eigenvectors (loadings) into a table. 3) to store the first 5 principal components’ component scores into a file. Then to display, to save and to print this file. 4) All remains the same, I’d also like to repeat the procedure above to run a principal component analysis (using correlation matrix) for every firm during 1988-2005. The program which covers steps 1) to step 3) is listed below.
!firm=0
!firm=!firm+1 and !firm<848
!yr=-1
!yr=!yr+1 and !yr<18
!i=1987.000
!i=!i+1 and !i<2005.000
If crossid=!firm and year=1988.000+!yr then
group pc1stdif!i DBOOKMV DCACL DCASHFLOWMV DCASHFLOWTA DCASHFLOWTLIABILITIES DCREDITORMV DCREDITORTA DDY DFIXATA DIGEAR DLTBORMV DLTBORRATIO DLTDEBTFA DOPINCOMMV DTAMV DSTDEBTFA DSALESTA DSALESMV DPMTA DPMMV DOPM DOPINCOMTA
freeze(bycompany!firm) pc1stdif!i.pcomp(cor, eigvale=v1, eigvec=m1) pc1 pc2 pc3 pc4 pc5
bycompany!firm.save mytable.txt
open mytable.txt
print mytable.txt
pc1stdif!i.makepccomp comp1 comp2 comp3 comp4 comp5
pc1stdif!i.save score1.txt
open score1.txt
print score.txt
save local
endif
There is not error message when I run this program. However, Eviews also do not display, save or print any results. Could you be so kind to point out the problem in this program, please? Thank you very much!
Re: Principal Components Analysis
Posted: Wed Jan 28, 2009 1:11 pm
by EViews Glenn
There are a number of problems with your program.
The most important thing is that you need to be quite clear about where the outputs from the original program are stored. The
pcomp and
makepcomp routines allow you to save the eigenvalues and eigenvectors as well as the components into EViews objects in the workfile. As described in the manual, the
eigval= option instructs EViews to save the eigenvalues in a vector in the workfile, while the
eigvec= option instructs EViews to save the eigenvectors in a matrix in the workfile. Listing names for the components after the command tells EViews to save the results in series with those names in the workfile.
The key line in your program is:
Code: Select all
freeze(bycompany!firm) pc1stdif!i.pcomp(cor, eigval=v1, eigvec=m1) pc1 pc2 pc3 pc4 pc5
Note that I've corrected a typo in the "eigval=" option from your original post.
This command will put the eigenvalue and eigenvector results in a vector V1 and a matrix M1, and the first five components in series PC1, PC2, PC3, PC4 and PC5.
To print V1 and M1, you can issue the commands:
To save them in text files
Code: Select all
v1.write v1_{!firm}.txt
m1.write m_1{!firm}.text
Note that I've appended the firm identifier to the output name.
To print the components:
Code: Select all
group comps pc1 pc2 pc3 pc4 pc5
write comps_{!firm}.txt comps
print comps
writes the series in the group COMPS (PC1 to PC5) to a text file (with appended firm identifier), then prints the group with the components.
To be honest, I'm not certain that you're going to want to print the output inside the loop (I think you are better off working with the saved files directly), but what I've posted above should work in you wish to do so.
Re: Principal Components Analysis (no results)
Posted: Wed Jan 28, 2009 2:33 pm
by Greentea
Thank YOU so much for the reply and thank you very much for the kind advice!
I’m not so sure about what do you mean by “I'm not certain that you're going to want to print the output inside the loop”. I simply need to save and print 2 files. The format of the file does not matter (Well, if I can get the file in Excel format it will be a plus). The 1st file shows the results of the ordinary correlation, the eigenvalues and the eigenvectors. The 2nd file displays component scores for PC1, PC2, PC3, PC4 and PC5.
However, after making all those changes as you kindly suggested below, I'm still facing the same problem. That is, Eviews do not save and print any result for me and there is no error message. The revised program is listed below.
!firm=0
!firm=!firm+1 and !firm<848
!yr=-1
!yr=!yr+1 and !yr<18
!i=1987.000
!i=!i+1 and !i<2005.000
If crossid=!firm and year=1988.000+!yr then
group pc1stdif!i DBOOKMV DCACL DCASHFLOWMV DCASHFLOWTA DCASHFLOWTLIABILITIES DCREDITORMV DCREDITORTA DDY DFIXATA DIGEAR DLTBORMV DLTBORRATIO DLTDEBTFA DOPINCOMMV DTAMV DSTDEBTFA DSALESTA DSALESMV DPMTA DPMMV DOPM DOPINCOMTA
freeze(bycompany!firm) pc1stdif!i.pcomp(cor, eigval=v1, eigvec=m1) pc1 pc2 pc3 pc4 pc5
print v1
print m1
v1.write v1 {!firm}.txt
m1.write m_1{!firm}.txt
group comps pc1 pc2 pc3 pc4 pc5
write comps_{!firm}.txt comps
print comps
endif
Could you be so kind to tell me what the problem is, please?
It sounds that this program above doesn’t communicate with, correspond or link to the workfile where all my data is in.
Many thanks!
Re: Principal Components Analysis
Posted: Wed Jan 28, 2009 4:10 pm
by EViews Glenn
I’m not so sure about what do you mean by “I'm not certain that you're going to want to print the output inside the loop”. I simply need to save and print 2 files. The format of the file does not matter (Well, if I can get the file in Excel format it will be a plus). The 1st file shows the results of the ordinary correlation, the eigenvalues and the eigenvectors. The 2nd file displays component scores for PC1, PC2, PC3, PC4 and PC5.
If your looping was working, printing results using the
print command will put results for each country will be on at least three pieces of paper (one each for the vector, the matrix, and at least one for the components), each of which will have identical header information across firms (since the names of the objects you are saving are the same in every iteration of the loop). I'm not certain, but I can't imagine that being particularly useful.
Now the results that you save to individually named files...those are clearly useful. In the examples I provided earlier, if you replace the .TXT extension with .XLS, you'll get Excel files, three for each firm, with the name of the file uniquely identifying the output.
As to why it's not working, you'll have to send your workfile to us for that (
support@eviews.com). I do notice that you aren't really doing any looping here so I suspect it's that you have no observations in your sample. What is in your V1 and M1, and PC1 after you are doing running your program? Or more to the point, what is in !firm and !yr
Re: Principal Components Analysis
Posted: Thu Jan 29, 2009 3:09 am
by Greentea
Thank you so much for the useful information as always.
To me, I thought I’ve asked Eviews to create a !firm and a !yr in order to identify each firm and each year. I cannot see these !firm and !yr coz they are control variables. Yes, I didn’t use loop coz I though merely the control variables will do the job. Now, I changed the programme as below.
for !firm=0 to 847
!firm=!firm+1
!yr=-1
!yr=!yr+1 and !yr<18
!i=1987.000
!i=!i+1 and !i<2005.000
If crossid=!firm and year=1988.000+!yr then
group pc1stdif!i DBOOKMV DCACL DCASHFLOWMV DCASHFLOWTA DCASHFLOWTLIABILITIES DCREDITORMV DCREDITORTA DDY DFIXATA DIGEAR DLTBORMV DLTBORRATIO DLTDEBTFA DOPINCOMMV DTAMV DSTDEBTFA DSALESTA DSALESMV DPMTA DPMMV DOPM DOPINCOMTA
freeze(bycompany!firm) pc1stdif!i.pcomp(cor, eigval=v1, eigvec=m1) pc1 pc2 pc3 pc4 pc5
print v1
print m1
v1.write v1 {!firm}.xls
m1.write m_1{!firm}.xls
group comps pc1 pc2 pc3 pc4 pc5
write comps_{!firm}.xls comps
print comps
endif
next
I think that this programme is working. Because when I run the programme, I can see Eviews are processing this programme. However, the same problem remains. No files and no printed results. I’ve sent my workfile named local and my programme file named looppc to the email address which you kindly provided here.
Thank you and I look forward to hearing from you!
Re: Principal Components Analysis
Posted: Thu Jan 29, 2009 12:15 pm
by EViews Glenn
If I'd looked a bit more carefully at the program I wouldn't have had to have to send the workfile (though as you'll see below it was useful for me to have).
The problem in the program is that your IF condition is never true. You are performing a series boolean test:
If crossid=!firm and year=1988.000+!yr then
This statement tests whether the series CROSSID is equal to the !FIRM value for all periods (which it clearly does not) and whether the YEAR series is equal to 1988+!YR for all periods (which it also do not). Thus, none of the code in your IF statement is being called, hence no output.
What I think that you want to do is to remove the ENDIF statement, and replace the IF statement with a sample condition
Code: Select all
smpl if crossid=!firm and year=1988+!yr
which will give you the observations that you appear to want from your IF statement.
Doing so, however, yields a different problem. You have a balanced sample of annual data from 1988 to 2005 for 848 cross-sections. The sample condition that you provided will result in exactly one observation being kept. Clearly you can't run a principal components procedure for one data point. I suspect from an earlier post that you simply want to perform the PC analysis for each of the cross sections. In this case, you can simply your code greatly:
Code: Select all
group pc1stdif DBOOKMV DCACL DCASHFLOWMV DCASHFLOWTA DCASHFLOWTLIABILITIES DCREDITORMV DCREDITORTA DDY DFIXATA DIGEAR DLTBORMV DLTBORRATIO DLTDEBTFA DOPINCOMMV DTAMV DSTDEBTFA DSALESTA DSALESMV DPMTA DPMMV DOPM DOPINCOMTA
for !firm=1 to 848
smpl if crossid = !firm
pc1stdif.pcomp(cor, eigval=v1, eigvec=m1) pc1 pc2 pc3 pc4 pc5
print v1
print m1
v1.write v1 {!firm}.xls
m1.write m_1{!firm}.xls
group comps pc1 pc2 pc3 pc4 pc5
write comps_{!firm}.xls comps
print comps
next
Note that I've moved the group definition outside of the loop since it doesn't change. I've also removed the FREEZE part of the statement since you don't use the output from the routine for anything.
I again caution you about using the PRINT statement with your COMPS group, since that will produce **a lot** of paper output.
Even as written above, you still have problems running your program since for your first cross-section you only have 4 usable observations for the correlation matrix, and at that, some of your variables, DDY, for example, have no variation in the subsample (I haven't looked at any other cross-sections). But that's a data and conceptual issue, not an EViews one. The above program does what I believe you want to do...
Re: Principal Components Analysis
Posted: Thu Jan 29, 2009 2:59 pm
by Greentea
Thank you very much again for the kind message and such a patient explanation.
You’re absolutely right!! I really should remove all printing related commands since it’s too much to print.
However, when you mentioned “[The sample condition that you provided will result in exactly one observation being kept. Clearly you can't run a principal components procedure for one data point.]”, I know that I haven’t clearly explained what I want to do. In another word, once we [move the group definition outside of the loop][/quote]“”, it is not what I want Eviews to do for me anymore. It is because I need the group definition to change with both firms and years.
From my 1st post, [I’d like to1) run a principal components analysis for each firm in each year][/quote]“.” That means, for example, to use the 1st firm’s 22 accounting measures in year 1980 to run a principal component analysis. I think that the programme should look like:
group pc1stdif11980 DBOOKMV DCACL DCASHFLOWMV DCASHFLOWTA DCASHFLOWTLIABILITIES DCREDITORMV DCREDITORTA DDY DFIXATA DIGEAR DLTBORMV DLTBORRATIO DLTDEBTFA DOPINCOMMV DTAMV DSTDEBTFA DSALESTA DSALESMV DPMTA DPMMV DOPM DOPINCOMTA
I also need Eviews to repeat the process above for the 1st firm’s 22 accounting measures in year 1981. Such as:
group pc1stdif11981 DBOOKMV DCACL DCASHFLOWMV DCASHFLOWTA DCASHFLOWTLIABILITIES DCREDITORMV DCREDITORTA DDY DFIXATA DIGEAR DLTBORMV DLTBORRATIO DLTDEBTFA DOPINCOMMV DTAMV DSTDEBTFA DSALESTA DSALESMV DPMTA DPMMV DOPM DOPINCOMTA
After Eviews 1) show the results of the ordinary correlation, the eigenvalues and the eigenvectors, 2) display component scores for PC1, PC2, PC3, PC4 and PC5 for the 1st firm from principal component analysis from year 1980 to 2005. The programme which I wrote supposes to tell Eviews to run principal component analysis for the 2nd firm using the corresponded 22 accounting measures again. So:
group pc1stdif21980 DBOOKMV DCACL DCASHFLOWMV DCASHFLOWTA DCASHFLOWTLIABILITIES DCREDITORMV DCREDITORTA DDY DFIXATA DIGEAR DLTBORMV DLTBORRATIO DLTDEBTFA DOPINCOMMV DTAMV DSTDEBTFA DSALESTA DSALESMV DPMTA DPMMV DOPM DOPINCOMTA
It should start from year 1980 and finish with 2005. So on and so forth.
After all these, “[4) I’d also like to repeat the procedure above to run a principal component analysis for every firm during 1988-2005.”][/quote] It means that, instead of using 22 accounting measures in 1980, I ask Eviews to using the data during 1980-2005 for 1st firm. Again, save the results for the ordinary correlation, the eigenvalues, the eigenvectors and the component scores for PC1, PC2, PC3, PC4 and PC5. Then to repeat the process again, for the 2nd firm during 1988-2005, ect.
If I still haven’t made myself clear, please kindly drop me a line. Thank you very much!
Re: Principal Components Analysis
Posted: Thu Jan 29, 2009 5:23 pm
by EViews Glenn
I still don't understand what you are trying to do here...
However, when you mentioned “[The sample condition that you provided will result in exactly one observation being kept. Clearly you can't run a principal components procedure for one data point.]”, I know that I haven’t clearly explained what I want to do. In another word, once we [move the group definition outside of the loop]“”, it is not what I want Eviews to do for me anymore. It is because I need the group definition to change with both firms and years.
From my 1st post, [I’d like to1) run a principal components analysis for each firm in each year. That means, for example, to use the 1st firm’s 22 accounting measures in year 1980 to run a principal component analysis. I think that the programme should look like:
group pc1stdif11980 DBOOKMV DCACL DCASHFLOWMV DCASHFLOWTA DCASHFLOWTLIABILITIES DCREDITORMV DCREDITORTA DDY DFIXATA DIGEAR DLTBORMV DLTBORRATIO DLTDEBTFA DOPINCOMMV DTAMV DSTDEBTFA DSALESTA DSALESMV DPMTA DPMMV DOPM DOPINCOMTA
I also need Eviews to repeat the process above for the 1st firm’s 22 accounting measures in year 1981. Such as:
group pc1stdif11981 DBOOKMV DCACL DCASHFLOWMV DCASHFLOWTA DCASHFLOWTLIABILITIES DCREDITORMV DCREDITORTA DDY DFIXATA DIGEAR DLTBORMV DLTBORRATIO DLTDEBTFA DOPINCOMMV DTAMV DSTDEBTFA DSALESTA DSALESMV DPMTA DPMMV DOPM DOPINCOMTA
I note once again that the workfile in question is a panel workfile with roughly 22 series representing the accounting measures. There are 848 firms, each of which is observed annually from 1988 to 2005. This implies a couple of things about the lines above:
1. The groups PC1STDIF11980 and PC1STDIF11981 are identical. They contain the same series. Hence, the definition can be pulled out of the sample setting loop. Note that you do not have different
variables for each firm or period, which is what you would need in order for the group definition to be firm or period specific.
2. The first firm does have 22 accounting measures in year 1981, but there is only a single observation for each measure. Thus, it is impossible to
run a principal components analysis for each firm in each year
Furthermore,
3. Even if you extend the analysis to compute principal components for each firm using data *across* years, you will still have problems since there are insufficient data (4 obs, with some variables exhibiting no variation) for at least one firm.
4. If you'd like to compute the principal components across firms for a given year, that'll be a different story. I'd imagine that this would work.
Re: Principal Components Analysis
Posted: Thu Jan 29, 2009 6:27 pm
by Greentea
Thank you very much for the kind reply. I think by writing those group command above, I successfully confused you again.
For your 1st and 2nd point, I’m afraid that I don’t agree.
The programme needs to 1) select these 22 accounting measures for the 1st firm and for the 1st year and to run principal component analysis. For those data which I have in my workfile called local, the 1st firm does not have any data until 2002. So effectively, I’m expecting the programme give me NA for the ordinary correlation, the eigenvalues, the eigenvectors and the component scores for PC1, PC2, PC3, PC4 and PC5. On the other hand, the programme should be able to give me some results for those data in 2002.
That is, using these 22 accounting measures shown as below
DLTBORRATIO DLTBORMV DIGEAR DCASHFLOWTLIABILITIES …… DFIXATA
-0.011336122 -0.006894475 0.003607878 -3.922778687000001 …… -0.355705486
to run a principal component analysis and to get some results.
2) Then the programme should repeat the process above using data in 2003 for the 1st firm as:
DLTBORRATIO DLTBORMV DIGEAR DCASHFLOWTLIABILITIES …… DFIXATA
0.000000000 0.000000000 -0.006890846 3.909873737 …… -0.0163563
The programme finishes the 1st firm, it should move onto the 2nd firm.
“3. Even if you extend the analysis to compute principal components for each firm using data *across* years, you will still have problems since there are insufficient data (4 obs, with some variables exhibiting no variation) for at least one firm.”
For those firms where there is no variation in the data, I don’t believe it is the case for all the years for the same company. Even if it is for all the year, all I’m expecting are some NAs.
“4. If you'd like to compute the principal components across firms for a given year, that'll be a different story. I'd imagine that this would work.”
Instead of compute the principal components across firms for a given year, I’d also like to of compute the principal components across years for a given firm. This is what I meant in “ I’d also like to repeat the procedure above to run a principal component analysis for every firm during 1988-2005.”
Hope it is clear now. If not, please please let me know. Thank you!
Re: Principal Components Analysis (combine files)
Posted: Thu Jan 29, 2009 6:55 pm
by Greentea
Addtionally, after getting results for component scores in different Excel files, I also would like Eviews to combine the results and save the results into one Excel file. At this stage, I’m not really sure about what the component scores look like. However, I’d like to hypothetically demonstrate what do I mean by “combine the results and save the results into one Excel file”. Let’s say, the component scores for firm 1 in 2002 is:
PC1score PC2 score PC3score PC4score PC5score
1.2345 2.2345 3.2345 4.2345 5.2345
The component scores for firm 1 in 2003 is:
PC1score PC2 score PC3score PC4score PC5score
23.451 2. 4523 3.5234 5.3452 4. 4523
Therefore, the combined results should be:
PC1score PC2 score PC3score PC4score PC5score
1988 NA NA NA NA NA
1989 NA NA NA NA NA
1990 NA NA NA NA NA
1991 NA NA NA NA NA
1992 NA NA NA NA NA
… … …. … … …
. … …. … … …
. … …. … … …
.
2002 1.2345 2.2346 3.2345 4.2345 5.2345
2003 23.457 2.4523 3.5234 5.3452 4. 4523
Thank you very much!
Re: Principal Components Analysis
Posted: Fri Jan 30, 2009 10:23 am
by EViews Glenn
You write that you want to perform the following
The programme needs to 1) select these 22 accounting measures for the 1st firm and for the 1st year and to run principal component analysis. For those data which I have in my workfile called local, the 1st firm does not have any data until 2002. So effectively, I’m expecting the programme give me NA for the ordinary correlation, the eigenvalues, the eigenvectors and the component scores for PC1, PC2, PC3, PC4 and PC5. On the other hand, the programme should be able to give me some results for those data in 2002.
That is, using these 22 accounting measures shown as below
DLTBORRATIO DLTBORMV DIGEAR DCASHFLOWTLIABILITIES …… DFIXATA
-0.011336122 -0.006894475 0.003607878 -3.922778687000001 …… -0.355705486
to run a principal component analysis and to get some results.
I'm afraid that I don't know how to get EViews
or any other software package to perform principal components analysis on a single year (record) of data for your 22 measures, so I don't think I can be of much further assistance. As I've said before, the correlation matrix for these data are undefined for a single observation so that principal components based on correlations is impossible.
Perhaps someone else can step in and offer further assistance.
Re: Principal Components Analysis
Posted: Fri Jan 30, 2009 11:18 am
by Greentea
Thank you SO much for the kind reply. You’re absolutely right! I simply cannot run the principal component analysis for one firm in a single year!! I didn’t realize this until I tried one sample using my data today. So thank you so much for pointing this out for me and thank you for your patient!
So there is only one task left to do: how to perform principal component across years for a single firm, please?
I would like to assume that the programme should look like:
for !firm = 1 to 848
!yr = 1988 to 2005
group pc1stdif!firm!yr DBOOKMV DCACL DCASHFLOWMV DCASHFLOWTA DCASHFLOWTLIABILITIES DCREDITORMV DCREDITORTA DDY DFIXATA DIGEAR DLTBORMV DLTBORRATIO DLTDEBTFA DOPINCOMMV DTAMV DSTDEBTFA DSALESTA DSALESMV DPMTA DPMMV DOPM DOPINCOMTA
smpl if crossid = !firm
pc1stdif.pcomp(cor, eigval=v1, eigvec=m1) pc1 pc2 pc3 pc4 pc5
v1.write v1 {!firm!yr}.xls
m1.write m_1{!firm!yr}.xls
group comps pc1 pc2 pc3 pc4 pc5
write comps_{!firm!yr}.xls comps
next
Thank you so much for the reply.
You’re absolutely right! I simply cannot run the principal component analysis for one firm in a single year!! I didn’t realize this until I tried one sample using my data today. So thank you so much for pointing this out for me and thank you for your patient!
So there is only one task left to do: how to perform principal component across years for a single firm, please?
I would like to assume that the programme should look like:
for !firm = 1 to 848
!yr = 1988 to 2005
group pc1stdif!firm!yr DBOOKMV DCACL DCASHFLOWMV DCASHFLOWTA DCASHFLOWTLIABILITIES DCREDITORMV DCREDITORTA DDY DFIXATA DIGEAR DLTBORMV DLTBORRATIO DLTDEBTFA DOPINCOMMV DTAMV DSTDEBTFA DSALESTA DSALESMV DPMTA DPMMV DOPM DOPINCOMTA
smpl if crossid = !firm
pc1stdif.pcomp(cor, eigval=v1, eigvec=m1) pc1 pc2 pc3 pc4 pc5
v1.write v1 {!firm!yr}.xls
m1.write m_1{!firm!yr}.xls
group comps pc1 pc2 pc3 pc4 pc5
write comps_{!firm!yr}.xls comps
print comps
next
However, when I run this programme, the error message says that !yr is not defined or is an illegal command in !yr=1988 to 2005. Could you help me to correct this please? Thank you very much!
Re: Principal Components Analysis
Posted: Fri Jan 30, 2009 11:41 am
by EViews Glenn
The post I wrote yesterday does the pcomp for a each firm across all years. As I mentioned then, you are still going to have trouble since for some cross-sections, you have very little data (e.g., firm 1 only had 4 usable observations, with some variables having zero variance to boot).
And once again, the !yr in your program irrelevant, and the group definition can be outside the loop since it doesn't change.
Re: Principal Components Analysis
Posted: Fri Jan 30, 2009 12:26 pm
by Greentea
I’ve tried the programme you wrote yesterday.
group pc1stdif DBOOKMV DCACL DCASHFLOWMV DCASHFLOWTA DCASHFLOWTLIABILITIES DCREDITORMV DCREDITORTA DDY DFIXATA DIGEAR DLTBORMV DLTBORRATIO DLTDEBTFA DOPINCOMMV DTAMV DSTDEBTFA DSALESTA DSALESMV DPMTA DPMMV DOPM DOPINCOMTA
for !firm=1 to 848
smpl if crossid = !firm
pc1stdif.pcomp(cor, eigval=v1, eigvec=m1) pc1 pc2 pc3 pc4 pc5
v1.write v1 {!firm}.xls
m1.write m_1{!firm}.xls
group comps pc1 pc2 pc3 pc4 pc5
write comps_{!firm}.xls comps
next
Just as you predicted, there is a error message saying “missing value found in covariance/correlation matrix in “DOPC1STDIF.PCOMP(COR, EIGVAL=V1, EIGVEC=M1) PC1 PC2 PC3 PC4 PC5”. Is there any possibility to ask Eviews to skip this (or give a NA) and to proceed, please? Thank you as always!
Furthermore, I have computed the principal components across firms for a given year for me as below.
group pc1stdif DBOOKMV DCACL DCASHFLOWMV DCASHFLOWTA DCASHFLOWTLIABILITIES DCREDITORMV DCREDITORTA DDY DFIXATA DIGEAR DLTBORMV DLTBORRATIO DLTDEBTFA DOPINCOMMV DTAMV DSTDEBTFA DSALESTA DSALESMV DPMTA DPMMV DOPM DOPINCOMTA
for !yr=1988 to 2005
smpl if year = !yr
pc1stdif.pcomp(cor, eigval=v1, eigvec=m1) pc1 pc2 pc3 pc4 pc5
v1.write v1 {!yr}.xls
m1.write m_1{!yr}.xls
group comps pc1 pc2 pc3 pc4 pc5
write comps_{!yr}.xls comps
next
It worked just as you predicted!! You’re a genius!!
Re: Principal Components Analysis
Posted: Fri Jan 30, 2009 12:37 pm
by EViews Gareth
You’re a genius!!
Steady on, it'll go to his head....I have to work with him!