gls中的外函数调用(arg 1)中的NA / NaN / Inf

时间:2019-10-06 04:20:51

标签: r

我尝试使用varExp()来检查空间自相关,但是当我运行代码时,遇到了 recalc.corSpatial(object [[i]],conLin)中的错误:

  

NA / NaN / Inf在外部函数调用(arg 1)中,那么我该如何解决?

当我剪切一些数据时,我发现问题似乎消失了,但是显然我无法做到这一点。

datah <- data.frame(sou=c(18464.5896,18974.98643,18720.76108,18572.57526,18641.36477,18689.07228,18318.6146,18502.4185,18577.657,18333.77524,18756.79527,18727.89873,18251.97676,18619.33025,18336.22126,18600.10308,18569.4394,18298.79336,17987.1023,18283.87389),
                height=c(368,414,548.6,568.8,653,1842.84,1745,1365.65,1492.34,1545.71,658.75,535.5,1284,1169.75,1239.8,1240.333333,1205,999,869.75,808.8),
                long=c(25.16018611,25.15174167,25.13214722,25.13651,25.11462431,24.488482,24.483646,24.444984,24.441987,24.405398,24.1457375,24.0212375,23.97276736,23.51997778,23.495615,23.50344444,23.96935903,25.61936611,25.61547292,25.60349389),
                lat=c(108.0581333,108.0436167,107.9863328,107.9698472,107.9586076,106.394446,106.394824,106.357908,106.370668,106.379341,110.0880299,110.2530819,110.1112444,108.3869556,108.4341233,108.4413315,110.1140097,109.9258978,109.9042396,109.90436))

str(datah)
fgls <- formula(sou ~ height,data=datah)
vf111 <- varExp(form =~ height)
a1 <-gls(fgls,correlation=corSpher(form=~long+lat,nugget=T),weights = vf111,data=datah)

a2 <-gls(fgls,correlation=corLin(form=~long+lat,nugget=T),weights = vf111,data=datah)
a3 <-gls(fgls,correlation=corRatio(form=~long+lat,nugget=T),weights = vf111,data=datah)
a4 <-gls(fgls,correlation=corGaus(form=~long+lat,nugget=T),weights = vf111,data=datah)
a5 <-gls(fgls,correlation=corExp(form=~long+lat,nugget=T),weights = vf111,data=datah)

谢谢您的帮助!

0 个答案:

没有答案