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

Dieter Menne dieter.menne at menne-biomed.de
Mon Feb 6 09:37:01 CET 2006


Denis Chabot <chabotd <at> globetrotter.net> writes:

.... Quantreg package ....

> 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.
..
> 
>  > 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?

Looks like quantreg has been reworked, but predict was not tested. 
Checking the code, I got a (hopefully) working solution

pred <- predict.qss1(fit$qss[[1]]$xyz, My.x$x)

but this follow neither convention nor documentation. Maybe you should contact
the author of the package to provide an example in the documentation, which
would have show the problem earlier.

Dieter




More information about the R-help mailing list