Thursday, April 4, 2013

Principal Component analysis in Excel using Rexcel

See the related posts on RExcel (for basicExcel 2003 and Excel 2007) for basic information. In these posts we have discussed how we can install and operate in Rexcel (R integrated within Excel)- there is no need for any scripting skills, it is menu driven ! 

Here is data, we want to load it to R data, putting to R dataframe. See the above mentioned posts for details.


After creating dataset, under statistics menu, select dimension analysis find "principal component analysis". Then the following box will appear where we need to add variables need to be analysis, highlight them by clicking them. We might want to see screeplot and we want to add principal component to data set so that we can plot it later. If we checked this box, it will show a box where we can specify how many components we want to retain.







The output also plotted in output window. You can copy and paste in text editor and load it in excel too. Other way would get it from R dataset, by put data to sheet. The scree plot will appear in R graphical device. 
  
We can also plot the pricipal components (usually PC1 and PC2 or 3D - PC1, PC2, and PC3). Plot scatter plot between components, go to graphs then to scatter plot matrix. Let's say we are interested in plotting PC1, PC2, PC3 and PC4. 





We might want to plot 3D scatter plot for first three components, go to graphs and then 3D graphs, then 3D scatter plot. Then select the PC variables to plot:





For plotting from Excel read my another blog: 





No comments:

Post a Comment

Note: Only a member of this blog may post a comment.