Announcement

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

  • Graph for multiple regression

    Dear Stata-listicians,

    A colleague of mine run a multiple regression model with various independent variables. He then obtained predicted values from the model and plotted against one of the independent variables. It looks very nice, but I'm trying to figure out what exactly it means/shows.
    Sample code:
    Code:
    regress y x1 x2 x3 x4 x5
    predict N1
    twoway (scatter N1 x1) (lfit N1 x1)
    It seems like a nice graphical depiction of the linear relationship between Y and x1 but with the values being predicted, I guess the scatter is really a nice visualization of R2? Has anyone used a graph like this? what would it be called?

    What would be the best way to show y vs x1 'adjusted' for x2-x5? I was thinking avplot?

    Thanking you in advance - stay safe in the pandemic!
    Nikos

  • #2
    You will increase your chances of useful answer by following the FAQ on asking questions – provide Stata code in code delimiters, readable Stata output, and sample data using dataex.

    If you look at the regress postestimation section of the documentation, it will give you a lot of insight into this.

    The vertical distance between the actual observations and the predicted line are indicators of the error size. Of course, you can plot the errors directly as well.

    Comment


    • #3
      Indeed, you can easily do better. Stata supports added-variable plots (other names exist) which do their level best to hold other variables constant.

      See also favplots (SSC),

      Comment


      • #4
        Thank you! Appreciate the comments - I thought the question was generic enough to barely merit any code or sample data but will plan to provide these in the future. It sounds like there is little value to such a graph beyond indicating model errors. I tried avplots but will install favplots for the added formatting benefits (many thanks for building it, Dr Cox).

        Comment


        • #5
          Dr Cox - is there something broken in favplot(s) when it comes to running after a regression that includes dummy variables?
          I am using Stata 14 on Windows.

          Here is sample code as previously requested:

          Code:
          use http://www.stata-press.com/data/r13/auto2, clear
          regress price mpg weight length i.foreign
          avplot mpg
          favplot mpg
          . favplot mpg
          invalid syntax
          r(198);
          In the above, avplot works but favplot does not (output quoted above). In contrast, both work in the below.

          Code:
          use http://www.stata-press.com/data/r13/auto2, clear
          regress price mpg weight length
          avplot mpg
          favplot mpg
          Many thanks,
          Nikos

          Comment


          • #6
            Interim report: You are correct. favplots does not support factor variables. The original program was 2011. At this distance, my best guess is that then I decided that was a complication I didn't need, but it's a perfectly reasonable expectation. I am working on it.

            Comment


            • #7
              I have fixed the code. On rummaging I see that Dave Airey pointed out the same problem in 2011. https://www.stata.com/statalist/arch.../msg00613.html

              Nikos Kakouros If you need revised code urgently, please email me. Otherwise this will go up on SSC when Kit Baum can find the time to do it.

              Comment


              • #8
                Thanks Nick Cox from 2011!

                Comment


                • #9
                  Thank you, Nick Cox . It would be great if you could provide code as I'm in the midst of an analysis, though I'm not sure I know how to implement it.
                  PS: I just realized my email notifications were off, hence the delay in seeing this. They are on now ;-)
                  Last edited by Nikos Kakouros; 05 May 2020, 09:23.

                  Comment


                  • #10
                    #9 Please see notification of update at https://www.statalist.org/forums/for...updated-on-ssc

                    Code:
                    ssc install favplots, replace
                    should be sufficient.

                    Comment

                    Working...
                    X