Skip to content

missing tools: canonical correlation and ranktest #1111

Open

Description

@josef-pkt

http://ideas.repec.org/c/boc/bocode/s456865.html

used by ivreg for underidentification tests
I guess it should also be useful for sysreg

Johansen's cointegration test is also a test for matrix rank, but I didn't try to understand the details.

This would fit in statsmodels stats.

(Related other location for regression helpers is in statsmodels.tools and spread out
Where do I put a partial function for partialling out variables in linear regression?)

Activity

  1. josef-pkt commented on Oct 10, 2013

    @josef-pkt
    MemberAuthor

    trying an example

    After canon Stata reports all the usual multivariate or repeated ANOVA statistics. Another place for sharing code?

    . canon (length weight headroom trunk) (displ mpg gear_ratio turn)
    
    Canonical correlation analysis                         Number of obs =      74
    
    Raw coefficients for the first variable set
    
                     |        1         2         3         4 
        -------------+----------------------------------------
              length |   0.0095    0.1441    0.0329    0.0212 
              weight |   0.0010   -0.0037   -0.0010    0.0007 
            headroom |   0.0351   -0.3701    1.5361   -0.0440 
               trunk |  -0.0023   -0.0343   -0.2135   -0.3253 
        ------------------------------------------------------
    
    Raw coefficients for the second variable set
    
                     |        1         2         3         4 
        -------------+----------------------------------------
        displacement |   0.0054   -0.0125    0.0191   -0.0005 
                 mpg |  -0.0461   -0.0413    0.0683    0.2478 
          gear_ratio |   0.0330    1.0280    3.6596   -1.0311 
                turn |   0.0794    0.3113    0.0033    0.2240 
        ------------------------------------------------------
    
    ----------------------------------------------------------------------------
    Canonical correlations:
      0.9476  0.3400  0.0634  0.0447
    
    ----------------------------------------------------------------------------
    Tests of significance of all canonical correlations
    
                             Statistic      df1      df2            F     Prob>F
             Wilks' lambda    .0897314       16  202.271      15.1900     0.0000 a
            Pillai's trace     1.01956       16      276       5.9009     0.0000 a
    Lawley-Hotelling trace     8.93344       16      258      36.0129     0.0000 a
        Roy's largest root     8.79667        4       69     151.7426     0.0000 u
    ----------------------------------------------------------------------------
                                e = exact, a = approximate, u = upper bound on F
    
    
  2. josef-pkt commented on Oct 12, 2013

    @josef-pkt
    MemberAuthor

    first version included in gmm_new PR #1105
    ranktest assumes iid. no Kleibergen and Paap 2006 for robust cov_params yet

  3. jseabold commented on Oct 12, 2013

    @jseabold
    Member

    sklearn includes an implementation of canonical correlation using partial least squares, but I never tried to connect it to Stata's canon.

  4. josef-pkt commented on Oct 12, 2013

    @josef-pkt
    MemberAuthor

    I looked at it briefly to see whether I want to reuse it for the ranktest.
    It's many lines of code, all methods mixed together, and doing many things that I didn't need in this case.

    my version is essentially 4 lines of code to get the correlations. (One of the definitions that I saw looked like 2 pinv and an eigvals.)
    I don't think sklearn has statistics like Pillai's trace, ....

    Looking at sklearn will be useful when we want to get more multivariate analysis.

  5. added this to the 0.9 milestone on Jun 24, 2016
  6. josef-pkt commented on Jun 24, 2016

    @josef-pkt
    MemberAuthor

    https://github.com/statsmodels/statsmodels/blob/master/statsmodels/stats/multivariate_tools.py
    has the basic canonical correlation, needs to move to statsmodels.multivariate

    related reduced rank regression #2625
    Johansen also has some notes on it

  7. modified the milestones: 0.9, 0.10 on Dec 23, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions