Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • two-way graph with percentage of dichotomous variable

    Hi everyone,

    I am new to this forum and I want to thank you in advance for any help. I need help with plotting a graph for my master thesis.

    I want to have a graph that looks like the one in screenshot 1.

    I used the following command in Stata:

    twoway (connect HD_PVH_high Opportunitätskosten, lcolor(black) mcolor(black) msize(medium) msymbol(S) lpattern(dash))
    (connect HD_PVH_low Opportunitätkosten, mcolor(black) lcolor(black) msize(medium) msymbol(D)),
    legend(lab (1 "PVH high individuals") lab (2 "PVH low individuals") row(2)) graphregion(color(white) icolor(white) ilcolor(gs6) lcolor(gs6) ilwidth(vthin) lwidth(vthin))
    xtitle("opportunity costs", margin(medium)) ytitle("{bf:Count of honest decisions}")
    xlabel(`=0.5' "0.50 CHF " `=1' "1.00 CHF" `=2' "2.00CHF" `=4' "4.00CHF") ylabel(0(0.1)1, nogrid angle(0)) plotregion(lcolor(gs6))

    The result is screenshot 2.

    The aim is to have a graph that shoes the percentage of honest answers for any opportunity cost scenario. The variable HD_PVH_high is a dichotomous variable that shows if people committed to honesty answered honest (1) or dishonest (0) in 4 different scenarios in an experiment (indicated by the opportunity costs). The variable HD_PVH_low is coded the same way only for individual who are not committed to honesty.

    Is there any way I can "tell" Stata to use the percentage of honest answers? Or is there a way to graph frequency tables?

    I hope the problem comes across. I will gladly answer follow up questions.

    Thank you
    Marah

    Attached Files

  • #2
    There is quite a lot to wade through here yet no data example. Please review http://www.statalist.org/forums/help#stata for what to tell us.

    Nevertheless the proportion of Yes answers (Yes coded 1 and No coded 0) is just the mean of the corresponding binary or dichotomous variable. To see the percent of Yes, multiply by 100.

    This code segment you can run shows some technique.

    Code:
    . sysuse auto, clear
    (1978 Automobile Data)
    
    . egen prmean = mean(foreign), by(rep78)
    
    . egen pcmean = mean(100 * foreign), by(rep78)
    
    .. twoway connected prmean rep78 , ytitle(Proportion foreign) sort
    
    . twoway connected pcmean rep78 , ytitle(Percent foreign) sort
    (Being a Master's student is neither here nor there for Statalist; it's curious why so many feel the need to mention it. Questions here come from young and old, rich and poor, and there are no distinctions according to status or degree of knowledge.)

    Comment

    Working...
    X