-
Notifications
You must be signed in to change notification settings - Fork 0
/
maxent.Rmd
86 lines (50 loc) · 1.8 KB
/
maxent.Rmd
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
80
81
82
83
84
85
86
---
title: "maxent"
author: "zjz"
date: "`r Sys.Date()`"
output: html_notebook
---
## 环境配置
- R41=4-1-3
- RStudio-daily
```{r message=FALSE, include=FALSE}
library(raster)
library(sp)
library(rgdal)
library(rmarkdown)
```
## Method
先对30多个变量进行相关性分析,再从中选取具有生态学意义的变量。
- 如果先从生态学意义上进行选取,再考虑相关性,那么势必会剔除掉部分具有生态学意义的变量。
- 如先相关性分析,再考虑生态学意义,那么最终选取的变量则既相互独立、且具有生态学意义。
## Correlation Analysis
Pearson相关系数:对定距连续变量的数据进行计算。
1. 如果x,y变化的方向一致,r\>0;
- \|r\|\>0.95 存在显著性相关;
- \|r\|≥0.8 高度相关;
- 0.5≤\|r\|\<0.8 中度相关;
- 0.3≤\|r\|\<0.5 低度相关;
- \|r\|\<0.3 关系极弱,认为不相关;
2. 负相关:y变化与x方向相反,\|r\|\<0;
3. 如果x和y是函数关系,则\|r\|=1,否则-1\<r\<1,x和y为统计关系。
```{r}
# 设置文件路径
dir = "D://Data//GISData//Maxent//InputData//z1"
files <- list.files(path=dir,pattern = "*.asc",full.names = TRUE,recursive = FALSE, ignore.case = FALSE)
# 遍历文件列表并读取为rasterlayer
alllayer <- lapply(files,function(x)raster(paste(x)))
# 将rasterlayer 转为rasterstack
layers <- stack(alllayer, bands=NULL, native=FALSE, RAT=TRUE)
# 统计rasterstack的pearson系数
p <- layerStats(layers,'pearson',asSample=TRUE, na.rm=TRUE)
print(p$`pearson correlation coefficient`)
```
## Chose varibles
```{r}
# todo
```
## Maxent
```{}
# todo
```
## Parameters Optimization