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

getPCscores fails with sizeshape=TRUE #21

Open
daskandalis opened this issue Dec 13, 2020 · 1 comment
Open

getPCscores fails with sizeshape=TRUE #21

daskandalis opened this issue Dec 13, 2020 · 1 comment

Comments

@daskandalis
Copy link

Expected behaviour: Expected PC scores from aligned data, but this fails when sizeshape=TRUE.

library(Morpho)
data(boneData)
proc <- procSym(boneLM[,,-c(1:2)], sizeshape=TRUE)
newdata <- boneLM[,,c(1:2)]
newdataAlign <- align2procSym(proc,newdata)
scores <- getPCscores(newdataAlign,proc$PCs,proc$mshape)
@zarquon42b
Copy link
Owner

Hi,
sorry for my very very belated answer. If you select sizeshape=T, then the first entry in the PC-scores captures the variability of the log transformed CS. In that case you will need to process the logCS separately:
usinig your example, you can do this like:

x <- newdataAlign
x <- sweep(x,1:2,proc$mshape)
size <- log(apply(newdata,3,cSize))
meanLogCS <- mean(log(proc$size))
size <- size-meanLogCS
x <- vecx(x)
x <- cbind(size,x)
scores <- x%*%(proc$PCs)

You will get some distortions though because the scaling in full PCA is based on a sample wide optimization of size. When you do this post-hoc, your results can deviate (slightly).

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

No branches or pull requests

2 participants