Announcement

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

  • Fit plots based on multivariable linear regression

    Dear community,

    I would like to create a two-way plot of two continuous variables. STATA's fit plots offer an intuitive way to facilitate visualisation of a univariable linear regression.
    I was wondering whether this option exists also for multivariable linear regression, or otherwise how to best solve this.

    So far, I have tried to run my weighted multivariable linear regression equations and create linear predictions for subsequent utilization in STATA's twoway command:

    regress dep_var indep_var conf1 conf2 conf3 [aweight=indep_var]
    predict dep_var_prediction

    scatter dep_var indep_var || dep_var_prediction indep_var, sort

    This approach yields a wiggly line if plotted against the independent variable (Screenshot 1). This is in contrast to the straight line that is plotted if linear predictions are made based on the crude linear regression model (Screenshot 2) i.e. ...

    regress dep_var indep_var[aweight=indep_var]
    predict dep_var_prediction_crude

    Is it possible to produce a plot with a straight line based on the multivariable regression equation? I am certain that the solution might probably be very obvious, yet I have been unable to see it. Many thanks for any advice in advance.

    Best wishes,
    Hannes
    Click image for larger version

Name:	Screenshot 1.png
Views:	1
Size:	82.2 KB
ID:	1596193
    Click image for larger version

Name:	Screenshot 2.png
Views:	1
Size:	57.2 KB
ID:	1596194

  • #2
    No; what you are asking for is to collapse a hyperplane in 5-dimensional space so that it reduces to a line. Some other possibilities are a plot of observed versus fitted or of residual versus fitted., or added variable plots.

    Comment


    • #3
      Hi Johnanes,
      there is an alternative, which isnt exactly the idea of plotting actual vs a single explanatory variable, but its something that is in spirit the same.
      You can check an explanation of the strategy (and some caveats) here :https://youtu.be/fg9T2gPZCIs?t=1250

      Code:
      sysuse auto , clear
      reg price mpg trunk weight length
      reg price trunk weight length
      predict double price_res, res
      
      reg mpg trunk weight length
      predict double mpg_res, res
      
      reg price_res mpg_res
      predict price_hat
      two scatter price_res mpg_res || line price_hat mpg_res, sort
      scatter price mpg

      Comment

      Working...
      X