Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down on April 23, and its replacement, statalist.org is already up and running.


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

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


From   Maarten buis <maartenbuis@yahoo.co.uk>
To   statalist@hsphsun2.harvard.edu
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

// load data
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
           2 Managers/admin
           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 grade, meanonly
gen c_grade = grade - r(mean)

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/


© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index