Dear all,
I am just preparing lecture notes for Logit exercises. STATA is the
default software used in teaching. However, usually I also provide
gretl examples to the students.
I want to compute the conditional marginal effects of x on the binary
variable y over a range of x-values; not just at the mean. For this I am
using Allin's "lp-mfx" function -- which works just fine -- in a loop
(see the example below).
However, is there is an easy way (without manipulating Allin's package)
to replicate Stata's marginsplot() command which also reports confidence
intervals? See here:
http://www.ats.ucla.edu/stat/stata/faq/margins_graph12.htm
Thanks,
Artur
<hansl>
set echo off
set messages off
open keane.gdt -q
include lp-mfx.gfn
logit manuf const lwage
#bundle b = binary_mfx(lwage, $xlist, $coeff, $vcv, $sample,1)
#lp_mfx_print(&b)
matrix xeduc = seq(0,max(educ),1)'
matrix x = ones(rows(xeduc),1)~xeduc
matrix dp_dx = zeros(rows(x),1)
loop i=1..rows(x) -q
dp_dx[i] = binary_dp_dx($coeff, $xlist, x[i,], 1)
endloop
matrix mplot = dp_dx ~ xeduc
gnuplot 1 2 --matrix=mplot --with-lines --fit=none --output=display \
{ set arrow from 50,graph(0,0) to 50,graph(1,1) nohead ; \
set title 'Conditional marginal effects of lwage' ; \
set ylabel 'Effects on Pr(manuf)' ; \
set xlabel 'lwage'; }
</hansl>