Announcement

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

  • How to make a graph for U-shaped relationships

    Hi,

    I often check estimated relationships in a graph by using the Stata marginsplot or marginscontplot command.
    Can these commands also produce a graph in terms of a U-shaped (or inverted-U-shaped) relationship?
    Or is there any other command in Stata?

  • #2
    Yes. See below for example.
    Code:
    version 15.1
    
    clear *
    
    set seed `=strreverse("1495462")'
    quietly set obs 25
    
    generate double x = runiform() - 0.5
    generate double y = rnormal(x * x, sqrt(0.005))
    
    *
    * Begin here
    *
    regress y c.x##c.x
    
    quietly margins , at(x = (-0.5(0.05)0.5))
    marginsplot , ///
        plotopts(lcolor(black) msize(small) mfcolor(white)) ///
        noci ///
        xlabel(-0.5(0.1)0.5) ///
        ylabel( , angle(horizontal) nogrid) ///
        title("")
    
    exit

    Comment


    • #3
      Joseph Coveney I am very grateful for your excellent answer.

      Comment

      Working...
      X