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

# Re: st: Margins command

 From "Michael N. Mitchell" <[email protected]> To [email protected] Subject Re: st: Margins command Date Thu, 13 Jan 2011 21:39:46 -0800

```Dear Robin

```
I could not find anything in the help file that addressed this, so I made a simple example and it looks like -margins- is doing the computation based on the estimation sample. In the example below, the -regress- command yields N=22, and then the -margins- command also reflects N=22.
```
sysuse auto
(1978 Automobile Data)

. regress price weight if foreign==1

Source |       SS       df       MS              Number of obs =      22
-------------+------------------------------           F(  1,    20) =   72.66
Model |   113204096     1   113204096           Prob > F      =  0.0000
Residual |  31159116.4    20  1557955.82           R-squared     =  0.7842
Total |   144363213    21   6874438.7           Root MSE      =  1248.2

------------------------------------------------------------------------------
price |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
weight |    5.36204   .6290375     8.52   0.000     4.049891    6.674189
_cons |  -6033.316     1480.9    -4.07   0.001    -9122.419   -2944.213
------------------------------------------------------------------------------

. margins , at(weight=3000)

Adjusted predictions                              Number of obs   =         22
Model VCE    : OLS

Expression   : Linear prediction, predict()
at           : weight          =        3000

------------------------------------------------------------------------------
|            Delta-method
|     Margin   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
_cons |    10052.8    505.955    19.87   0.000     9061.151    11044.46
------------------------------------------------------------------------------

I hope this helps,

Michael N. Mitchell
Data Management Using Stata      - http://www.stata.com/bookstore/dmus.html
A Visual Guide to Stata Graphics - http://www.stata.com/bookstore/vgsg.html
Stata tidbit of the week         - http://www.MichaelNormanMitchell.com

On 2011-01-13 9.29 PM, Robin Jeffries wrote:
```
```If I run a regression on a subset, for example

xtlogit outcome var1 var2 if level==0

margins var1, at var2=1 predict(pu0)

Will the predictions be for everyone? Or for those with level==0 only?

-Robin Jeffries
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/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/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/
```