Oh, ok, I'm sorry, I had not understand the "self-contained" expression.
Anyway, a self-contained exaple can be this:

############################## BEGINNING
library(gstat)
library(rgdal)
library(raster)

data(meuse)
coordinates(meuse) = ~x+y
r <- raster(system.file("external/test.grd", package="raster"))
projection(r)<-projection(meuse)

##ORDINARY KRIGING (working)
v<-variogram(log(zinc)~1,meuse)
m<-fit.variogram(v,vgm(1,"Sph",300,1))
gOK<-gstat(NULL,"log.zinc",log(zinc)~1,meuse,model=m)
OK<-interpolate(r,gOK)

##UNIVERSAL KRIGING (not working!!)
vu<-variogram(log(zinc)~elev,meuse)
mu<-fit.variogram(vu,vgm(1,"Sph",300,1))
gUK<-gstat(NULL,"log.zinc",log(zinc)~elev,meuse,model=mu)
UK<-interpolate(r,gUK)

###CO-KRIGING (working)
gCoK<-gstat(NULL,'log.zinc',log(zinc)~1,meuse)
gCoK<-gstat(gCoK,'elev',elev~1,meuse)
gCoK<-gstat(gCoK,'cadmium',cadmium~1,meuse)
gCoK<-gstat(gCoK,'copper',copper~1,meuse)
gCoK
coV<-variogram(gCoK)
plot(coV,type='b',main='Co-variogram')
coV.fit<-fit.lmc(coV,gCoK,vgm(model='Sph',range=1000))
coV.fit
plot(coV,coV.fit,main='Fitted Co-variogram')
coK<-interpolate(r,coV.fit)
############################################ END

I hope it can be ok :)
Thanks a lot (again)

-- 
Maurizio Marchi
ID skype: maurizioxyz
*Ubuntu 12.04 (Precise Pangolin)*
*"Il bello dell'open-source è che le domande possono essere poste alla
fonte"*
*utente linux 552.742*

	[[alternative HTML version deleted]]

