Announcement

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

  • Graphing MLR Predictions with Scatter of Data.

    I want to be able to graph my multiple linear regression predictions on the same graph as the scatter plot of the data set.
    The closest I have found is
    twoway (scatter Y X) (lfit Y X)
    which only allows an approximation of SLR.

    Is there any way to do this without spending 20 minutes copy-pasting matrices into excel?

  • #2
    You can plot the observed response versus the predicted response, say

    Code:
    sysuse auto, clear
    regress weight length displacement 
    predict predicted 
    scatter weight predicted


    You could also

    Code:
    scatter weight predicted length 
    scatter weight predicted displacement


    -- although I am not sure that such graphs would be more helpful.

    Otherwise, sorry: I can't imagine what graph you are seeking. Why would copying matrices to Excel help? What graph is it that Excel could produce here?

    Comment


    • #3
      So this is the general principle for overlaying a scatter plot with a line plot - which lfit provides.
      Code:
      sysuse auto, clear
      regress weight length 
      predict predicted 
      sort length
      scatter weight length || line predicted length
      Click image for larger version

Name:	Graph.png
Views:	1
Size:	155.3 KB
ID:	1497754

      If you indeed have more than one independent variable you are going to have to do something different, because this doesn't really work well.

      Code:
      sysuse auto, clear
      regress weight length displacement
      predict predicted 
      sort length
      scatter weight length || line predicted length
      Click image for larger version

Name:	Graph2.png
Views:	1
Size:	170.2 KB
ID:	1497755

      So as Nick asks, what is it you hope to see?

      Comment

      Working...
      X