Hello,

I use the following function "bootstrapge" to calculate (and compare) the generalization error of several bootstrap implementations:

##
## Calculates and returns a coefficient corresponding to the generalization 
## error. The formula for the bootstrap generalization error is:
## $N^{-1}\sum_{i=1}^n B^{-1}\sum_{j=1}^B |y_i - (\beta_n^{*j})^T x|$
## 
## x - mxn matrix where m is the number of model parameters and n is the 
##     number of observations
## y - n column-vector containing true values
## theta_star - mxn matrix where m is the number of bootstrapped samples 
##              and n is the number of model parameters 
##
bootstrapge <- function(x,y,theta_star) {
	B <- nrow(theta_star)
	P <- ncol(theta_star)

	t <- 0
	for (b in 1:B) {
		t <- t + abs(y - rbind(theta_star[b,])%*%x)
	}
	return(mean(t/B))
}  

Is there a nicer/faster way to accomplish the same using implicit loop functions e.g. apply, sapply etc I could not figure it out ...

Is there a way to get a similar coefficient using the boot library? I could not find any way to get such a "generalization error" so I can compare my implementation with that one ...

TIA,
Best regards,
Giovanni
	[[alternative HTML version deleted]]

