Bookmark and Share

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

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

st: Using margins and marginsplot with the ologit command‏

From   Thomas Boquet <>
To   <>
Subject   st: Using margins and marginsplot with the ologit command‏
Date   Fri, 17 Aug 2012 15:14:10 -0400

Hello everybody,

I'm actually working with the command margins after ologit for a class exemple and I have a few questions on the interpretation of the output when dydx and at are used. Here is my code, I'm using the database attend.dta from the manual Econometric Analysis of Cross Section and Panel Data by Jeffrey Wooldridge avalaible on the Stata website :

set more off
set linesize 230

use "";, clear

gen termgpac=1 if termgpa>=0 & termgpa<=1
replace termgpac=2 if termgpa>1 & termgpa<=2
replace termgpac=3 if termgpa>2 & termgpa<=3
replace termgpac=4 if termgpa>3 & termgpa<=4
replace termgpac=. if termgpa==.
label variable termgpac "GPA , 1: entre 0 et 1, 2: entre 1 et 2, 3: entre 2 et 3, 4: entre 3 et 4"

gen hwrtec=1 if hwrte>=0 & hwrte<=25
replace hwrtec=2 if hwrte>25 & hwrte<=50
replace hwrtec=3 if hwrte>50 & hwrte<=75
replace hwrtec=4 if hwrte>75 & hwrte<=100
replace hwrtec=. if hwrte==.

ologit termgpac c.priGPA c.atndrte i.hwrtec i.frosh

margins, dydx(*) predict(outcome(4))

margins, dydx(*) atmeans  predict(outcome(4))

margins, dydx(*) at((median)c.priGPA c.atndrte) predict(outcome(4))

margins i.hwrtec, dydx(priGPA) at(priGPA=(1(0.2)4)) predict(outcome(1))
marginsplot, recast(line) recastci(rscatter) title(Effet marginal à la moyenne de atndrte) yline(0) xlabel(, angle(90)) ylabel(, angle(0)) ytitle("")

Q1 : I would like to know if the output of margins with the option at((median)..... is the average calculation when priGPA and atndrte are at their median.

Q2 : I'm not sure if it's the correct calculation of the average marginal effect of priGPA for different values of the variable (last calculation and graph).

I'm then showing a twoway table with the observed dependent variable against the prediction of the model.

predict p1 p2 p3 p4

gen termgpachat  = 1 if( p1>p2 & p1>p3 & p1>p4) & e(sample)
replace termgpachat = 2 if( p2>p1 & p2>p3 & p2>p4) & e(sample)
replace termgpachat = 3 if( p3>p1 & p3>p2 & p3>p4) & e(sample)
replace termgpachat = 4 if( p4>p1 & p4>p2 & p4>p3) & e(sample)
replace termgpachat=. if termgpac==. & e(sample)

tab termgpac termgpachat, row nofreq

Q3 : Are the values in percentage in the diagonal, the percentage of correctly classified observations?

Thank you very much

Thomas BOQUET 

*   For searches and help try:

© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index