使用标记重新捕获数据创建物种发现曲线

时间:2018-05-01 14:31:17

标签: r

我正在R工作,我正在寻找为蝙蝠响铃数据创建累积发现曲线。我们每年进行两次访问,我们真正感兴趣的是我们是否需要进行两次访问,或者我们是否可以通过一次访问来逃避。为此,我们想要绘制第一次和第二次访问的累积重新捕获/发现率,并查看这些是否有很大差异。通过这种方式我们可以看到,即使只有一次访问,我们仍然可以使用洞穴记录大多数蝙蝠。

我已经绘制了累积捕获率随着时间的推移(总计一年加上下一次的累计捕获率),但我试着看一下这些独特个体随时间的累积回收率。

数据的子样本如下所示。我们有我们的赛季(年),每个球棒的独特铃声代码以及它是否访问过一到两个。

             Field.season   Ring_Number       visit_number
    184                 28     m3061                 1           
    185                 28     m4653                 1           
    186                 28     m4653                 1           
    187                 28     m5072                 1           
    188                 28     m5865                 1           
    189                 28     m5930                 1           
    190                 28     m8900                 1           
    191                 28     m8932                 1           
    192                 28     m9010                 1           
    193                 28     m9174                 1           
    194                 28     m9179                 1           
    195                 28     m9180                 1           
    196                 28     m9187                 1           
    197                 28     m9188                 1           
    198                 28     m9189                 1           
    199                 28     m9190                 1           
    200                 28     m9191                 1           
    201                 28     m9192                 1           
    202                 28     m9193                 1           
    203                 28     m9194                 1           
    204                 28     m9195                 1           
    205                 28     m9196                 1           
    206                 28     m9197                 1           
    207                 28     m9198                 1           
    208                 28     m9199                 1           
    209                 28     m9199                 1           
    210                 28      x301                 1           
    211                 28      x303                 1           
    212                 28      x322                 1           
    213                 28      x332                 1           
    214                 28     m5910                 1           
    215                 28     m7023                 1           
    216                 28     m8936                 1           
    217                 28      x305                 1           
    218                 28      x307                 1           
    219                 28      x316                 1           
    220                 28      x320                 1           
    221                 28      x329                 1           
    222                 28      x330                 1           
    223                 28      x341                 1           
    224                 28      x407                 1           
    225                 28      x408                 1           
    226                 28      x409                 1          
    227                 28      x410                 1          
    228                 28      x411                 1          
    229                 28      x412                 1           
    230                 28      x413                 1           
    231                 28      x414                 1           
    232                 28      x415                 1           
    233                 28      x416                 1           
    234                 28      x417                 1           
    235                 28      x418                 1           
    236                 28      x419                 1           
    237                 28      x421                 1           
    238                 28      x422                 1           
    239                 28      x423                 1           
    240                 28      x424                 1           
    241                 28      x425                 1           
    242                 28      x426                 1           
    243                 28      x427                 1           
    244                 28      x428                 1           
    245                 28      x429                 1           
    246                 28      x430                 1           
    247                 28      x431                 1           
    248                 28      x432                 1           
    249                 28      x434                 1           
    250                 28      x450                 1           
    251                 28      x496                 1           
    252                 28      x497                 1           
    253                 28      x499                 1           
    254                 28     m5088                 1           
    255                 28     m5910                 1           
    256                 28     m5924                 1           
    257                 28     m5931                 1           
    258                 28     m5935                 1           
    259                 28     m5953                 1           
    260                 28     m5992                 1           
    261                 28     m8880                 1           
    262                 28     m8881                 1           
    263                 28      x302                 1           
    264                 28      x305                 1           
    265                 28      x311                 1           
    266                 28      x311                 1           
    267                 28      x315                 1           
    268                 28      x333                 1           
    269                 28      x338                 1           
    270                 28      x341                 1           
    271                 28      x408                 1           
    272                 28      x410                 1           
    273                 28      x412                 1          
    274                 28      x414                 1           
    275                 28      x415                 1           
    276                 28      x416                 1           
    277                 28      x418                 1           
    278                 28      x426                 1           
    279                 28      x430                 1           
    280                 28      x434                 1           
    281                 28      x435                 1           
    282                 28      x436                 1           
    283                 28      x437                 1           
    284                 28      x438                 1           
    285                 28      x439                 1           
    286                 28      x440                 1           
    287                 28      x441                 1           
    288                 28      x442                 1           
    289                 28      x443                 1           
    290                 28      x444                 1           
    291                 28      x445                 1           
    292                 28      x447                 1           
    293                 28      x448                 1           
    294                 28      x497                 1           
    295                 28      x500                 1           
    296                 28     m3504                 2           
    297                 28     m4584                 2           
    298                 28     m5059                 2           
    299                 28     m5910                 2           
    300                 28     m5953                 2           
    301                 28     m7023                 2           
    302                 28     m8909                 2           
    303                 28     m8936                 2           
    304                 28      x304                 2           
    305                 28      x327                 2           
    306                 28      x333                 2           
    307                 28      x338                 2           
    308                 28      x341                 2           
    309                 28      x351                 2           
    310                 28      x352                 2           
    311                 28      x353                 2           
    312                 28      x354                 2           
    313                 28      x355                 2           
    314                 28      x356                 2           
    315                 28      x357                 2           
    316                 28      x358                 2           
    317                 28      x408                 2           
    318                 28      x412                 2           
    319                 28      x418                 2           
    320                 28      x426                 2           
    321                 28      x429                 2           
    322                 28      x431                 2           
    323                 28      x432                 2           
    324                 28      x438                 2           
    325                 28      x439                 2           
    326                 28      x448                 2           
    327                 28      x449                 2           
    328                 28      x450                 2           
    329                 28      x497                 2           
    330                 28      x498                 2           
    331                 28      x500                 2           
    339                 29     m4885                 1           
    340                 29     m6912                 1           
    341                 29     m8993                 1           
    342                 29     m9019                 1           
    343                 29     m9178                 1           
    344                 29      x405                 1           
    345                 29      x421                 1           
    346                 29     m3504                 1           
    347                 29     m5103                 1           
    348                 29     m5954                 1           
    349                 29     m7083                 1           
    350                 29     m8874                 1           
    351                 29     m8935                 1           
    352                 29     m8938                 1           
    353                 29     m8995                 1           
    354                 29     m9582                 1          
    355                 29      x358                 1           
    356                 29      x410                 1           
    357                 29      x414                 1           
    358                 29      x426                 1           
    359                 29      x438                 1           
    360                 29      x451                 1           
    361                 29      x452                 1           
    362                 29      x454                 1           
    363                 29      x455                 1           
    364                 29      x456                 1           
    365                 29      x457                 1           
    366                 29      x458                 1           
    367                 29      x459                 1           
    368                 29      x460                 1           
    369                 29      x461                 1           
    370                 29      x462                 1           
    371                 29      x463                 1           
    372                 29      x464                 1           
    373                 29      x465                 1           
    374                 29      x466                 1           
    375                 29      x467                 1           
    376                 29      x468                 1           
    377                 29      x469                 1           
    378                 29      x470                 1           
    379                 29      x471                 1           
    380                 29      x472                 1           
    381                 29      x473                 1           
    382                 29      x474                 1           
    383                 29      x475                 1           
    384                 29      x476                 1           
    385                 29     m5210                 1           
    386                 29     m5920                 1           
    387                 29     m5931                 1           
    388                 29     m5935                 1           
    389                 29     m8936                 1           
    390                 29     m9175                 1           
    391                 29     m9200                 1           
    392                 29      x304                 1           
    393                 29      x305                 1           
    394                 29      x327                 1           
    395                 29      x345                 1           
    396                 29      x351                 1           
    397                 29      x353                 1           
    398                 29      x354                 1           
    399                 29      x359                 1           
    400                 29      x360                 1           
    401                 29      x362                 1           
    402                 29      x363                 1           
    403                 29      x364                 1           
    404                 29      x365                 1           
    405                 29      x366                 1           
    406                 29      x367                 1           
    407                 29      x368                 1           
    408                 29      x369                 1           
    409                 29      x371                 1           
    410                 29      x372                 1           
    411                 29      x373                 1           
    412                 29      x374                 1           
    413                 29      x375                 1           
    414                 29      x376                 1           
    415                 29      x377                 1           
    416                 29      x378                 1           
    417                 29      x379                 1           
    418                 29      x380                 1           
    419                 29      x381                 1           
    420                 29      x382                 1           
    421                 29      x383                 1           
    422                 29      x384                 1           
    423                 29      x385                 1           
    424                 29      x386                 1           
    425                 29      x386                 1           
    426                 29      x387                 1           
    427                 29      x389                 1           
    428                 29      x390                 1           
    429                 29      x391                 1           
    430                 29      x392                 1           
    431                 29      x393                 1           
    432                 29      x394                 1           
    433                 29      x395                 1           
    434                 29      x396                 1           
    435                 29      x397                 1           
    436                 29      x398                 1           
    437                 29      x399                 1           
    438                 29      x400                 1           
    439                 29      x409                 1           
    440                 29      x417                 1          

