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
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
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"
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
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
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
6 matches
Mail list logo