Login
Login

Re: AugmentedDickeyFuller and different result in R

Home 21090308 Forums Re: AugmentedDickeyFuller and different result in R

#2143
andreynado
Member

My goal is to rate a pair of securities from mean reverting perspective. Cointegration seemed to be a good tool for my little research so I’ve decided to use Engle-Granger two-step method to get this kind of rating. I’m a Java developer but I haven’t found a good Java library so I implemented it in R first. But that was my first experience with R so the quality of the code is most likely poor.

The code simply reads EOD stock data downloaded from Yahoo, computes linear regression and then uses ADF test to check if the spread series is stationary. I use the pValue to rate the two stocks for cointegration.

Then a couple of days ago I found this library and tried too implement it in Java. But the result is different. So please help me either with R or Java to get the same results. Or perhaps the whole cointegration idea is wrong and I should use a different stats tool.

Again the code simply reads the downloaded data, calculates a linear regression (here the results are the same as in R) and then it uses AugmentedDickeyFuller to calculate pValue. Which is different than the p.value in R. R gives something like 0.3563176 and SuanShu gives 0.2. I even wonder why SuanShu gives only one decimal digit precision.

There is a small issue with the library because I had a trial license only couple of days and you haven’t issued a new one for March. So I cannot run my example right now.