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

View source: R/egcm_extras.R

yegcmR Documentation

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,
      ...)

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

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.

Value

An Engle-Granger cointegration model

Author(s)

Matthew Clegg matthewcleggphd@gmail.com

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


e <- yegcm("SPY", "VOO", start="2013-01-01", end="2014-01-01")
print(e)
plot(e)
summary(e)


matthewclegg/egcm documentation built on March 5, 2023, 6:33 a.m.