-
Notifications
You must be signed in to change notification settings - Fork 24
/
Numerical Ecology Chapter 9.Rpres
79 lines (60 loc) · 2.01 KB
/
Numerical Ecology Chapter 9.Rpres
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
Numerical Ecology Chapter 9
========================================================
author: Joey Bernhardt
date: January 31 2016
Plan for today
========================================================
- PCA
- PCoA
- NMDS
- Correspondence analysis
Goals of ordination
========================================================
- represent the data along a reduced number of orthogonal axes, constructed in such a way that they represent, in decreasing order, the main trends of the data
Ordination
========================================================
- Imagine an n × p data set containing n objects and p variables
PCA
========================================================
- The first principal axis (or principal-component axis) of a PCA of this data set is the line that goes through the greatest dimension of the concentration ellipsoid describing this multinormal distribution
- objects are represented as points and variables are displayed as arrows
Prepare the data
========================================================
```{r}
# Load the required packages
# (vegan must be loaded after ade4 to avoid some conflicts)
library(ade4)
library(vegan)
library(gclus)
library(ape)
# Load additional functions
# (files must be in the working directory)
source("evplot.R")
source("cleanplot.pca.R")
source("PCA.R")
source("CA.R")
```
PCA on the environmental dataset
========================================================
```{r}
# Import the data from CSV files
# (files must be in the working directory)
spe <- read.csv("DoubsSpe.csv", row.names=1)
env <- read.csv("DoubsEnv.csv", row.names=1)
spa <- read.csv("DoubsSpa.csv", row.names=1)
# Remove empty site 8
spe <- spe[-8,]
env <- env[-8,]
spa <- spa[-8,]
# PCA based on a correlation matrix
# Argument scale=TRUE calls for a standardization of the variables
env.pca <- rda(env, scale=TRUE)
env.pca
summary(env.pca) # Default scaling 2
summary(env.pca, scaling=1)
```
Slide With Plot
========================================================
```{r, echo=FALSE}
plot(cars)
```