[R] Bootstrap and average median squared error

Rui Barradas ruipb@rr@d@@ @ending from @@po@pt
Tue May 22 12:47:09 CEST 2018


Hello,

Right!
I copied from the OP's question without thinking about it.
Corrected would be


bootMedianSE <- function(data, indices){
     d <- data[indices, ]
     fit <- rq(crp ~ bmi + glucose, tau = 0.5, data = d)
     ypred <- predict(fit)
     y <- d$crp
     median((y - ypred)^2)
}

Sorry,

rui Barradas

On 5/22/2018 11:32 AM, Daniel Nordlund wrote:
> On 5/22/2018 2:32 AM, Rui Barradas wrote:
>> bootMedianSE <- function(data, indices){
>>       d <- data[indices, ]
>>       fit <- rq(crp ~ bmi + glucose, tau = 0.5, data = d)
>>       ypred <- predict(fit)
>>       y <- d$crp
>>       median(y - ypred)^2
>> }
> 
> since the OP is looking for the "median squared error", shouldn't the 
> final line of the function be
> 
>          median((y - ypred)^2)
> 
> 
> Dan
>



More information about the R-help mailing list