[R-SIG-Finance] Quantile Regression-Fit Stock data
Dirk Eddelbuettel
edd at debian.org
Sat Dec 4 18:59:56 CET 2010
On 4 December 2010 at 09:28, Ronald McEwan wrote:
| I am new to R
Well, welcome! But one piece of advice: you cross-posted at StackOverflow
and here. Cross-posting is seen as distasteful. Don't do it.
| and I am trying to reproduce some of my Excel models in R. In this
| project I am trying to perform a Quantile Regression on two Securities. I am not
| able to get the rq() function to read the stock data I retrieve. From what I
| have read so far I think I have to provide a definition for the data to enable
| rq() to recognize it. I have not had success with this so far. I would
| appreciate advice on how to define the stock market data in a way that the
| function will recognize the data as a valid input. This is what I have so far.
As I told you in an answer on SO which you chose to ignore so far, you also
seem to regress _prices_ on _prices_. I gave you the Granger and Newbold
reference on spurious regression that predates unit roots, cointegrations and
all that -- don't work in prices, work in returns.
Cheers, Dirk
| Thanks,
| Regards,
| Ron McEwan
|
|
| # Quantile Regression - Fit Stock data
|
| # Get Library
|
| library(quantmod)
| library(quantreg)
|
| # Get Stock Data
|
| stk1 <- getSymbols("DD", from="2009-12-31", auto.assign=FALSE)
| stk2 <- getSymbols("GE", from="2009-12-31", auto.assign=FALSE)
|
| # perform quantile regression procedures
|
| #median (l1) regression fit for the stock data.
|
| rq(stk1 ~ stk2,.5)
|
| #the 1st quartile,
|
| rq(stk1 ~ stk2,.25)
|
| #note that 8 of the 21 points lie exactly on this plane in 4-space!
| #this returns the full rq process
|
| rq(stk1 ~ stk2, tau=-1)
|
| #ordinary sample median --no rank inversion ci
|
| rq(rnorm(50) ~ 1, ci=FALSE)
|
| #weighted sample median
|
| rq(rnorm(50) ~ 1, weights=runif(50),ci=FALSE)
|
|
|
|
| [[alternative HTML version deleted]]
|
| _______________________________________________
| R-SIG-Finance at r-project.org mailing list
| https://stat.ethz.ch/mailman/listinfo/r-sig-finance
| -- Subscriber-posting only. If you want to post, subscribe first.
| -- Also note that this is not the r-help list where general R questions should go.
--
Dirk Eddelbuettel | edd at debian.org | http://dirk.eddelbuettel.com
More information about the R-SIG-Finance
mailing list