gcv.Krig(out, lambda.grid = NA, cost = 1, nstep.cv = 200, rmse = NA,
verbose = FALSE, tol = 1e-05, offset = 0,
y = NULL, give.warnings = TRUE, give.warnings.REML = FALSE)gcv.sreg (out, lambda.grid = NA, cost = 1, nstep.cv = 80, rmse =
NA, offset = 0, trmin = NA, trmax = NA, verbose = FALSE, tol = 1e-05)
The Krig object passed to this function has some matrix decompostions that facilitate rapid computation of the GCV and ML functions and do not depend on the independent variable. This makes it possible to compute the Krig object once and to reuse the decompostions for multiple data sets. (But keep in mind if the x values change then the object must be recalculated.) The example below show show this can be used for a simulation study on the variability for estimating the smoothing parameter.
Krig
,
Tps
,
predict.Krig
#
Tps( ozone$x, ozone$y)-> obj # default is to find lambda by GCV
summary( obj)
gcv.Krig( obj)-> out
print( out$lambda.est) # results agree with Tps summary
sreg( rat.diet$t, rat.diet$trt)-> out
gcv.sreg( out, tol=1e-10) # higher tolerance search for minimum
# a simulation example
x<- seq( 0,1,,150)
f<- x**2*( 1-x)
f<- f/sqrt( var( f))
set.seed(123) # let's all use the same seed
sigma<- .1
y<- f + rnorm( 150)*sigma
Tps( x,y)-> obj # create Krig object
hold<- matrix( NA, ncol=5, nrow=100)
for( k in 1:10){
# look at GCV estimates of lambda
# new data simulated
y<- f + rnorm(150)*sigma
# save GCV estimates
hold[k,]<- gcv.Krig(obj, y=y, give.warnings=FALSE)$lambda.est[1,]
}
plot( hold[,2], hold[,4], xlab="estimated eff. df", ylab="sigma hat")
yline( sigma, col=2)
# note some occaisional flaky behaviour with GCV ( eff df > 15!)
Run the code above in your browser using DataLab