[R] Bootstrap and average median squared error

varin sacha v@r|n@@ch@ @end|ng |rom y@hoo@|r
Thu May 24 00:00:36 CEST 2018


Hi Rui and Daniel,
Many thanks for your responses. It perfectly works.
Best,
 

    Le mardi 22 mai 2018 à 12:47:14 UTC+2, Rui Barradas <ruipbarradas using sapo.pt> a écrit :  
 
 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
> 
  
	[[alternative HTML version deleted]]




More information about the R-help mailing list