Learn R Programming

egcm (version 1.0.13)

yegcm: Engle-Granger cointegration model from Yahoo! price series

Description

Fetches the Yahoo! price series for two securities and constructs an Engle-Granger cointegration model from them

Usage

yegcm(ticker1, 
      ticker2, 
      start = format(Sys.Date() - 365, "%Y-%m-%d"),
      end = format(Sys.Date(), "%Y-%m-%d"),
      clear.na.inf=TRUE,
      ...)

Value

An Engle-Granger cointegration model

Arguments

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 egcm

Author

Matthew Clegg matthewcleggphd@gmail.com

Details

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.

References

Engle, R. F. and C. W. Granger. (1987) Co-integration and error correction: representation, estimation, and testing. Econometrica, 251-276.

See Also

egcm getSymbols

Examples

Run this code
# \donttest{
e <- yegcm("SPY", "VOO", start="2013-01-01", end="2014-01-01")
print(e)
plot(e)
summary(e)
# }

Run the code above in your browser using DataLab