Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.

# st: Margins & marginsplot with a multi-level model

 From Kendra Lewis To statalist@hsphsun2.harvard.edu Subject st: Margins & marginsplot with a multi-level model Date Tue, 1 May 2012 16:33:19 -0700

```Hello,

I am running an xtmelogit model, and would like to run the margins &
marginsplot commands afterwards, but am receiving an error. If I take
out the "cluster" variable and run a logit model, the commands work
just fine.

Here is the model, followed by the error message:

. xtmelogit drunkt5 drugedt5##treatms  if drunkt1  == 0 ||cluster:

Refining starting values:

Iteration 0:   log likelihood = -3988.7591  (not concave)
Iteration 1:   log likelihood = -3952.4376
Iteration 2:   log likelihood = -3952.1877

Iteration 0:   log likelihood = -3952.1877
Iteration 1:   log likelihood = -3952.1877

Mixed-effects logistic regression               Number of obs      =      8547
Group variable: cluster                         Number of groups   =        82

Obs per group: min =         5
avg =     104.2
max =       347

Integration points =   7                        Wald chi2(3)       =     31.01
Log likelihood = -3952.1877                     Prob > chi2        =    0.0000

----------------------------------------------------------------------------------
drunkt5 |      Coef.   Std. Err.      z    P>|z|     [95%
Conf. Interval]
-----------------+----------------------------------------------------------------
1.drugedt5 |   .3720199   .0954558     3.90   0.000     .1849299
.5591099
1.treatms |   .5823083   .1318417     4.42   0.000     .3239032
.8407133
|
drugedt5#treatms |
1 1  |    -.73265   .1383434    -5.30   0.000    -1.003798
-.4615019
|
_cons |  -1.741293   .0788033   -22.10   0.000    -1.895744
-1.586841
----------------------------------------------------------------------------------

------------------------------------------------------------------------------
Random-effects Parameters  |   Estimate   Std. Err.     [95% Conf. Interval]
-----------------------------+------------------------------------------------
cluster: Identity            |
sd(_cons) |   .3424621   .0427972      .2680641    .4375085
------------------------------------------------------------------------------
LR test vs. logistic regression: chibar2(01) =    70.20 Prob>=chibar2 = 0.0000
r; t=5.95 15:39:50

. margins drugedt5, at(treatms= (0 1))
default prediction is a function of possibly stochastic quantities
other than e(b)
r(498); t=0.78 15:40:40

Any suggestions? Thanks!

--
Kendra Lewis, Ph.D.
Certified Family Life Educator (provisional)