Created
March 31, 2018 17:00
-
-
Save willtownes/a0ff36c1fdac563550bb56942ad94ad2 to your computer and use it in GitHub Desktop.
Compositional Data Transformations
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#compositional analysis | |
library(compositions) | |
x<-c(.1,.5,.4) | |
V<-t(ilrBase(x)) | |
D<-rbind(c(1,0,-1),c(0,1,-1)) | |
x_alr<-D%*%log(x) | |
x_ilr<-V%*%log(x) | |
x_alr | |
alr(x) | |
x_ilr | |
ilr(x,t(V)) | |
#matrix to convert ilr to alr directly | |
A<-D%*%t(V) | |
#is A invertible? | |
det(A) #should be nonzero | |
x_alr2<-A%*%x_ilr |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment