[R] how to extract predicted values from a quantreg fit?

Denis Chabot chabotd at globetrotter.net
Sun Feb 5 01:54:35 CET 2006


Hi,

I have used package quantreg to estimate a non-linear fit to the  
lowest part of my data points. It works great, by the way.

But I'd like to extract the predicted values. The help for  
predict.qss1 indicates this:

predict.qss1(object, newdata, ...)
and states that newdata is a data frame describing the observations  
at which prediction is to be made.

I used the same technique I used to extract predicted values of GAM  
fits with mgcv package: if I fit a GAM using x as the x variable on  
which I smooth, I then create such a dataframe like this

MyX <- data.frame(x=seq(-1,60))

This works fine with GAM (mgcv) but not with quantreg:

 > y <- rnorm(500, 10, 5)
 > x <- rep(seq(1,50,1), 10)
 > My.data <- data.frame(x, y)
 > My.x <- data.frame(x=seq(5,45))
 >
 > fit <- rqss(y ~ qss(x, lambda=5), tau=0.05)
 > pred <- predict.qss1(fit, My.x)

Could someone please help me creating a dataframe "newdata" that  
would satisfy predict.qss1?

Thanks in advance,

Denis Chabot




More information about the R-help mailing list