Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unexplained behaviour with prinComp and grid2PCs #15

Open
matteodefelice opened this issue Nov 25, 2017 · 1 comment
Open

Unexplained behaviour with prinComp and grid2PCs #15

matteodefelice opened this issue Nov 25, 2017 · 1 comment
Labels

Comments

@matteodefelice
Copy link
Contributor

Hi,
I was planning to use prinComp and grid2PCs to implement a sort of cross-validation for the use of PCA with seasonal forecasts.
Here the grid test file I have used: https://www.dropbox.com/s/a699e6wq4zae0vm/monthly-erain.rda?dl=0

Here a reproducible example:

rm(list = ls())
library(transformeR)
load(file = 'monthly-erain.rda')
orig_princomp <- prinComp(obs, 4)
get_pc <- PC2grid(orig_princomp)

# reapply on the same grid
reapplied_princomp = grid2PCs(orig_princomp, obs)
# compare PCs
plot(reapplied_princomp[[1]][,1] ~ get_pc$Data[1,,1,1])

If I use grid2PCs on the same grid file used to compute the prinComp I would expect to have the same identical PCs, am I wrong? Instead they are similar but not identical, what happens here?

@jbedia
Copy link
Member

jbedia commented Feb 23, 2018

Because you are retaining the first 4 EOFs, you are not capturing the whole variance, but just a large proportion of it. Therefore, when you recover the original field from the PCs, the recovered field is not identical to the original one (it is very similar though...). Try to set the explained variance to 100% and you should obtain exactly the same grid (setting aside minor rounding errors...):

orig_princomp <- prinComp(obs, v.exp = 1)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants