On Mon, 6 Dec 2021, francesco.delledonne(a)unicredit.eu wrote:
Thanks Riccardo,
I can nevertheless see that the "byhand" calculation is consistent with
theory.
By running your script i get the following:
PC1 PC2 fac1 fac2
1 -2.709256 0.285568 -854.063 -0.26550
2 -2.066726 0.463805 -662.994 -2.01606
3 -1.980962 0.517025 -616.468 -2.60151
[...]
It's possible your gretl version desn't have the latest behavior for
cdemean(). You could try this variant:
open data4-1.gdt
list X = price sqft bedrms baths
# native
pca X --save=2
# by hand
list SX = stdize(X)
matrix Z = {SX}
matrix evec = {}
lambda = eigensym(Z'Z, &evec)
series fac1 = Z * evec[,4]
series fac2 = Z * evec[,3]
print PC1 PC2 fac1 fac2 --byobs
fac1 and fac2 should be identical to PC1 and PC2.
Allin Cottrell