Description Usage Arguments Details Value Author(s) Examples
View source: R/Cointegration.R
Estimate parameters(spread, premium, cointegration coefficient) at any point by regression(default linear regression).
1 | EstimateParameters(price.pair, method = lm)
|
price.pair |
pair stock price (xts object) |
method |
estimation method.(see also) |
"method" is any regression method which returns a result with "$coef" attribute. "$coef[1]" should be regression intercept(means premium) and "$coef[2]" should be regression coefficient(headge.ratio).
return a list consisting of elements below.
spread |
xts object. "residual" in regression |
hedge.ratio |
scalar value. "coefficient" in regression |
premium |
scalar value. "intercept" in regression |
Shinichi Takayanagi, Kohta Ishikawa
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | #load library
library(PairTrading)
#load sample stock price data
data(stock.price)
#select 2 stocks
price.pair <- stock.price[,1:2]["2008-12-31::"]
#Estimate parameters & plot spread
reg <- EstimateParameters(price.pair, method = lm)
str(reg)
plot(reg$spread)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.