Announcement

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

  • OLS regression with factorial variable coefficients summing to zero

    Hello,

    I'm estimating a simple ols regression on several sets of factor variables:

    reg y i.dest i.orig i.time

    I'd like to constrain the sum of coefficients for each factor variable to zero. How can I achieve this? I'd also like to know the standard errors in that case.

    Thank you,
    Christian

  • #2
    A constraint like that typically happens when you want to parametrize the effect of a categorical variable as deviations from the grand mean. If that is the case, take a look at help contrasts
    ---------------------------------
    Maarten L. Buis
    University of Konstanz
    Department of history and sociology
    box 40
    78457 Konstanz
    Germany
    http://www.maartenbuis.nl
    ---------------------------------

    Comment


    • #3
      Thanks, Maarten. I had seen that you had posted that advice before and I had looked at this example
      http://www.stata.com/features/overview/contrasts/
      But I'm not sure how to apply it to my examples. I don't want to do adjacent contrasts, but a contrast relative to the 'average' so that all coefficients add up to 0.

      Comment


      • #4
        That website is not meant to help you do an analysis. It is meant to help you decide whether or not Stata is worth buying for you.

        The help files and manuals are for helping you do research using Stata. So that is the information you should consult.

        Here is a brief example, but read to documentation to decide if you really want the g. or the gw. prefix. The g. prefix literally answers your question, but I suspect that it is gw. that you actually want.

        Code:
        // open example data
        sysuse auto, clear
        
        // estimate the model
        reg price i.rep78
        
        // get the comparison with the mean
        // assuming a balanced design
        contrast g.rep78
        
        // check if it adds up to 0:
        mata : sum(st_matrix("r(b)"))
        // 0.000000000000062 is close enough to 0
        ---------------------------------
        Maarten L. Buis
        University of Konstanz
        Department of history and sociology
        box 40
        78457 Konstanz
        Germany
        http://www.maartenbuis.nl
        ---------------------------------

        Comment

        Working...
        X