计算标准降水-蒸散指数(SPEI)仅返回NA值

时间:2019-01-28 15:33:02

标签: r

我尝试为我的225个站点计算SPEI(两个月的汇总),但spei仅返回NA。我的数据集怎么了?

我有一个225列的数据框;每个都包含某个站点的水平衡。行(48)代表从2013年6月到2016年5月的不同月份。

这是前两列的前四行的样子:

   BE_HI_T1_P1 BE_HI_T1_P2
1      -46.67      -46.82
2      -92.98      -93.44
3      -73.53      -74.78
4       22.13       20.53

我处理的数据框只包含数字值而没有NA:

'data.frame':   48 obs. of  225 variables:
 $ BE_HI_T1_P1: num  -46.7 -93 -73.5 22.1 72.4 ...
 $ BE_HI_T1_P2: num  -46.8 -93.4 -74.8 20.5 70.6 ...
 $ BE_HI_T1_P3: num  -47.2 -95.2 -80.4 12.9 61.7 ...
 $ BE_HI_T1_P4: num  -45.3 -87.5 -58.6 40.4 91.4 ...
 $ BE_HI_T1_P5: num  -47 -94 -76.4 33.6 84.7 ...
 $ BE_HI_T2_P1: num  3.51 -3.39 10.13 70.57 90.88 ...
 $ BE_HI_T2_P2: num  7.16 2.12 15.19 74.31 94.39 ...
 $ BE_HI_T2_P3: num  -6.95 -20.02 -6.14 58.14 79.49 ...
 $ BE_HI_T2_P4: num  22 23.2 33.2 86.5 106.5 ...
 $ BE_HI_T2_P5: num  16.1 15 26.6 78 97.9 ...
 $ BE_HI_T3_P1: num  56.49 23.34 -6.19 28.52 33.55 ...
 $ BE_HI_T3_P2: num  43.03 6.38 -20.98 18.9 28.05 ...
 $ BE_HI_T3_P3: num  75.3 48.5 19.9 47.3 45.4 ...
 $ BE_HI_T3_P4: num  56.79 23.73 -5.83 28.76 33.7 ...
 $ BE_HI_T3_P5: num  65.9 35.5 5.7 -22.5 14.2 ...
 $ BE_LO_T1_P1: num  -9.76 -62.88 -105.31 -43.44 38.4 ...
 $ BE_LO_T1_P2: num  -19.2 -70.4 -108.1 -43.8 37.2 ...
 $ BE_LO_T1_P3: num  13.8 -42 -96.7 -42 42.3 ...
 $ BE_LO_T1_P4: num  -12.4 -65.1 -106.2 -43.6 38 ...
 $ BE_LO_T1_P5: num  -64.72 -91.92 -86.62 4.73 96.85 ...
 $ BE_LO_T2_P1: num  -64.34 -90.78 -83.66 8.22 100.42 ...
 $ BE_LO_T2_P2: num  -65.23 -94.14 -93.6 -5.28 86.06 ...
 $ BE_LO_T2_P3: num  -63.3 -86.6 -72.3 22.5 114.1 ...
 $ BE_LO_T2_P4: num  -63.5 -88.2 -76.9 16.8 108.8 ...
 $ BE_LO_T2_P5: num  -14.86 -0.27 0.85 55.43 114.2 ...
 $ BE_LO_T3_P1: num  -25.8 -18.2 -17.1 42.5 103.2 ...
 $ BE_LO_T3_P2: num  3.2 26.4 24.4 73.5 130.5 ...
 $ BE_LO_T3_P3: num  -15.68 -1.56 -0.39 55.72 114.45 ...
 $ BE_LO_T3_P4: num  -7.64 10.81 11.2 64.45 122.12 ...
 $ BE_LO_T3_P5: num  37.16 26.47 -16.55 9.96 57.21 ...
 $ BE_ME_T1_P1: num  38.41 12.88 -25.17 9.14 23.64 ...
 ....

这是我尝试运行的代码:

DataSPEI <-spei(ts(DataWaterBalance,freq = 12,start = c(2013,6)),2)

我的结果如下:

         BE_HI_T1_P1 BE_HI_T1_P2 
Jun 2013          NA          NA                  
Jul 2013          NA          NA                
Aug 2013          NA          NA                 
Sep 2013          NA          NA 

 > str(DataSPEI)
List of 8
 $ call        : language spei(data = ts(DataWaterBalance, freq = 12, start = c(2013, 6)), scale = 2)
 $ fitted      : Time-Series [1:48, 1:225] from 2013 to 2017: NA NA NA NA NA NA NA NA NA NA ...
  ..- attr(*, "dimnames")=List of 2
  .. ..$ : NULL
  .. ..$ : chr    [1:225] "BE_HI_T1_P1" "BE_HI_T1_P2" "BE_HI_T1_P3" "BE_HI_T1_P4" ...
 $ coefficients: logi [1:3, 1:225, 1:12] NA NA NA NA NA NA ...
  ..- attr(*, "dimnames")=List of 3
  .. ..$ par: chr [1:3] "xi" "alpha" "kappa"
  .. ..$    : chr [1:225] "BE_HI_T1_P1" "BE_HI_T1_P2" "BE_HI_T1_P3" "BE_HI_T1_P4" ...
  .. ..$    : NULL
 $ scale       : num 2
 $ kernel      :List of 3
  ..$ type  : chr "rectangular"
  ..$ shift : num 0
  ..$ values: num [1:2] 0.5 0.5
 $ distribution: chr "log-Logistic"
 $ fit         : chr "ub-pwm"
 $ na.action   : logi FALSE
 - attr(*, "class")= chr "spei"

提前谢谢!

1 个答案:

答案 0 :(得分:0)

似乎应该传递一个na.rm参数,如果您有其他NA,它将影响此参数。 https://cran.r-project.org/web/packages/SPEI/SPEI.pdf