[R-sig-Geo] Leave one out cross validation in a Generalized linear Model?
Alexander Brenning
brenning at uwaterloo.ca
Tue Sep 27 15:33:37 CEST 2011
Hi Swen,
try 'errorest' in package 'ipred'. Leave-one-out cross-validation of the
'lm' is pretty straightforward with this function. For LOO-CV of
regression kriging (i.e. combined prediction of regression and kriging
method) you would have to write small wrapper functions to be passed to
'errorest' via the 'model' and 'predict' arguments - see the Examples
section of the errorest help.
Best,
Alex
> Date: Mon, 26 Sep 2011 12:38:51 +0200
> From: Swen Meyer<s.meyer at lmu.de>
> To: R-sig-Geo at r-project.org
> Subject: [R-sig-Geo] Leave one out cross validation in a Generalized
> linear Model?
> Message-ID:<4E80563B.8050705 at lmu.de>
> Content-Type: text/plain; charset=ISO-8859-15; format=flowed
>
>
> 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
>
--
Alexander Brenning
brenning at uwaterloo.ca - T +1-519-888-4567 ext 35783
Department of Geography and Environmental Management
University of Waterloo
200 University Ave. W - Waterloo, ON - Canada N2L 3G1
http://www.environment.uwaterloo.ca/geography/faculty/brenning/
More information about the R-sig-Geo
mailing list