Davey, Andrew
2011-Jan-11 09:54 UTC
[R] Confidence interval on quantile regression predictions
I am using the quantreg package to build a quantile regression model and wish to generate confidence intervals for the fitted values. After fitting the model, I have tried running predict() and predict.rq(), but in each case I obtain a vector of the fitted values only. For example: library(quantreg) y<-rnorm(50,10,2) x<-seq(1,50,1) model<-rq(y~x,tau=0.5,method="br",model=TRUE) model$fitted predict(model,type=c("percentile"),interval=c("confidence"),level=0.95) #returns same output as model$fitted Am I missing something obvious? I have tried altering the settings for the type and interval arguments but without success. (I am running R v 2.10.1). Thank you for your help. Regards, Andrew Davey Senior Consultant Tel: + 44 (0) 1793 865023 Mob: +44 (0) 7747 863190 Fax: + 44 (0) 1793 865001 E-mail: andrew.davey@wrcplc.co.uk Website: www.wrcplc.co.uk P Before printing, please think about the environment. ------------------------------------------------------------------------------------------- To read our latest newsletter visit http://www.wrcplc.co.uk/default.aspx?item=835 - Keeping our clients up-to-date with WRc's business developments ------------------------------------------------------------------------------------------- Visit our websites www.wrcplc.co.uk and www.wrcnsf.com, as well as www.waterportfolio.com for collaborative research projects. ------------------------------------------------------------------------------------------- The Information in this e-mail is confidential and is intended solely for the addressee. Access to this e-mail by any other party is unauthorised. If you are not the intended recipient, any disclosure, copying, distribution or any action taken in reliance on the information contained in this e-mail is prohibited and maybe unlawful. When addressed to WRc Clients, any opinions or advice contained in this e-mail are subject to the terms and conditions expressed in the governing WRc Client Agreement. ------------------------------------------------------------------------------------------- WRc plc is a company registered in England and Wales. Registered office address: Frankland Road, Blagrove, Swindon, Wiltshire SN5 8YF. Company registration number 2262098. VAT number 527 1804 53. ------------------------------------------------------------------------------------------- [[alternative HTML version deleted]]
Roger Koenker
2011-Jan-11 13:49 UTC
[R] Confidence interval on quantile regression predictions
You need to add explicitly newdata = list(x=x) and if you want percentile method you also need se = "boot". Roger Koenker rkoenker at illinois.edu On Jan 11, 2011, at 3:54 AM, Davey, Andrew wrote:> I am using the quantreg package to build a quantile regression model and > wish to generate confidence intervals for the fitted values. > > After fitting the model, I have tried running predict() and > predict.rq(), but in each case I obtain a vector of the fitted values > only. > > For example: > > library(quantreg) > y<-rnorm(50,10,2) > x<-seq(1,50,1) > model<-rq(y~x,tau=0.5,method="br",model=TRUE) > model$fitted > predict(model,type=c("percentile"),interval=c("confidence"),level=0.95) > #returns same output as model$fitted > > Am I missing something obvious? I have tried altering the settings for > the type and interval arguments but without success. > > (I am running R v 2.10.1). > > Thank you for your help. > > Regards, > > > Andrew Davey > Senior Consultant > > Tel: + 44 (0) 1793 865023 > Mob: +44 (0) 7747 863190 > Fax: + 44 (0) 1793 865001 > E-mail: andrew.davey at wrcplc.co.uk > Website: www.wrcplc.co.uk > P Before printing, please think about the environment. > > ------------------------------------------------------------------------------------------- > To read our latest newsletter visit http://www.wrcplc.co.uk/default.aspx?item=835 - Keeping our clients up-to-date with WRc's business developments > ------------------------------------------------------------------------------------------- > Visit our websites www.wrcplc.co.uk and www.wrcnsf.com, as well as www.waterportfolio.com for collaborative research projects. > ------------------------------------------------------------------------------------------- > The Information in this e-mail is confidential and is intended solely for the addressee. Access to this e-mail by any other party is unauthorised. If you are not the intended recipient, any disclosure, copying, distribution or any action taken in reliance on the information contained in this e-mail is prohibited and maybe unlawful. When addressed to WRc Clients, any opinions or advice contained in this e-mail are subject to the terms and conditions expressed in the governing WRc Client Agreement. > ------------------------------------------------------------------------------------------- > WRc plc is a company registered in England and Wales. Registered office address: Frankland Road, Blagrove, Swindon, Wiltshire SN5 8YF. Company registration number 2262098. VAT number 527 1804 53. > ------------------------------------------------------------------------------------------- > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code.