Re: [R] Bootstrap and average median squared error

2018-05-23 Thread varin sacha via R-help
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 a écrit : Hello, Right! I copied from the OP's question without thinking about it. Corrected would be bootMedianSE <- function(data, indices){     d <- d

Re: [R] Bootstrap and average median squared error

2018-05-22 Thread Rui Barradas
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

Re: [R] Bootstrap and average median squared error

2018-05-22 Thread Daniel Nordlund
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"

Re: [R] Bootstrap and average median squared error

2018-05-22 Thread Rui Barradas
I forgot, you should also set.seed() before calling boot() to make the results reproducible. Rui Barradas On 5/22/2018 10:00 AM, Rui Barradas wrote: Hello, If you want to bootstrap a statistic, I suggest you use base package boot. You would need the data in a data.frame, see how you could do

Re: [R] Bootstrap and average median squared error

2018-05-22 Thread Rui Barradas
Hello, If you want to bootstrap a statistic, I suggest you use base package boot. You would need the data in a data.frame, see how you could do it. library(boot) bootMedianSE <- function(data, indices){ d <- data[indices, ] fit <- rq(crp ~ bmi + glucose, tau = 0.5, data = d) ypred

[R] Bootstrap and average median squared error

2018-05-21 Thread varin sacha via R-help
Dear R-experts, I am trying to bootstrap (and average) the median squared error evaluation metric for a robust regression. I can't get it. What is going wrong ? Here is the reproducible example. # install.packages( "quantreg" ) library(quantreg) crp <-c(12,14,13,24