pythonslicestatsmodelsp-valuemanova

Extract only p-value from MANOVA test result with statsmodel


I have run MANOVA test with statsmodel as following:

manova = MANOVA(endog=X, exog=y)

print(manova.mv_test())

as a result I have gotten the following table:

                 Multivariate linear model
============================================================
                                                            
------------------------------------------------------------
           x0           Value  Num DF  Den DF F Value Pr > F
------------------------------------------------------------
          Wilks' lambda 0.7762 5.0000 28.0000  1.6148 0.1887
         Pillai's trace 0.2238 5.0000 28.0000  1.6148 0.1887
 Hotelling-Lawley trace 0.2884 5.0000 28.0000  1.6148 0.1887
    Roy's greatest root 0.2884 5.0000 28.0000  1.6148 0.1887
============================================================

my question is, how do I extract only the p-value? following this post I have tried that:

 print(manova.mv_test().results['x0']['stat'].values['Hotelling-Lawley trace',4])

but I got index error and also i'm not sure I understand the logic behind it.

IndexError: only integers, slices (:), ellipsis (...), numpy.newaxis (None) and integer or boolean arrays are valid indices

My end goal is to save only the p-value as new variable, e.g to "Extract" the p-value from the table.

maybe understnading how this table is generated could also help, as i'm not sure what is this (it is table that is not pandas and doesn't look like matrix so how can I slice anything from there?)


Solution

  • I was able to solve the same problem with this line, which in your case should be:

    x = pd.DataFrame((manova.mv_test().results['x0']['stat']))
    

    Now you could select any result.