-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathenfa.R
48 lines (32 loc) · 1.05 KB
/
enfa.R
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
library (adehabitatHS)
##### necesitamos un dataframe con los datos del clima, tab
#### y un vector de 0/1 con la presencia, pr
## We then perform the PCA before the ENFA
pc <- dudi.pca(tab, scannf = FALSE)
## The object 'pc' contains the transformed table (i.e.
## centered so that all columns have a mean of 0
## and scaled so that all columns have a variance of 1
## 'pc' also contains the weights of the habitat variables,
## and the weights of the pixels in the analysis
(enfa1 <- enfa(pc, pr,
scannf = FALSE))
hist(enfa1)
hist(enfa1, scores = FALSE, type = "l")
## scatterplot
scatter(enfa1)
## randomization test
## Not run:
(renfa <- randtest(enfa1))
plot(renfa)
#### ahora, para predecir,
### necesito que las variables estén en SpatialPixelDataFrame, map
data(meuse.grid)
head (meuse.grid)
map<- SpatialPixelsDataFrame(points = meuse.grid[c("x", "y")],
data = meuse.grid)
predict.enfa (enfa1, map)
pred <- predict(enfa1, map)
image(pred)
points(locs, pch = 16, cex=0.2)
??SpatialPixelDataFrame
?madifa