Skip to content

ENH/Design mixedlm params versus summary #2231

Open

Description

@josef-pkt

I'm checking t_test and wald_test for mixed_lm using the examples/notebooks/mixed_lm_example

summary shows different params for the random effects than the attribute in the second example. design or bug?

md = smf.mixedlm("Weight ~ Time", data, groups=data["Pig"], re_formula="~Time")
mdf = md.fit()
print(mdf.summary())

              Mixed Linear Model Regression Results
=================================================================
Model:               MixedLM    Dependent Variable:    Weight    
No. Observations:    861        Method:                REML      
No. Groups:          72         Scale:                 6.0374    
Min. group size:     11         Likelihood:            -2217.0475
Max. group size:     12         Converged:             Yes       
Mean group size:     12.0                                        
-----------------------------------------------------------------
                       Coef.  Std.Err.   z    P>|z| [0.025 0.975]
-----------------------------------------------------------------
Intercept              15.739    0.550 28.609 0.000 14.661 16.817
Time                    6.939    0.080 86.927 0.000  6.783  7.095
Intercept RE           19.493    1.572                           
Intercept RE x Time RE  0.294    0.154                           
Time RE                 0.416    0.033                           
=================================================================

In [21]: mdf.params
Out[21]:
Intercept                 15.738766
Time                       6.939014
Intercept RE               1.796876
Intercept RE x Time RE     0.027083
Time RE                   -0.261114
dtype: float64

In [18]: mdf.t_test(np.eye(len(mdf.params)))
Out[18]:
<class 'statsmodels.stats.contrast.ContrastResults'>
                             Test for Constraints                             
==============================================================================
                 coef    std err          z      P>|z|      [95.0% Conf. Int.]
------------------------------------------------------------------------------
c0            15.7388      0.550     28.609      0.000        14.661    16.817
c1             6.9390      0.080     86.927      0.000         6.783     7.095
c2             1.7969      0.640      2.808      0.005         0.543     3.051
c3             0.0271      0.063      0.433      0.665        -0.096     0.150
c4            -0.2611      0.013    -19.386      0.000        -0.288    -0.235
==============================================================================

Activity

  1. added this to the 0.7 milestone on Feb 6, 2015
  2. josef-pkt commented on Feb 6, 2015

    @josef-pkt
    MemberAuthor

    related: the notebook doesn't show up in the documentation on the web site

  3. josef-pkt commented on Feb 6, 2015

    @josef-pkt
    MemberAuthor

    another question: Why does summary of mixedlm not show the inference, bse, ... for the random effects?
    AFAICS: the cov_params is available for them

    correction: the summary shows bse of random effects parameters
    variance parameters = 0 are on boundary of the parameter space and standard wald test doesn't apply.

    tvalues and pvalues look generic and are available also for the RE parameters

  4. kshedden commented on Feb 6, 2015

    @kshedden
    Contributor

    I can look into this in more detail later, but I'm pretty sure the issue is that the 'params' that lilkelihood actually sees contains the Cholesky factor of the random effects covariance matrix (for easier numerical performance), but the 'params' that we need to show in the summary is the actual covariance matrix. There is some rather complicated code to convert between the two.

  5. josef-pkt commented on Feb 6, 2015

    @josef-pkt
    MemberAuthor

    Ok, I started to suspect that.

    I'm just a naive user who starts with an example and pushes all the usual buttons, and didn't read the manual.

    I think the main task would be to provide more information in the summary so it's less confusing for users that don't read the manual or don't remember what's in it.

    t_test and wald_test for mean parameters are working without problems. However, there is no indication in "naive" use that testing random effects parameters might not make sense or does not do what we might think it does.

    I will remove the bug label and push it to 0.8.
    This is essentially the first model that has variance parameters as part of the MLE, and we should figure out something to make the use more "obvious".

  6. changed the title [-]BUG? mixedlm params versus summary[/-] [+]ENH/Design mixedlm params versus summary[/+] on Feb 6, 2015
  7. modified the milestones: 0.8, 0.7 on Feb 6, 2015
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