Ok sure. I will hereby simulate the interpolation of a target variable "points" (whose data is attached) via a single factor predictor "classes" created randomly over the region of interest:
# libraries library(sp) library(gstat) library(automap) # Import the point pattern from the txt file and turn it to Spatial # (set properly the path variable) points <- read.table(path, header=TRUE) coordinates(points)<- ~ LON+LAT # Create grid enclosing the points and fill it with random factor data grid <- GridTopology(c(9,43.5), c(.1,.1), c(40, 20)) SPgrid <- SpatialGridDataFrame(grid, data.frame(classes=round(runif(40*20, 1, 10)))) SPgrid$classes <- as.factor(SPgrid$classes) # Overlay the factor covariate onto the points ov <- overlay(SPgrid, points) points$CL <- ov$classes # Create the linear regression model lm <- lm(pm10 ~ CL, points) summary(lm) # Fit the variogram of the residuals rvar <- autofitVariogram(residuals(lm) ~ 1, points) # Regression Kriging pm10.rk <- krige(lm$call$formula, points, SPgrid, rvar) --> HERE I HAVE ERROR: Error in function (classes, fdef, mtable) : unable to find an inherited method for function "krige", for signature "call", "SpatialPointsDataFrame" Hope this helps getting closer to the problem, Piero http://r-sig-geo.2731867.n2.nabble.com/file/n6011444/2009-045.ARPA.txt 2009-045.ARPA.txt -- View this message in context: http://r-sig-geo.2731867.n2.nabble.com/Universal-Kriging-with-factor-covariate-tp6009230p6011444.html Sent from the R-sig-geo mailing list archive at Nabble.com. _______________________________________________ R-sig-Geo mailing list R-sig-Geo@r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-geo