For my statistical analysis I want to follow the steps of a paper I read.
I have a dataset in which each row corresponds to a dive carried out by a whale ('id' in table below) and the columns to the variables calculated for each dive (maximum depth, duration, speed, etc.).
id max_depths duration pd_times d_rate a_rate bottom_dur bottom_prop
1 57 166 41 0.5288462 0.9152542 2 1.204819
2 26 165 43 0.2688172 0.3333333 2 1.212121
3 18 140 90 0.1911765 0.3500000 31 22.142857
4 23 88 141 0.3437500 0.5625000 23 26.136364
5 51 177 47 0.5384615 0.6849315 77 43.502825
6 19 170 394 0.2631579 0.2400000 62 36.470588
My goal is to carry out an hierarchical cluster analysis to see if I can find different dive types.
I want to start by:
- Performing a PCA using the 'stats' package in R (function prcomp() or princomp()) to reduce multicollinearity and the dimensionality of the data.
- After this, using the combined principal components that explain at least 80-85% of the variance, I want to calculate the dissimilarity structure using vegdist() of the 'vegan' package and then
- Use hclust() to perform the actual clustering analysis.
However, I am unsure on how to use the principal components as input in step 2.
Using prcomp() to compute the PCA I get the following output:
List of 5
$ sdev : num [1:11] 2.055 1.679 1.126 1.009 0.946 ...
$ rotation: num [1:11, 1:11] 0.3101 0.3492 0.0284 0.0371 0.1052 ...
..- attr(*, "dimnames")=List of 2
.. ..$ : chr [1:11] "max_depths" "duration" "pd_times" "d_rate" ...
.. ..$ : chr [1:11] "PC1" "PC2" "PC3" "PC4" ...
$ center : Named num [1:11] 66.633 244.131 213.088 0.906 0.811 ...
..- attr(*, "names")= chr [1:11] "max_depths" "duration" "pd_times" "d_rate" ...
$ scale : Named num [1:11] 47.291 140.131 1089.682 0.488 0.494 ...
..- attr(*, "names")= chr [1:11] "max_depths" "duration" "pd_times" "d_rate" ...
$ x : num [1:2654, 1:11] -1.909 -2.45 -2.182 -1.858 0.145 ...
..- attr(*, "dimnames")=List of 2
.. ..$ : chr [1:2654] "1" "2" "3" "4" ...
.. ..$ : chr [1:11] "PC1" "PC2" "PC3" "PC4" ...
- attr(*, "class")= chr "prcomp"
What should I use as input in step 2 (dissimilarity structure) and why? $rotation
(variable loadings)? $x
(principal components of interest)?
Thanks in advance!!