Bookmark and Share

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


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

st: does -margins- work after -menbreg- or -mepoisson- in Stata 13?


From   [email protected] (Rafal Raciborski, StataCorp)
To   [email protected]
Subject   st: does -margins- work after -menbreg- or -mepoisson- in Stata 13?
Date   Mon, 12 Aug 2013 15:53:25 -0500

Steve Rothenberg <[email protected]> is trying to use -margins- after
-menbreg- but -margins- complains:

> I'm trying to use -margins- after -menbreg-.  No matter how I set up
> the -margins- command, I receive the following error message:
> 
> default prediction is a function of possibly stochastic quantities other
> than e(b)
> r(498);

Ariel Linden <[email protected]> notes that -margins- works after
-mixed- but not after a linear mixed model estimated by -meglm-.

> ... I receive the same error when using -meglm- ... Substituting -mixed- for
> -meglm- works fine.

-margins- requires that all quantities needed to produce the requested margins
are available for the prediction calculation.  Namely, it requires that the
prediction is only a function of -e(b)- and the independent variables in the
model.  The default prediction for the new -me- commands is the mean response
-mu- which is calculated as

        g^{-1}(X*b + Z*u)

where X in X*b is the list of fixed predictors (independent variables),
Z in Z*u is the list of random predictors (also independent variables),
and g^{-1} is the inverse link function that maps the linear prediction to the
mean response.

The only unknown thing here is 'u'.  The random effects 'u' are not variables
in the dataset; however, they can be substituted with empirical Bayes'
estimates.  The empirical Bayes' estimates are computed using the X, b, Z, and
the dependent variable from the original estimation sample.

-margins- will exit with an error if any prediction it is working on depends
on anything other than X, b, or Z.

-margins- can be used to calculate margins of predictions that are functions
of only the fixed effects.

  . webuse melanoma, clear
  . menbreg deaths c.uv##c.uv, exposure(expected) || nation: || region:
  . margins, predict(mu fixedonly)

The reason -margins- works after -mixed- without complaining is that the
default prediction after -mixed- is -xb- which is a function of only the fixed
effects.

-- Rafal
[email protected]

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index