多元回歸樹(Multivariate Regression Trees,MRT)是單元回歸樹的拓展,是一種對(duì)一系列連續(xù)型變量遞歸劃分成多個(gè)類群的聚類方法,是在決策樹(decision-trees)基礎(chǔ)上發(fā)展起來的一種較新的分類技術(shù)。其目的是在定量或分類解釋變量的控制下遞歸劃分一個(gè)定量變量。這樣的分類方式有時(shí)也稱為約束聚類或者導(dǎo)向聚類。同一般回歸模型一樣,MRT也需要因變量(響應(yīng)變量,群落學(xué)中一般是物種數(shù)據(jù))和自變量(預(yù)測(cè)變量,一般為環(huán)境因子數(shù)據(jù))。不同的是, MRT不需要在響應(yīng)變量和預(yù)測(cè)變量之間建立參數(shù)估計(jì)的回歸關(guān)系而是以預(yù)測(cè)變量為分類節(jié)點(diǎn),利用二歧式的分割法(binary split), 將由響應(yīng)變量定義的空間(樣方)逐步劃分為盡可能同質(zhì)的類別,每一次劃分都由某一預(yù)測(cè)變量(環(huán)境因子)的一個(gè)最佳劃分值來完成, 將響應(yīng)變量定義的空間(樣方)分成兩個(gè)部分(也叫節(jié)點(diǎn), node),最佳劃分原則是讓兩個(gè)節(jié)點(diǎn)內(nèi)部的差異盡量小,節(jié)點(diǎn)間的差異盡量大。
MRT是一種強(qiáng)大而可靠的分類方法,即使被劃分的變量含有缺失值,或者響應(yīng)變量與解釋變量是非線性關(guān)系,或解釋變量之間存在高階相互關(guān)系,經(jīng)過交叉驗(yàn)證等一系列篩選過程,多元回歸樹都能夠發(fā)揮很好的預(yù)測(cè)作用。
MRT的計(jì)算有兩個(gè)一起運(yùn)行的程序組成:A數(shù)據(jù)約束劃分;B分組結(jié)果交叉驗(yàn)證。
mvpart程序包中MRT的運(yùn)算流程
- 將數(shù)據(jù)隨機(jī)劃分成k組(默認(rèn)為10組,xval=10)。
- 從k組中隨機(jī)選取一組作為“驗(yàn)證組”(testing set),剩余k-1組(訓(xùn)練組,training set)重現(xiàn)混合后通過約束分析,按照組內(nèi)平方和最小的原則,建立回歸樹。
- 將以上過程重復(fù)k-1次,即依次剔除一組數(shù)據(jù)。
- 共產(chǎn)生k個(gè)回歸樹,對(duì)于每個(gè)回歸樹的不同分類方案,將驗(yàn)證組(一組數(shù)據(jù))內(nèi)的對(duì)象分配到分組結(jié)果中。計(jì)算每個(gè)回歸樹分類方案的CVRE。
- 對(duì)回歸樹進(jìn)行剪枝:可以保留CVRE最小的分類方案。也可以根據(jù)“1SE”準(zhǔn)則,保留CVRE在最小的CVRE加1個(gè)標(biāo)準(zhǔn)差范圍內(nèi)最小的分類方案。
- 為了獲得上面運(yùn)行過程的誤差估計(jì)值,需要重復(fù)多次(100次或500次)將對(duì)象隨機(jī)分配為k組。
- 置換檢驗(yàn)保留具有最小CVRE誤差(或者是1SE值最小,此法最常用)的回歸樹。
# 加載所需的程序包
library(ade4)
library(vegan) # 應(yīng)該先加載ade4后加載vegan以避免沖突
library(gclus)
library(cluster)
library(RColorBrewer)
library(labdsv)
library(mvpart)
library(MVPARTwrap) # MVPARTwrap這個(gè)程序包必須從本地zip文件安裝
# 導(dǎo)入CSV格式的數(shù)據(jù)
rm(list = ls())
setwd("D:\\Users\\Administrator\\Desktop\\RStudio\\數(shù)量生態(tài)學(xué)\\DATA")
spe <- read.csv("DoubsSpe.csv", row.names=1)
env <- read.csv("DoubsEnv.csv", row.names=1)
spa <- read.csv("DoubsSpa.csv", row.names=1)
# 刪除無物種數(shù)據(jù)的樣方8
spe <- spe[-8,]
env <- env[-8,]
spa <- spa[-8,]
# 物種多度數(shù)據(jù):先計(jì)算樣方之間的弦距離矩陣,然后進(jìn)行單連接聚合聚類
# **************************************************************
spe.norm <- decostand(spe, "normalize")
spe.ch <- vegdist(spe.norm, "euc")
spe.ch.single <- hclust(spe.ch, method="single")
mvpart程序包從CRAN上下架了,感謝賴江山老師提供的Windows版安裝包。我試了一下在3.4.0上安裝成功了,本文也是基于這個(gè)版本來做的。
library(mvpart) # 載入mvpart程序包
spe.ch.mvpart <- mvpart(data.matrix(spe.norm) ~ ., env, margin=0.08, cp=0,
xv="pick", xval=nrow(spe), xvmult=100, which=4)
X-Val rep : 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 87 88 89 90 91 92 93 94 95 96 97 98 99 100
Minimum tree sizes
tabmins
2 3 4 6 7 8 9 10 11
5 9 8 1 21 17 10 23 6
參數(shù)xv="pick"允許通過人機(jī)交互的方式選擇所需要的分類分組。如果自動(dòng)選擇具有最小CVRE值的回歸樹,可以設(shè)定xv="min"。
下面是嘗試的選擇分為4組回歸樹結(jié)果。
回歸樹特征描寫:
- 每個(gè)節(jié)點(diǎn)通過一個(gè)解釋變量劃分。例如第一個(gè)節(jié)點(diǎn)被海拔劃分為含有13和16個(gè)樣方的兩組。分割點(diǎn)(海拔340m)在原始數(shù)據(jù)中的比值,它是分割點(diǎn)左右兩個(gè)樣方的平均值。如果其他變量也能產(chǎn)生相同的分組,也可以選擇其他變量進(jìn)行分組。
- 每片葉子(終端)都顯示所含樣方的數(shù)量和RE,并顯示該組內(nèi)物種多度分布情況的條形圖(物種排列順序按照響應(yīng)變量矩陣內(nèi)的列變量順序排序)
- 對(duì)于一個(gè)新的觀測(cè)樣方,可以根據(jù)其環(huán)境變量相應(yīng)的值和回歸樹,將新樣方直接分配到某一組。樣方不斷分組的過程中一個(gè)環(huán)境變量也可以多次使用。
> summary(spe.ch.mvpart)
Call:
mvpart(form = data.matrix(spe.norm) ~ ., data = env, xv = "pick",
xval = nrow(spe), xvmult = 100, margin = 0.08, which = 4,
cp = 0)
n= 29
CP nsplit rel error xerror xstd
1 0.44820889 0 1.0000000 1.0758371 0.05827462
2 0.09506051 1 0.5517911 0.7332388 0.11169179
3 0.08626143 2 0.4567306 0.7165753 0.10479606
4 0.04889908 3 0.3704692 0.7021106 0.10280365
Node number 1: 29 observations, complexity param=0.4482089
Means=0.05571,0.2515,0.27,0.2729,0.05579,0.06116,0.04772,0.07049,0.1295,0.1958,0.1094,0.06915,0.1578,0.1098,0.09459,0.07749,0.07079,0.05359,0.057,0.1183,0.05701,0.03674,0.09898,0.1923,0.07156,0.1933,0.06187, Summed MSE=0.5256098
left son=2 (16 obs) right son=3 (13 obs)
Primary splits:
alt < 340 to the right, improve=0.4482089, (0 missing)
das < 204.75 to the left, improve=0.4482089, (0 missing)
deb < 24.65 to the left, improve=0.4482089, (0 missing)
amm < 0.06 to the left, improve=0.3825997, (0 missing)
oxy < 9.55 to the right, improve=0.3619088, (0 missing)
Node number 2: 16 observations, complexity param=0.08626143
Means=0.09453,0.4461,0.441,0.4128,0.09132,0.09554,0.005803,0.04497,0.1255,0.17,0.04618,0.02865,0.07062,0.06948,0.06199,0.005803,0.01124,0.01141,0.01124,0.06578,0,0,0,0.08812,0,0.01161,0.005803, Summed MSE=0.3337866
left son=4 (13 obs) right son=5 (3 obs)
Primary splits:
amm < 0.11 to the left, improve=0.2462006, (0 missing)
dbo < 4.05 to the left, improve=0.2423770, (0 missing)
oxy < 10.25 to the right, improve=0.2423770, (0 missing)
pho < 0.15 to the left, improve=0.1819782, (0 missing)
nit < 0.51 to the left, improve=0.1785430, (0 missing)
Node number 3: 13 observations, complexity param=0.09506051
Means=0.007934,0.01205,0.05962,0.1008,0.01205,0.01885,0.09931,0.1019,0.1345,0.2275,0.1871,0.119,0.2651,0.1593,0.1347,0.1657,0.1441,0.1055,0.1133,0.1829,0.1272,0.08196,0.2208,0.3205,0.1596,0.4168,0.1309, Summed MSE=0.2361686
left son=6 (3 obs) right son=7 (10 obs)
Primary splits:
amm < 0.45 to the right, improve=0.4719501, (0 missing)
dbo < 10.6 to the right, improve=0.4719501, (0 missing)
pho < 1.07 to the right, improve=0.3942148, (0 missing)
oxy < 6.75 to the left, improve=0.3942148, (0 missing)
das < 236.15 to the right, improve=0.2239291, (0 missing)
Node number 4: 13 observations
Means=0.1092,0.5207,0.4824,0.4334,0.1053,0.1033,0,0.02678,0.09794,0.1276,0.03541,0.006695,0.06573,0.05029,0.03392,0,0.006695,0,0.006695,0.04208,0,0,0,0.01639,0,0,0, Summed MSE=0.2366276
Node number 5: 3 observations
Means=0.03095,0.1228,0.2613,0.3233,0.03095,0.0619,0.03095,0.1238,0.245,0.3539,0.09285,0.1238,0.09181,0.1527,0.1836,0.03095,0.03095,0.06086,0.03095,0.1685,0,0,0,0.3989,0,0.0619,0.03095, Summed MSE=0.3165241
Node number 6: 3 observations
Means=0,0,0,0,0,0,0.05206,0,0.07647,0.3167,0,0,0.205,0.07647,0,0,0.05206,0.07647,0,0,0,0,0.1806,0.3167,0.05206,0.7619,0, Summed MSE=0.1186808
Node number 7: 10 observations
Means=0.01031,0.01567,0.07751,0.131,0.01567,0.02451,0.1135,0.1325,0.1519,0.2007,0.2432,0.1547,0.2831,0.1842,0.1751,0.2154,0.1717,0.1142,0.1473,0.2378,0.1653,0.1065,0.2329,0.3217,0.1919,0.3133,0.1701, Summed MSE=0.1265172
> printcp(spe.ch.mvpart)
mvpart(form = data.matrix(spe.norm) ~ ., data = env, xv = "pick",
xval = nrow(spe), xvmult = 100, margin = 0.08, which = 4,
cp = 0)
Variables actually used in tree construction:
[1] alt amm
Root node error: 15.243/29 = 0.52561
n= 29
CP nsplit rel error xerror xstd
1 0.448209 0 1.00000 1.07584 0.058275
2 0.095061 1 0.55179 0.73324 0.111692
3 0.086261 2 0.45673 0.71658 0.104796
4 0.048899 3 0.37047 0.70211 0.102804
# MRT的殘差
par(mfrow=c(1,2))
hist(residuals(spe.ch.mvpart), col="grey")
plot(predict(spe.ch.mvpart), residuals(spe.ch.mvpart)[,2],
main="Residuals vs Predicted")
abline(h=0, lty=3, col="grey")
> # 組的組成
> spe.ch.mvpart$where
[1] 3 3 3 3 4 3 3 4 3 3 3 3 3 3 3 4 7 7 7 7 7 6 6 6 7 7 7 7 7
> spe.ch.mvpart$where
[1] 3 3 3 3 4 3 3 4 3 3 3 3 3 3 3 4 7 7 7 7 7 6 6 6 7 7 7 7 7
> # 識(shí)別組的名稱
> (groups.mrt <- levels(as.factor(spe.ch.mvpart$where)))
[1] "3" "4" "6" "7"
> # 第一片葉子的魚類物種組成
> spe.norm[which(spe.ch.mvpart$where==groups.mrt[1]),]
CHA TRU VAI LOC OMB BLA HOT TOX
1 0.0000000 1.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0 0.0000000
2 0.0000000 0.7071068 0.5656854 0.4242641 0.0000000 0.0000000 0 0.0000000
3 0.0000000 0.5735393 0.5735393 0.5735393 0.0000000 0.0000000 0 0.0000000
4 0.0000000 0.4558423 0.5698029 0.5698029 0.0000000 0.0000000 0 0.0000000
6 0.0000000 0.3779645 0.5039526 0.6299408 0.0000000 0.0000000 0 0.0000000
7 0.0000000 0.6063391 0.4850713 0.6063391 0.0000000 0.0000000 0 0.0000000
10 0.0000000 0.1543033 0.6172134 0.6172134 0.0000000 0.0000000 0 0.0000000
11 0.1856953 0.5570860 0.7427814 0.1856953 0.1856953 0.0000000 0 0.0000000
12 0.2461830 0.6154575 0.4923660 0.4923660 0.2461830 0.0000000 0 0.0000000
13 0.2373563 0.5933908 0.5933908 0.2373563 0.3560345 0.2373563 0 0.0000000
14 0.2941742 0.4902903 0.4902903 0.3922323 0.3922323 0.2941742 0 0.0000000
15 0.2822163 0.3762883 0.3762883 0.4703604 0.1881442 0.3762883 0 0.0000000
16 0.1740777 0.2611165 0.2611165 0.4351941 0.0000000 0.4351941 0 0.3481553
VAN CHE BAR SPI GOU BRO
1 0.0000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000
2 0.0000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000
3 0.0000000 0.00000000 0.00000000 0.00000000 0.00000000 0.11470787
4 0.0000000 0.11396058 0.00000000 0.00000000 0.11396058 0.22792115
6 0.1259882 0.25197632 0.00000000 0.00000000 0.12598816 0.12598816
7 0.1212678 0.12126781 0.00000000 0.00000000 0.00000000 0.00000000
10 0.3086067 0.30860670 0.00000000 0.00000000 0.15430335 0.00000000
11 0.0000000 0.18569534 0.00000000 0.00000000 0.00000000 0.00000000
12 0.0000000 0.12309149 0.00000000 0.00000000 0.00000000 0.00000000
13 0.0000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000
14 0.0000000 0.09805807 0.09805807 0.00000000 0.09805807 0.09805807
15 0.2822163 0.28221626 0.18814417 0.00000000 0.18814417 0.00000000
16 0.4351941 0.17407766 0.17407766 0.08703883 0.17407766 0.08703883
PER BOU PSO ROT CAR TAN BCO PCH GRE
1 0.00000000 0 0.00000000 0 0.00000000 0.00000000 0 0 0
2 0.00000000 0 0.00000000 0 0.00000000 0.00000000 0 0 0
3 0.00000000 0 0.00000000 0 0.00000000 0.00000000 0 0 0
4 0.22792115 0 0.00000000 0 0.00000000 0.11396058 0 0 0
6 0.12598816 0 0.00000000 0 0.00000000 0.25197632 0 0 0
7 0.00000000 0 0.00000000 0 0.00000000 0.00000000 0 0 0
10 0.00000000 0 0.00000000 0 0.00000000 0.00000000 0 0 0
11 0.00000000 0 0.00000000 0 0.00000000 0.00000000 0 0 0
12 0.00000000 0 0.00000000 0 0.00000000 0.00000000 0 0 0
13 0.00000000 0 0.00000000 0 0.00000000 0.00000000 0 0 0
14 0.00000000 0 0.00000000 0 0.00000000 0.00000000 0 0 0
15 0.00000000 0 0.00000000 0 0.00000000 0.09407209 0 0 0
16 0.08703883 0 0.08703883 0 0.08703883 0.08703883 0 0 0
GAR BBO ABL ANG
1 0.00000000 0 0 0
2 0.00000000 0 0 0
3 0.00000000 0 0 0
4 0.00000000 0 0 0
6 0.12598816 0 0 0
7 0.00000000 0 0 0
10 0.00000000 0 0 0
11 0.00000000 0 0 0
12 0.00000000 0 0 0
13 0.00000000 0 0 0
14 0.00000000 0 0 0
15 0.00000000 0 0 0
16 0.08703883 0 0 0
> # 第一片葉子的環(huán)境變量組成
> env[which(spe.ch.mvpart$where==groups.mrt[1]),]
das alt pen deb pH dur pho nit amm oxy dbo
1 0.3 934 48.0 0.84 7.9 45 0.01 0.20 0.00 12.2 2.7
2 2.2 932 3.0 1.00 8.0 40 0.02 0.20 0.10 10.3 1.9
3 10.2 914 3.7 1.80 8.3 52 0.05 0.22 0.05 10.5 3.5
4 18.5 854 3.2 2.53 8.0 72 0.10 0.21 0.00 11.0 1.3
6 32.4 846 3.2 2.86 7.9 60 0.20 0.15 0.00 10.2 5.3
7 36.8 841 6.6 4.00 8.1 88 0.07 0.15 0.00 11.1 2.2
10 99.0 617 9.9 10.00 7.7 82 0.06 0.75 0.01 10.0 4.3
11 123.4 483 4.1 19.90 8.1 96 0.30 1.60 0.00 11.5 2.7
12 132.4 477 1.6 20.00 7.9 86 0.04 0.50 0.00 12.2 3.0
13 143.6 450 2.1 21.10 8.1 98 0.06 0.52 0.00 12.4 2.4
14 152.2 434 1.2 21.20 8.3 98 0.27 1.23 0.00 12.3 3.8
15 164.5 415 0.5 23.00 8.6 86 0.40 1.00 0.00 11.7 2.1
16 185.9 375 2.0 16.10 8.0 88 0.20 2.00 0.05 10.3 2.7
> # 葉子的魚類物種組成表格和餅圖
> leaf.sum <- matrix(0, length(groups.mrt), ncol(spe))
> colnames(leaf.sum) <- colnames(spe)
> for(i in 1:length(groups.mrt)){
+ leaf.sum[i,] <- apply(spe.norm[which(spe.ch.mvpart$where==groups.mrt[i]),],
+ 2, sum)
+ }
> leaf.sum
CHA TRU VAI LOC OMB BLA HOT
[1,] 1.41970277 6.7687248 6.2714982 5.634304 1.36828926 1.3430130 0.00000000
[2,] 0.09284767 0.3682695 0.7839270 0.969990 0.09284767 0.1856953 0.09284767
[3,] 0.00000000 0.0000000 0.0000000 0.000000 0.00000000 0.0000000 0.15617376
[4,] 0.10314212 0.1566709 0.7750802 1.310359 0.15667090 0.2450592 1.13488718
TOX VAN CHE BAR SPI GOU BRO
[1,] 0.3481553 1.2732731 1.6589502 0.4602799 0.08703883 0.8545320 0.6537141
[2,] 0.3713907 0.7349785 1.0616448 0.2785430 0.37139068 0.2754219 0.4579960
[3,] 0.0000000 0.2294157 0.9500115 0.0000000 0.00000000 0.6150052 0.2294157
[4,] 1.3247927 1.5186125 2.0069433 2.4324424 1.54705268 2.8307202 1.8419593
PER BOU PSO ROT CAR TAN BCO
[1,] 0.4409481 0.00000000 0.08703883 0.0000000 0.08703883 0.5470478 0.00000
[2,] 0.5508437 0.09284767 0.09284767 0.1825742 0.09284767 0.5053840 0.00000
[3,] 0.0000000 0.00000000 0.15617376 0.2294157 0.00000000 0.0000000 0.00000
[4,] 1.7514544 2.15448060 1.71685385 1.1420904 1.47306052 2.3783208 1.65332
PCH GRE GAR BBO ABL ANG
[1,] 0.000000 0.0000000 0.2130270 0.0000000 0.0000000 0.00000000
[2,] 0.000000 0.0000000 1.1968310 0.0000000 0.1856953 0.09284767
[3,] 0.000000 0.5417633 0.9500115 0.1561738 2.2856126 0.00000000
[4,] 1.065468 2.3285769 3.2165264 1.9190327 3.1330002 1.70137667
> par(mfrow=c(2,2))
> for(i in 1:length(groups.mrt)){
+ pie(which(leaf.sum[i,]>0), radius=1, main=c("leaf #", groups.mrt[i]))
+ }
> # 從mvpart()函數(shù)獲得的結(jié)果對(duì)象中提取MRT結(jié)果
> # 必須加載MVPARTwrap和rdaTest程序包
> spe.ch.mvpart.wrap <- MRT(spe.ch.mvpart, percent=10, species=colnames(spe))
> summary(spe.ch.mvpart.wrap)
Portion (%) of deviance explained by species for every particular node
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
--- Node 1 ---
Complexity(R2) 44.82089
alt>=340 alt< 340
~ Discriminant species :
TRU VAI LOC ABL
% of expl. deviance 19.77533931 15.26700612 10.2177021 17.23790891
Mean on the left 0.44606214 0.44096408 0.4127684 0.01160596
Mean on the right 0.01205161 0.05962155 0.1007969 0.41681637
~ INDVAL species for this node: : left is 1, right is 2
cluster indicator_value probability
TRU 1 0.9128 0.001
VAI 1 0.8258 0.001
LOC 1 0.7535 0.001
CHA 1 0.4036 0.022
ABL 2 0.9729 0.001
GRE 2 0.9231 0.001
HOT 2 0.7994 0.001
PSO 2 0.7849 0.001
GAR 2 0.7844 0.001
BBO 2 0.7692 0.001
BOU 2 0.7432 0.001
ANG 2 0.7366 0.001
GOU 2 0.7289 0.002
CAR 2 0.6998 0.001
ROT 2 0.6942 0.002
BCO 2 0.6923 0.001
SPI 2 0.6200 0.002
BAR 2 0.6170 0.002
BRO 2 0.5892 0.021
TAN 2 0.5658 0.018
PCH 2 0.5385 0.002
PER 2 0.5268 0.023
TOX 2 0.4803 0.014
Sum of probabilities = 0.786
Sum of Indicator Values = 17.76
Sum of Significant Indicator Values = 16.16
Number of Significant Indicators = 23
Significant Indicator Distribution
1 2
4 19
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
--- Node 2 ---
Complexity(R2) 8.626143
amm< 0.11 amm>=0.11
~ Discriminant species :
TRU GAR
% of expl. deviance 29.3525828 27.13056017
Mean on the left 0.5206711 0.01638669
Mean on the right 0.1227565 0.39894367
eliminating null columns
~ INDVAL species for this node: : left is 1, right is 2
cluster indicator_value probability
TRU 1 0.8092 0.005
GAR 2 0.9605 0.001
TAN 2 0.8001 0.014
Sum of probabilities = 6.17
Sum of Indicator Values = 10.26
Sum of Significant Indicator Values = 2.57
Number of Significant Indicators = 3
Significant Indicator Distribution
1 2
1 2
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
--- Node 3 ---
Complexity(R2) 9.506051
amm>=0.45 amm< 0.45
~ Discriminant species :
ABL
% of expl. deviance 32.0463373
Mean on the left 0.7618709
Mean on the right 0.3133000
~ INDVAL species for this node: : left is 1, right is 2
cluster indicator_value probability
ABL 1 0.7086 0.007
BAR 2 1.0000 0.004
SPI 2 1.0000 0.002
PER 2 1.0000 0.004
BOU 2 1.0000 0.002
CAR 2 1.0000 0.005
TAN 2 1.0000 0.004
ANG 2 1.0000 0.004
LOC 2 0.9000 0.019
TOX 2 0.9000 0.016
BCO 2 0.9000 0.015
PSO 2 0.7673 0.030
BBO 2 0.7080 0.037
BRO 2 0.7066 0.032
HOT 2 0.6855 0.032
VAN 2 0.6651 0.035
Sum of probabilities = 6.279
Sum of Indicator Values = 18.74
Sum of Significant Indicator Values = 13.94
Number of Significant Indicators = 16
Significant Indicator Distribution
1 2
1 15
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
--- Final partition ---
Sites in the leaf # 3
[1] "1" "2" "3" "4" "6" "7" "10" "11" "12" "13" "14" "15" "16"
Sites in the leaf # 4
[1] "5" "9" "17"
Sites in the leaf # 6
[1] "23" "24" "25"
Sites in the leaf # 7
[1] "18" "19" "20" "21" "22" "26" "27" "28" "29" "30"
~ INDVAL species of the final partition:
cluster indicator_value probability
TRU 1 0.7900 0.001
VAI 1 0.5422 0.001
LOC 1 0.4506 0.035
ABL 3 0.6700 0.001
BCO 4 0.9000 0.001
BOU 4 0.8744 0.001
ANG 4 0.8461 0.001
CAR 4 0.7965 0.001
BBO 4 0.7080 0.001
PCH 4 0.7000 0.009
PSO 4 0.6568 0.001
BAR 4 0.6548 0.001
HOT 4 0.5776 0.020
GRE 4 0.5632 0.027
SPI 4 0.5424 0.030
TAN 4 0.5304 0.006
GOU 4 0.4385 0.042
Sum of probabilities = 2.848
Sum of Indicator Values = 14.7
Sum of Significant Indicator Values = 11.24
Number of Significant Indicators = 17
Significant Indicator Distribution
1 3 4
3 1 13
~ Corresponding MRT leaf number for Indval cluster number:
MRT leaf # 3 is Indval cluster no. 1
MRT leaf # 4 is Indval cluster no. 2
MRT leaf # 6 is Indval cluster no. 3
MRT leaf # 7 is Indval cluster no. 4
# MRT作為空間和時(shí)間系列約束聚類方法
spe.ch.seq <- mvpart(as.matrix(spe) ~ das, env, cp=0, xv="pick", margin=0.08,
xval=nrow(spe), xvmult=100, which=4)
summary(spe.ch.seq)
# 組的組成(終端節(jié)點(diǎn)的標(biāo)識(shí))
(gr <- spe.ch.seq$where)
# 重新編排聚類簇的編號(hào)
aa <- 1
gr2 <- rep(1,length(gr))
for (i in 2:length(gr)) {
if (gr[i]!=gr[i-1]) aa <- aa+1
gr2[i] <- aa
}
# 在Doubs河地圖上標(biāo)注樣方所屬的聚類簇
plot(spa, asp=1, type="n", main="MRT 分類組",
xlab="x坐標(biāo) (km)", ylab="y坐標(biāo) (km)")
lines(spa, col="light blue")
text(70, 10, "上游", cex=1.2, col="red")
text(15, 115, "下游", cex=1.2, col="red")
k <- length(levels(factor(gr2)))
for (i in 1:k) {
points(spa[gr2==i,1], spa[gr2==i,2], pch=i+20, cex=3, col=i+1, bg=i+1)
}
text(spa, row.names(spa), cex=0.8, col="white", font=2)
legend("bottomright", paste("組",1:k), pch=(1:k)+20, col=2:(k+1),
pt.bg=2:(k+1), pt.cex=2, bty="n")