用于回归克里金法的 Logistic 函数
Logistic function for regression kriging
我想对二进制存在-不存在和宿主网格数据执行回归克里金法 (RK) 作为常量预测器。我已经使用逻辑函数来估计二元结果和预测变量之间的关系,但是我认为它没有通过 RK 假设?预测变量在模型中并不重要。有没有其他方法可以解决它?
代码数据:https://drive.google.com/folderview?id=0B7-8DA0HVZqDYk1BcFFwSkZCcjQ&usp=sharing
presabs <- read.csv("Pres_Abs.csv",header=T,
colClasses = c("integer","numeric","numeric",
"integer"))
coordinates(presabs) <- c("Long","Lat") # creates SpatialPointsDataFrame
host <- read.asciigrid("host.asc.txt") # reads ArcInfo Ascii raster map
host.ov <- overlay(host, presabs) # create grid-points overlay
presabs$host.asc.txt <- host.ov$host.asc.txt #copy host values
presabs$host.asc.txt <- log(host.ov$host.asc.txt)
glm(formula = Pres ~ host.asc.txt, family = binomial, data = presabs)
summary(glm.presabs)
Weighted Residuals:
Min 1Q Median 3Q Max
-0.3786 -0.3762 -0.3708 -0.3497 3.3137
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) -1.942428 0.320104 -6.068 1.38e-08 ***
host.asc.txt -0.001453 0.003034 -0.479 0.633
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Residual standard error: 1.007 on 127 degrees of freedom
Multiple R-squared: 1.317e-05, Adjusted R-squared: -0.007861
F-statistic: 0.001673 on 1 and 127 DF, p-value: 0.9674
然后,当涉及到实际的克里金法时,我已经从教程中构建了这段代码,但似乎 glm 的实际残差没有输入到 krige
函数中。可以在 gstat 中改进吗?
library(gstat)
# Set bin width for the variogram and max distance:
Bin <- 0.09
MaxDist <- 1
BinNo <- MaxDist/Bin
# Calculate and plot the variogram
surpts.var <- variogram(Pres~1, presabs, cutoff=MaxDist, width = Bin)
plot(surpts.var)
# Insert parameter values for the variogram model
psill = 0.05921
distance = 63.7/111
nugget = 0.06233 # constant
# Fit and plot variogram model:
null.vgm <- vgm(psill,"Sph",distance,nugget) # initial parameters
vgm_Pres_r <- fit.variogram(surpts.var, model=null.vgm, fit.ranges=TRUE,
fit.method=1)
plot(surpts.var,vgm_Pres_r)
# Run RK using universal kriging:
presabs_uk <- krige(Pres~host.asc.txt, locations=presabs,
newdata=host, model=vgm_Pres_r)
krige
提到是
[using universal kriging]
这意味着它适合线性模型,而不适合广义线性模型。它使用您拟合到原始数据而不是残差的变异函数。残差变异函数可以通过
获得
surpts.var <- variogram(Pres~host.asc.txt, presabs, cutoff=MaxDist, width = Bin)
但几乎相同,因为您的变量和网格图几乎不相关:
> cor(presabs$Pres,presabs$host.asc.txt)
[1] -0.04281038
因此,您在通用克里金法预测中无法识别网格地图也就不足为奇了:两者几乎(线性)独立。
我想对二进制存在-不存在和宿主网格数据执行回归克里金法 (RK) 作为常量预测器。我已经使用逻辑函数来估计二元结果和预测变量之间的关系,但是我认为它没有通过 RK 假设?预测变量在模型中并不重要。有没有其他方法可以解决它?
代码数据:https://drive.google.com/folderview?id=0B7-8DA0HVZqDYk1BcFFwSkZCcjQ&usp=sharing
presabs <- read.csv("Pres_Abs.csv",header=T,
colClasses = c("integer","numeric","numeric",
"integer"))
coordinates(presabs) <- c("Long","Lat") # creates SpatialPointsDataFrame
host <- read.asciigrid("host.asc.txt") # reads ArcInfo Ascii raster map
host.ov <- overlay(host, presabs) # create grid-points overlay
presabs$host.asc.txt <- host.ov$host.asc.txt #copy host values
presabs$host.asc.txt <- log(host.ov$host.asc.txt)
glm(formula = Pres ~ host.asc.txt, family = binomial, data = presabs)
summary(glm.presabs)
Weighted Residuals:
Min 1Q Median 3Q Max
-0.3786 -0.3762 -0.3708 -0.3497 3.3137
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) -1.942428 0.320104 -6.068 1.38e-08 ***
host.asc.txt -0.001453 0.003034 -0.479 0.633
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Residual standard error: 1.007 on 127 degrees of freedom
Multiple R-squared: 1.317e-05, Adjusted R-squared: -0.007861
F-statistic: 0.001673 on 1 and 127 DF, p-value: 0.9674
然后,当涉及到实际的克里金法时,我已经从教程中构建了这段代码,但似乎 glm 的实际残差没有输入到 krige
函数中。可以在 gstat 中改进吗?
library(gstat)
# Set bin width for the variogram and max distance:
Bin <- 0.09
MaxDist <- 1
BinNo <- MaxDist/Bin
# Calculate and plot the variogram
surpts.var <- variogram(Pres~1, presabs, cutoff=MaxDist, width = Bin)
plot(surpts.var)
# Insert parameter values for the variogram model
psill = 0.05921
distance = 63.7/111
nugget = 0.06233 # constant
# Fit and plot variogram model:
null.vgm <- vgm(psill,"Sph",distance,nugget) # initial parameters
vgm_Pres_r <- fit.variogram(surpts.var, model=null.vgm, fit.ranges=TRUE,
fit.method=1)
plot(surpts.var,vgm_Pres_r)
# Run RK using universal kriging:
presabs_uk <- krige(Pres~host.asc.txt, locations=presabs,
newdata=host, model=vgm_Pres_r)
krige
提到是
[using universal kriging]
这意味着它适合线性模型,而不适合广义线性模型。它使用您拟合到原始数据而不是残差的变异函数。残差变异函数可以通过
获得surpts.var <- variogram(Pres~host.asc.txt, presabs, cutoff=MaxDist, width = Bin)
但几乎相同,因为您的变量和网格图几乎不相关:
> cor(presabs$Pres,presabs$host.asc.txt)
[1] -0.04281038
因此,您在通用克里金法预测中无法识别网格地图也就不足为奇了:两者几乎(线性)独立。