EstimateParameters: Estimate parameters at any point.

Description Usage Arguments Details Value Author(s) Examples

View source: R/Cointegration.R

Description

Estimate parameters(spread, premium, cointegration coefficient) at any point by regression(default linear regression).

Usage

1
EstimateParameters(price.pair, method = lm)

Arguments

price.pair

pair stock price (xts object)

method

estimation method.(see also)

Details

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

Value

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

Author(s)

Shinichi Takayanagi, Kohta Ishikawa

Examples

 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)

PairTrading documentation built on May 2, 2019, 6:11 p.m.