2
我想爲二進制存在 - 缺失和主機網格數據執行迴歸克里格法(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)
第一個腳本有幾個問題:首先,您忘記了'library(sp)',那麼點數據在您的谷歌驅動器中沒有方便的格式,然後'presabs $ host.asc.txt < log(host.ov $ host.asc.txt)'不對應於下面的glm輸出,那麼你似乎在'glm'對象上調用'summary.lm'而不是相應的'summary',然後'glm .presabs'丟失。看起來像複製和粘貼命令,而不檢查它們是否一致和可重複。 – 2015-04-27 13:41:25