Announcement

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

  • Twoway graph generates vertical lines at min/max values of predictor

    Dear Statalist,

    Why does my twoway graph generate vertical lines at the minimum and maximum values of my treatment variable (i.e., 0,1)? I would like to remove them.

    Thanks so much,

    Matt

    Regression model:
    Code:
     eststo: mixed math treatment math_prior covariates i.year || school: , covariance(unstructured) mle
    Graph code:
    Code:
    predict values, fitted
    sort school treatment
    twoway (line values treatment), ///
    graphregion(color(white)) ///
    xtitle(" ""Treatment") ///
    xscale(range(-.1 1.1)) ///
    xlabel(0 1) ///
    ytitle("Empirical Bayes Regression Lines, Math"" ")
    Graph:
    Click image for larger version

Name:	ebprl_math.png
Views:	1
Size:	691.5 KB
ID:	1473985

  • #2
    Because the lines at 0 and 1 is where the predicted values are for the treatment variable. The sloped lines are arbitrary line connecting changes in treatment from one school to another. If you had sorted:
    Code:
    sort treatment school
    there would one connecting line.

    For example:
    Code:
    webuse nlswork,clear
    mixed ln_w grade age   collgrad || id:
    predict value, fitted
    sort id coll
    twoway connect value collgrad, title(Sorted on id collgrad) name(gr1,replace)
    sort coll id
    twoway connect value collgrad, title(Sorted on collgrad id) name(gr2,replace)
    Click image for larger version

Name:	gr1.png
Views:	4
Size:	105.1 KB
ID:	1474001

    Click image for larger version

Name:	gr2.png
Views:	1
Size:	26.6 KB
ID:	1474002
    Attached Files

    Comment


    • #3
      Perhaps adding the connect(L) option to the twoway command will solve your problem, or at least point you on your way to a solution.

      Comment


      • #4
        Thanks Scott. That totally makes sense now. The graphs I was referencing Rabe-Hesketh & Skrondal had a continuous predictor variable.

        Comment


        • #5
          Matt Lenard
          Hit me up sometime and I can show you a bunch of Stata related stuff that you might find useful. I wasn’t sure if there was another Matt Lenard out there. Hope things are going well at HGSE.

          Comment

          Working...
          X