[R-sig-Geo] Leave one out cross validation in a Generalized linear Model?

Swen Meyer s.meyer at lmu.de
Mon Sep 26 12:38:51 CEST 2011


Dear All,
I got the following problem. I use the GLM below to do Regression Kriging:

#MLR backward Co-Variables(P1 -P10)
fit1 <- lm((CLAY)~  PC1 + PC2 +PC3 +PC4 +PC5 +PC6 +PC7 +PC8+PC9 +PC10   
, boden.ov[sel,] )
#GLM
m.glm <- glm(formula(step), boden.ov[sel,], family=gaussian)
summary(m.glm)
p.glm <- predict(m.glm, newdata=boden.grid, type="link", se.fit=TRUE)
om.glm <- as(boden.grid["band1"], "SpatialPointsDataFrame")
om.glm$var1.pred <- p.glm$fit
om.glm$var1.var <- p.glm$se.fit
om.glm$svar <- p.glm$se.fit^2/(m.glm$null.deviance/m.glm$df.null)
gridded(om.glm) <- TRUE
fullgrid(om.glm) <- TRUE

##Regression Kriging with GLM
vario.res <- autofitVariogram((CLAY)~om.glm, boden.ov[sel,], model = 
c("Sph"))
plot(variogram((CLAY)~om.glm, boden.ov[sel,]), vario.res$var_model)
om.rk <- krige((CLAY)~om.glm,boden.ov, boden.grid,    vario.res$var_model)
om.rk$om.pred <- (om.rk$var1.pred)

#Leave one out Cross Validation Regression Kriging
rk.cv <- krige.cv((CLAY)~om.glm,boden.ov,   vario.res$var_model, 
verbose=TRUE)
rk.RMSE <- 
sqrt(mean((rk.cv$var1.pred-rk.cv$observed)^2)/length(rk.cv$var1.pred))
rk.RMSE

I would like to calculate a leave one out cross validation like I did it 
for the Regrssion Kriging, but only for upper GLM-part. Is there a way 
of package to calculate the CV only for the GLM part?

kordinary_m.glm.cv <- krige.cv(m.glm  , loc = boden.ov)

Does anyone have an idea?

Thank you in advance,
Swen

-- 
--------------------------------------------------------------
Dipl. - Geogr. Swen Meyer
Department of Geography
Physical Geography and Environmental Modeling Ludwig-Maximilian University of Munich

Luisenstrasse 37
80333 Munich/Germany
fon: +49 (0)89 2180-6648
fax: +49 (0)89 2180-6675
email: s.meyer at lmu.de
web: www.geographie.uni-muenchen.de



More information about the R-sig-Geo mailing list