yegcm | R Documentation |
Fetches the Yahoo! price series for two securities and constructs an Engle-Granger cointegration model from them
yegcm(ticker1, ticker2, start = format(Sys.Date() - 365, "%Y-%m-%d"), end = format(Sys.Date(), "%Y-%m-%d"), clear.na.inf=TRUE, ...)
ticker1 |
the ticker symbol of the first security |
ticker2 |
the ticker symbol of the second security |
start |
starting date, given in the format "YYYY-MM-DD". Default: One year ago. |
end |
ending date, given in the format "YYYY-MM-DD". Default: Today. |
clear.na.inf |
if TRUE, NA and Inf price values are replaced by the last available price. Default:TRUE. |
... |
additional parameters passed to |
Uses the getSymbols
function of the quantmod
package
to retrieve the adjusted closing prices of the two securities over
the specified date range. Then, constructs an Engle-Granger cointegration
model from this data, and returns it.
An Engle-Granger cointegration model
Matthew Clegg matthewcleggphd@gmail.com
Engle, R. F. and C. W. Granger. (1987) Co-integration and error correction: representation, estimation, and testing. Econometrica, 251-276.
egcm getSymbols
e <- yegcm("SPY", "VOO", start="2013-01-01", end="2014-01-01") print(e) plot(e) summary(e)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.