任何帮助都将不胜感激。

修改 举个例子来说明我一直在尝试但不知道它是否是正确的代码包括:

df1 <- df[which(df$visit_number == 1), ]
df2 <- df[which(df$visit_number == 2), ]

library(asnipe)
individuals1 <- data.frame(D = df1$Ring_Number, GROUP = df1$Field.season)
gbi1 <- get_group_by_individual(individuals1, data_format = "individuals")

library(vegan)
sp1 <- specaccum(gbi1)
sp2 <- specaccum(gbi1, "random")
sp2
summary(sp2)
plot(sp1, ci.type="poly", col="blue", lwd=2, ci.lty=0, ci.col="lightblue")
boxplot(sp2, col="yellow", add=TRUE, pch="+")
## Fit Lomolino model to the exact accumulation
mod1 <- fitspecaccum(sp1, "lomolino")
coef(mod1)
fitted(mod1)
plot(sp1)
## Add Lomolino model using argument 'add'
plot(mod1, add = TRUE, col=2, lwd=2)
## Fit Arrhenius models to all random accumulations
mods <- fitspecaccum(sp2, "arrh")
plot(mods, col="hotpink")
boxplot(sp2, col = "yellow", border = "blue", lty=1, cex=0.3, add= TRUE)
## Use nls() methods to the list of models
sapply(mods$models, AIC)

