Dear Allin, Sven, and Yiannis,
At first I would like to thank you all :-)
Em 23 de agosto de 2017, Allin escreveu:
> On Wed, 23 Aug 2017, Henrique Andrade wrote:
>
>> 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.
>
>
> The "component loadings" are eigenvectors of the relevant matrix
> (correlation or covariance) and eigenvectors are unique only up to an
> arbitrary (non-zero) real constant. In this case the loadings for PC1, PC6
> and PC7 as produced by "pca" and by your eigengen procedure differ by a
> factor of -1. It can be shown that when they're multiplied into the
> component series they produce series that again just differ by a constant.
>
> Try this script:
>
> <hansl>
> set verbose off
> open AWM.gdt --quiet
> list L = CAN COMPR EEN FDD HICP ITN KSR
> smpl ok(L) --restrict
>
> pca L --save-all --quiet
>
> matrix X = {L}
> matrix E = {}
> eigengen(mcorr(X), &E)
>
> matrix stdX = (X .- meanc(X)) ./ sdc(X,1)
> list stdL = null
> loop i=1..cols(X) --quiet
> stdL += genseries(sprintf("stdx_%d", i), stdX[,i])
> endloop
>
> list altPCs = null
> loop i = 1..cols(E) --quiet
> altPCs += genseries(sprintf("altPC%d", i), lincomb(stdL, E[,i]))
> endloop
>
> ols PC1 0 altPC1 --simple-print
> ols PC6 0 altPC6 --simple-print
> ols PC7 0 altPC7 --simple-print
> </hansl>
>
Dear Allin, I got your point, thanks! But one (big) question remains
on my mind: How "pca" command knows that it "has to" multiply the
loadings by -1?
Best,
Henrique Andrade