代码之家  ›  专栏  ›  技术社区  ›  Lyndz

R中的“极值”包出错:无法绘制重现期

r
  •  0
  • Lyndz  · 技术社区  · 6 年前

    我用的是 R包装 在绘制重现期时。

    数据如下: https://www.dropbox.com/s/un9vghuwmptnty1/Lumbia_1979-2017.csv?dl=0

    抱歉,重现期图需要大量观测点,所以这是我能发布的最小数据集。

    以下是目前为止的剧本:

    library(extRemes)
    dat<-read.csv("Lumbia_1979-2017.csv",header=T)
    dat[dat==-999]<-NA
    
    #Extract annual max precip
    annmax <- aggregate(dat$Rain, by = list(dat$Year),max, na.rm=TRUE,na.action=NULL)
    gevfit1 <- fevd(annmax[ ,2])
    gevfit1
    

    错误

    我遇到以下错误和警告:

    Error Message

    (a) 有人能提出一个解决方案来绘制缺失值数据集的返回期吗?

    (b) 例如,如果我想得到100毫米/天降雨量的重现期,我如何从重现期的曲线图中估计。

    在这件事上如有任何帮助,我将不胜感激。

    0 回复  |  直到 6 年前
        1
  •  1
  •   Tomas    6 年前

    您得到的错误来自 aggregate 电话:

    annmax <- aggregate(dat$Rain, by = list(dat$Year),max, na.rm=TRUE,na.action=NULL)
    # Warning messages:
    # 1: In FUN(X[[i]], ...) : no non-missing arguments to max; returning -Inf
    # 2: In FUN(X[[i]], ...) : no non-missing arguments to max; returning -Inf
    # [...]
    

    在这个调用中,您正在计算 Rain 对于每个 Year

    annmax
    #    Group.1     x
    # 1     1979   5.4
    # 2     1980  27.1
    # 3     1981  62.5
    # [...]
    # 33    2011  58.2
    # 34    2012   5.7
    # 35    2013  74.9
    # 36    2014  -Inf
    # 37    2015  -Inf
    # 38    2016  -Inf
    # 39    2017  -Inf
    

    这些年,当 骨料 返回 -Inf

    dat[dat$Year %in% 2014:2017,]
    #      Year Month Day Rain
    # 1086 2014     1   1   NA
    # 1087 2014     1   2   NA
    # 1088 2014     1   3   NA
    # 1089 2014     1   4   NA
    # 1090 2014     1   5   NA
    # 1091 2014     1   6   NA
    # 1092 2014     1   7   NA
    # 1093 2014     1   8   NA
    # 1094 2014     1   9   NA
    # 1095 2014     1  10   NA
    # 1096 2014     1  11   NA
    # [...]
    

    所以,你要决定如何处理那些失踪的岁月。这取决于分析。分析是否需要缺失年份的数据?

    fevd )需要一些缺失年份的数据,你需要一些方法从其他年份中插值。

    2) 如果分析不需要缺失的年份,就删除它们。这是最简单的解决方案:

    annmax2 <- annmax[is.finite(annmax[,2]),]
    gevfit1 <- fevd(annmax2[ ,2])