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

# Re: st: variance-covariance matrix of the marginal effects of a logit and probit

 From Maarten buis <[email protected]> To [email protected] Subject Re: st: variance-covariance matrix of the marginal effects of a logit and probit Date Tue, 26 Apr 2011 15:48:36 +0100 (BST)

```--- On Tue, 26/4/11, Mongeon, Kevin wrote:
> I was wondering how to calculate (and save) the variance
> -covariance matrix of the marginal effects of a logit and
> probit regression.  I am using Stata 11.

*--------------------- begin example --------------------
//================================= data preparation

sysuse nlsw88, clear

/* Categories 1 & 2 are classified as 1, i.e.
"good occupations"
the rest is classified as 0, i.e. "bad occupation"

The categories for occupation are:
1 Professional/technical
3 Sales
4 Clerical/unskilled
5 Craftsmen
6 Operatives
7 Transport
8 Laborers
9 Farmers
10 Farm laborers
11 Service
12 Household workers
13 Other

*/
gen byte good_occ = occupation < 3 ///
if occupation < .

// marital status is present in the data
// as two dummy variables, these are
// combined into one categorical variable
// marst so it will work more nicely with
// Stata's new factor variable notation
gen byte marst = never_married + 2*married
label define marst 0 "widowed/divorced" ///
1 "never married"    ///
2 "married"
label value marst marst
label variable marst "marital status"

// center variables

sum ttl_exp, meanonly
gen c_ttl_exp = (ttl_exp - r(mean))/10

sum age, meanonly
gen c_age = age - r(mean)

//=============================== estimate the model
logit good_occ c_grade c_ttl_exp i.race i.south ///
c_age i.marst

// compute marginal effects
margins, dydx(*) post

// store the variance covariance matrix
matrix v = e(V)

// display the variance covariance matrix
matlist v
*---------------------- end example ---------------------
(For more on examples I sent to the Statalist see:
http://www.maartenbuis.nl/example_faq )

Hope this helps,
Maarten

--------------------------
Maarten L. Buis
Institut fuer Soziologie
Universitaet Tuebingen
Wilhelmstrasse 36
72074 Tuebingen
Germany

http://www.maartenbuis.nl
--------------------------

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