#this was then done for df2 (gbi2) for comparison. 

但我不确定它正在做我正在考虑的事情。

1 个答案:

答案 0 :(得分:0)

好的,那怎么样:

  • 您将戒指分成每个季节/访问组合的单独向量

...

ring_per_visit <- split(df$Ring, list(df$Number, df$Field.season))
  • 你循环遍历它,因为每一个计算设定差异与包含所有先前发现的环/物种的矢量相比(即,你只保留那次访问期间新发现的那些)

    < / LI>
  • 您通过在访问期间总共查看了多少环来规范化

...(结果反过来)

discoveries <- sapply(rev(seq_along(ring_per_visit)), function(x) {
    if (x != 1) {
      length(unique(unlist(setdiff(
        ring_per_visit[[x]], 
        unlist(ring_per_visit[seq(x - 1)])
        )
        ))) / length(ring_per_visit[[x]])
    } else {
    length(unique(ring_per_visit[[x]])) / length(ring_per_visit[[x]])
    }
  }
)

然后你可以绘制它,例如

library(ggplot2)
ggplot() + 
  geom_line(aes(
    x = factor(c("Y1V1", "Y1V2", "Y2V1", "Y2V2")), 
    y = rev(discoveries),
    group = 1
  )) +
  ylim(0, 1)

enter image description here