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]

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


From   "Ariel Linden, DrPH" <[email protected]>
To   <[email protected]>
Subject   re: st: does -margins- work after -menbreg- or -mepoisson- in Stata 13?
Date   Mon, 12 Aug 2013 19:36:39 -0400

Thank you, Rafal. This is extremely helpful. I intuited that the error was
related to differentiating between the fixed and random effects.

It would be helpful if the relevant help files and manual entries, were to
state what you wrote below. Even more specifically, I can't seem to find the
post-estimation -margins- for these commands. I am not sure if they are
there and I am not finding them, or they are just not available? In any
case, the issue that you raise (and the solution) should be made easy to
find...

Thanks again!

Ariel  



________________________________________
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/



*
*   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