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

# st: Re: statalist-digest V4 #4057

 From "Alistair Windsor (U of M)" To statalist@hsphsun2.harvard.edu Subject st: Re: statalist-digest V4 #4057 Date Mon, 07 Feb 2011 09:57:20 -0600

```Dear Hafidha,

```
Perhaps we need to take a step back and ask what Hafidha is looking for. As Steve's first post indicates there is no concept of "marginal effect" for the dependent variable. The marginal effect is the effect on the dependent variable of a change in an independent variable. Ssince this is a linear regression this effect is thankfully independent of the values of the other variables. Indeed for this linear regression there is no need to run mfx since the result is just the same as the coefficients and linearized standard errors. the mfxcommand just reproduces the results of the regression minus the constant.
```
```
To get the standard error of the predicted value at the the means we would do the following
```
mean predicted y = mean y

variance of predicted y at mean x is

x^t sigma^2 (X^t X)^-1 x

```
where X is the matrix of regressors and x is the vector of means (and a 1 entry for the constant).
```
The matrix sigma^2 (X^t X)^-1 is available as e(V) after your reg command.

```
If you form the appropriate vector x (means) then you should be able to get the standard error by doing something like
```
mat s = x'*e(V)*x
mat lis s

though I am far from an expert in matrix manipulation in Stata.

```
Hopefully all your categorical variables have been expanded into 0 1 dummy variables. In this case the means are simply proportions of 1s in your data.
```
Hope that helps,

Alistair

On 2/7/11 1:33 AM, statalist-digest wrote:
```
```Date: Sun, 6 Feb 2011 19:02:37 +0700
From: Nur Hafidha Hikmayani<nhhikmayani@gmail.com>
Subject: st: Obtaining 95%CI for marginal effect

Dear all,
I've been running some regression models using -svy- and estimating
its marginal effect using -mfx- (I use Stata 10.1).
I wonder how can I get the 95% CI for the marginal effects (y)?

The output for regression and its marginal effect are as follows:

. xi: svy: reg GH i.medgrp exgrp chronic nummed gp
- ------------------------------------------------------------------------------
|             Linearized
GH |      Coef.   Std. Err.      t    P>|t|       [95% Conf. Interval]
- -------------+----------------------------------------------------------------
_Imedgrp_1 |   4.429839    3.56263     1.24   0.214    -2.564628    11.42431
_Imedgrp_2 |   8.333728   3.633545     2.29   0.022     1.200035    15.46742
_Imedgrp_3 |   10.05818   3.773961     2.67   0.008     2.648813    17.46755
exgrp |  -8.916839    1.89046    -4.72   0.000    -12.62835   -5.205324
chronic |  -10.31767   1.936802    -5.33   0.000    -14.12017   -6.515169
nummed |  -1.063043   .3452676    -3.08   0.002    -1.740902   -.3851831
gp |  -4.347845   1.773649    -2.45   0.014    -7.830027    -.865663
_cons |   83.19335   3.520136    23.63   0.000     76.28231    90.10438
- ------------------------------------------------------------------------------

. mfx, at(mean _Imedgrp_1=0 _Imedgrp_2=0)
Marginal effects after svy:regress
y  = Fitted values (predict)
=  53.085624
- ------------------------------------------------------------------------------
variable |      dy/dx    Std. Err.     z    P>|z|    [    95% C.I.   ]      X
- ---------+--------------------------------------------------------------------
_Imedg~1*|   4.429839     3.56263    1.24   0.214  -2.55279  11.4125         0
_Imedg~2*|   8.333728     3.63354    2.29   0.022   1.21211  15.4553   .379185
_Imedg~3*|   10.05818     3.77396    2.67   0.008   2.66136   17.455         0
exgrp*|  -8.916839     1.89046   -4.72   0.000  -12.6221 -5.21161   .762312
chronic*|  -10.31767      1.9368   -5.33   0.000  -14.1137 -6.52161    .83752
nummed |  -1.063043      .34527   -3.08   0.002  -1.73975 -.386331   6.69376
gp*|  -4.347845     1.77365   -2.45   0.014  -7.82413 -.871558   .472814
- ------------------------------------------------------------------------------
(*) dy/dx is for discrete change of dummy variable from 0 to 1

Any help is much appreciated,
Thanks,
hafida-
```
```

--
--
Alistair Windsor
380 Dunn Hall           Ph: 901-678-4431
University of Memphis   Fax: 901-678-2480
Memphis, TN 38152-3240
*
*   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/
```