Announcement

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

  • Twoway lfit (without constant)

    Is there a way to generate figure (twoway lfit) with constant excluded in the regression?

    Using two simple variables, I did a regression without constant term (which is identical measuring the correlation).

    The regression result is as below. The estimated coefficient is negative, indicating negative correlation.
    Click image for larger version

Name:	reg_result.png
Views:	1
Size:	12.8 KB
ID:	1698404


    When I do twoway lfit, however, the figure shows positive relation. I believe that this is because lfit includes constant term.
    lfit_result.png

    To double check my guess, I did the regression again using constant term included. As expected, the estimated coefficient is positive in this case.
    Click image for larger version

Name:	reg_result_constant.png
Views:	1
Size:	14.0 KB
ID:	1698406


    In short, is there a way to perform "twoway lift" with constant term excluded? Is there user written ado command?

    Thanks for your help a lot.



  • #2
    This will do what you want, but usually, you don't want to suppress the constant term.

    Code:
    reg cum_automation_infer routineshare , nocons
    predict yhat
     
    tw line yhat routineshare

    Comment


    • #3
      The results in #1 don't seem persuasive that omitting an intercept is a good idea. If anything fitting the mean is the simpler model to go for.

      Comment


      • #4
        Here's some different technique. More work is needed on the graph.


        Code:
         sysuse auto , clear
        (1978 automobile data)
        
        . gen gp1000mi = 1000 / mpg
        
        . regress gp1000mi weight, noconstant
        
              Source |       SS           df       MS      Number of obs   =        74
        -------------+----------------------------------   F(1, 73)        =   4067.54
               Model |  194889.452         1  194889.452   Prob > F        =    0.0000
            Residual |  3497.67227        73  47.9133187   R-squared       =    0.9824
        -------------+----------------------------------   Adj R-squared   =    0.9821
               Total |  198387.125        74  2680.90709   Root MSE        =    6.9219
        
        ------------------------------------------------------------------------------
            gp1000mi | Coefficient  Std. err.      t    P>|t|     [95% conf. interval]
        -------------+----------------------------------------------------------------
              weight |   .0164665   .0002582    63.78   0.000     .0159519    .0169811
        ------------------------------------------------------------------------------
        
        . scatter gp1000mi weight || function `=_b[weight]'*x, ra(weight)
        
        . scatter gp1000mi weight || function `=_b[weight]'*x, ra(0 5000)
        .

        Comment

        Working...
        X