Dear Gretl Community,
I would like to replicate the "pca" command using "eigengen" function
but I can't replicate the "signs behavior" of the component loadings.
Sorry if this is a very newbie/dummy question, but I really don't
understand the signal inversion in PC1 PC6 and PC7. Please take a look
at my code:
<hansl>
set echo off
set messages off
open AWM.gdt --quiet
list L = CAN COMPR EEN FDD HICP ITN KSR
printf "\n########## Gretl's native PCA ##########\n\n"
pca L
printf "\n########## Alternative PCA (using 'eigengen' function) ##########\n\n"
matrix X = {L}
matrix C = mcorr(X)
matrix Eigenvector = {}
matrix Eigenvalue = eigengen(C, &Eigenvector)
matrix Proportion = zeros(rows(Eigenvalue), 1)
matrix Cumulative = zeros(rows(Eigenvalue), 1)
loop i = 1..rows(Eigenvalue) --quiet
Proportion[i, 1] = Eigenvalue[i, 1]/sumc(Eigenvalue)
Cumulative[i, 1] = sumc(Proportion[1:i])
endloop
matrix Eigenvalue = Eigenvalue ~ Proportion ~ Cumulative
rownames(Eigenvalue, "1 2 3 4 5 6 7")
colnames(Eigenvalue, "Eigenvalue Proportion Cumulative")
rownames(Eigenvector, "CAN COMPR EEN FDD HICP ITN KSR")
colnames(Eigenvector, "PC1 PC2 PC3 PC4 PC5 PC6 PC7")
printf "Principal Components Analysis\nn = %d\n\n", rows(X)
printf "Eigenanalysis of the Correlation Matrix\n\n"
printf "%15.4f\n", Eigenvalue
printf "Eigenvectors (component loadings)\n\n"
printf "%10.3f\n", Eigenvector
</hansl>
Best regards,
Henrique Andrade
_______________________________________________
Gretl-users mailing list
Gretl-users@lists.wfu.edu
http://lists.wfu.edu/mailman/listinfo/gretl-users