Replies: 3 comments
-
> m <- rda(varechem)
> zapsmall(colSums(m$Ybar^2))
N P K Ca Mg S Al Fe
30.56 223.39 4204.53 59332.17 1681.93 136.14 14962.28 3654.07
Mn Zn Mo Baresoil Humdepth pH
1149.98 8.90 0.06 270.26 0.44 0.05
> zapsmall(apply(varechem, 2, var))
N P K Ca Mg S Al Fe
30.56 223.39 4204.53 59332.17 1681.93 136.14 14962.28 3654.07
Mn Zn Mo Baresoil Humdepth pH
1149.98 8.90 0.06 270.26 0.44 0.05
> m1 <- rda(varechem, scale=TRUE)
> colSums(m1$Ybar^2)
N P K Ca Mg S Al Fe
1 1 1 1 1 1 1 1
Mn Zn Mo Baresoil Humdepth pH
1 1 1 1 1 1
> head(m$Ybar/m1$Ybar, 3)
N P K Ca Mg S Al Fe
18 5.528084 14.9464 64.84236 243.582 41.01134 11.66783 122.3204 60.4489
15 5.528084 14.9464 64.84236 243.582 41.01134 11.66783 122.3204 60.4489
24 5.528084 14.9464 64.84236 243.582 41.01134 11.66783 122.3204 60.4489
Mn Zn Mo Baresoil Humdepth pH
18 33.91134 2.983939 0.2399804 16.43944 NaN 0.2140026
15 33.91134 2.983939 0.2399804 16.43944 NaN 0.2140026
24 33.91134 2.983939 0.2399804 16.43944 0.6646346 0.2140026
> all.equal(crossprod(m$Ybar), cov(varechem))
[1] TRUE
> all.equal(crossprod(m1$Ybar), cor(varechem))
[1] TRUE |
Beta Was this translation helpful? Give feedback.
-
Thanks a lot! It is now clearer: Using
all those values are the square root the variances of each variables (so,the sd). I have a follow up question. As I understand, the next step in |
Beta Was this translation helpful? Give feedback.
-
You need to use scaling if the variables are not measured in same units. The Compare > biplot(rda(varechem), dis="sp")
> biplot(rda(varechem, scale=TRUE), dis="sp") Or for community data: > biplot(rda(varespec), dis="sp")
> biplot(rda(varespec, scale=TRUE), dis="sp") |
Beta Was this translation helpful? Give feedback.
-
For really long I thought that the argument of
scale=T
inrda
was doing z scaling:(xi-mean(x))/sd(x)
prior to pca calcuations . However, recently (after reading about how pca is calculating uisingrda
) I found that z scaling is always calcuated (even whenscale=F
). For example, using varechem:example<-rda(varechem)
The z-scaled values are already calculated:
that is TRUE
(Side note: I stil do not know why the number are not identical and there is some scaling factor, here being 0.8675)
Now, if I run:
example2<-rda(varechem,scale=T)
The scaled values are different as in example1. They were just "re-scaled" (in this case by 0.1808945)
example2$Ybar[,1]/example$Ybar[,1]
In the documentation it says that the argument scale "Scale species to unit variance (like correlations)". So my main questions are: what variance exactly? the total variance of all the data? how is this calculated? And why is this necessary since all the data is z-scaled already to units of standard deviation?
Thanks for all the support!
Beta Was this translation helpful? Give feedback.
All reactions