Announcement

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

  • Contour plot cannot handle missing x

    Hi all,

    As you can see from my code below, I only want to plot the cells with F statistics higher than 10. It turns out that when x is 3 (reference decile is 3), all the Fs are lower than 10. I expected to see a blank column along the vertical line x=3, but STATA filled the column in with adjacent values.

    Any idea how to fix this? Thanks!

    Code:
    twoway (contour ref_b sub_n ref_n if ref_n!=sub_n & P_val<0.05 & F>10, ///
    format(%5.2g) ccuts($expblist) interp(none) crule(hue) heatmap), ///
    ylabel(1(1)10, grid ticks) ytitle("Subject Decile" " ") yscale(range(1 10)) ///
    xlabel(1(1)10, grid ticks) xtitle(Reference Decile) xscale(range(1 10)) ///
    ztitle("Estimated Reference Effect with" "A P-value Less Than 5% and" "F Statistics Greater Than 10") ///
    xsize(20) ysize(15) ///
    title("Figure A14 Estimated Coefficients of Reference Consumption Instrumented " "by Bartik Consumption Weighted by Number of Children", size(medsmall)) ///
    name(NewplanFigureA14SigCoff, replace) saving(NewplanFigureA14SigCoff, replace)

    Click image for larger version

Name:	stata.png
Views:	1
Size:	49.4 KB
ID:	1494667

  • #2
    You did not get what you want, but it's how twoway contour should be expected to behave. You give it certain data points and it contours between them according to the data selected. There is no way that it can know that certain regions of the space are forbidden.

    But what you want is more like a heat map in which tiles are coloured independently of other tiles. There are commands to do that. Further, contour hasn't worked especially well for you as the boundary tiles are half the size of the interior tiles.

    There is much literature explaining that rainbow sequences for colour schemes don't work well. Their basis in physics doesn't map into effective psychological decoding. https://eos.org/features/the-end-of-...-data-graphics is one sample.

    Yet another suggestion is to use tabplot (Stata Journal) encoding reference effects by bar heights or lengths.

    Comment

    Working...
    X