[R-SIG-Finance] Time-Varying Cointegration in R

Paul Gilbert pgilbert902 at gmail.com
Tue Mar 22 19:55:22 CET 2016


Johannes

Ordering complex numbers is not obvious, so one likely thing would be 
that you have the same result but in a different order. If the 
eigenvalues are the same, only the vectors are different, it is a 
normalization issue. If it is not that, then verify that you are 
calculating eigenvalues with the same matrix in both systems. A matrix 
that has several orders of magnitude difference between the largest and 
smallest eigenvalues (in abs value) will be ill-conditioned, in which 
case the result can differ a lot based on seemingly small differences in 
the matrix. You can verify if this is a problem by copy and paste of 
exactly the same matrix into both systems. (Round to a reasonable number 
of digits and truncate the rest.)

BTW, if ill-conditioning is the problem, and the results depend 
critically on this calculation, there is a problem with the technique.

If those are not the problem, then you might consider checking which 
result is correct. This problem does have an answer that can be 
verified.  From ?eigen

    If ‘r <- eigen(A)’, and ‘V <- r$vectors; lam <- r$values’, then

                               A = V Lmbd V^(-1)

      (up to numerical fuzz), where Lmbd =‘diag(lam)’.

Please let us know if R is getting an incorrect result. It seems highly 
unlikely, but it might affect a lot of calculations.

HTH,
Paul

On 03/22/2016 05:14 AM, Johannes Lips wrote:
> Dear list,
>
> I've implemented the time-varying cointegration framework by Bierens and
> Martins (2010) in R [1], based on the gauss implementation of Luis
> Martins [2]. I do get the same results as in gauss, when using lower
> chebyshev dimensions, but when the number of dimensions is increasing, I
> run into issues with complex eigenvalues and eigenvectors.
> Additionally the eigenvalues and eigenvectors differ quite a bit between
> gauss and R and I do not really know how to find out why that is. I also
> experimented with different implementations of eigenvalues
> determination, based on the C++ routine eigen, but was not able to
> replicate the gauss results exactly.
> One notable difference is that gauss does not normalize the
> eigenvectors, but even after considering this a discrepancy remains.
> Perhaps someone with a better knowledge of gauss may shed some light on
> possible sources for these differences.
>
>
>
> [1] https://github.com/hannes101/TimeVaryingCointegration
> [2] http://home.iscte-iul.pt/~lfsm/
>
> 	[[alternative HTML version deleted]]
>
> _______________________________________________
> R-SIG-Finance at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-sig-finance
> -- Subscriber-posting only. If you want to post, subscribe first.
> -- Also note that this is not the r-help list where general R questions should go.
>



More information about the R-SIG-Finance mailing list