Announcement

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

  • Number of constraints in constrained linear regression

    Greetings,

    I am experimenting with constrained linear regression (cnsreg) using a simple linear regression model with one predictor. I have written constraints that fix both the intercept and the slope to constants (i.e., 1.00 and 0.60). When I apply both constraints, I receive the following error message:

    there are at least as many constraints as parametersr(498);

    Why does cnsreg not allow as many constraints as parameters? I did not see this limitation discussed in the documentation. Any ideas or workarounds would be appreciated.

    Thanks,

    Jeff Edwards

  • #2
    Think about it this way. With no constraints, in a simple linear regression of the type y = a + bx + error, you are asking Stata (or any other statistics package) to find the values of a and b that best (in the sense of least total squared error) fit the data. Now, suppose you give one constraint, on either a or b. For concreteness, let's say you specify a constraint on a. Then in that case, you are asking Stata: using the value of a that I have specified as a given, find the b that best fits this equation to the data. Fair enough. Stata will do that. If you now add a second constraint on the value of b, there is nothing left for Stata to fit. You have completely stipulated the values of a and b and there is nothing left to regress. Stata is in effect telling you that you have already stipulated all the results yourself, so there is no question for it to answer.

    This is just logic (or, from a different perspective, linear algebra). There are no workarounds.

    Added: Even if your constraints are more complicated than just specifying the values of a and b directly, the same holds. Suppose for example your first constraint is a + b = 5 and your second constraint is 2*a - b = 7. Now you have two linear equations involving a and b, so there is a unique solution to those equations, namely a = 4 and b = 1. So you have, indirectly, stipulated the values of a and b with your constraints and there is nothing to regress.
    Last edited by Clyde Schechter; 13 Feb 2019, 13:31.

    Comment


    • #3
      We just released an update to Stata 15 that removes the limitation that the number of constraints must be less than the number of parameters. Jeff can type update all in Stata to take advantage of this new feature.

      Comment


      • #4
        I just want to make clear to Jeff Edwards that what StataCorp has reported doing in #2 does not in any way overturn linear algebra. All that has changed is that you no longer get an error message. It remains true that if the number of constraints equals or exceeds the number of parameters being estimated, then the parameters are completely or over (and possibly inconsistently) determined. Now you will get output from -cnsreg-, but all it reflects is the solution of the simultaneous linear equations represented in your parameters--no actual regression is being done. And, if the constraints are mutually inconsistent, you will still get an error messsage.

        Comment


        • #5
          Hi Clyde,

          A belated thanks for your follow-up -- I hadn't checked back after your first reply. I'd like note that I was able to conduct the test I had in mind using sem. Here is the syntax:

          constraint 1 _cons = 1.00
          constraint 2 ipjnm = 0.06

          sem ipjr <- _cons ipjnm
          sem ipjr <- _cons ipjnm, constraints(1 2)

          As would be expected, the first sem command produces yields a chi-square of zero because the model is saturated. The estimated intercept and slope are 3.110 and 0.034, respectively. The second command estimates an equation for which the intercept and slope are constrained to 1.00 and 0.06, respectively. The model has two degrees of freedom, and the chi-square is 172.53, which provides a joint test of the two constraints. This approach achieves my objective, which to conduct a joint test of the intercept and slope against hypothesized nonzero values.

          Regards,

          Jeff

          Comment


          • #6
            Thank you for showing what you've done.

            Had I understood from the beginning that you were trying to test your regression against the constraints, we would have had a very different discussion. Your way of doing it with -sem- is one way of doing it. Here's another:

            Code:
            regress ipjr  ipjnm
            test _cons = 1, notest
            test ipjnm = 0.06, accum
            I should add that the chi square test that you get from the -sem- approach is a large sample approximation to the test. If your sample is, indeed, large*, this is not a problem. The test you would get from the code I show here is an F-test, and it is applicable to finite sample sizes directly.

            *Larger than 60 is certainly fine, even over 30 is typically quite good for this purpose. If your sample size is less than 30, then the F-test is better.

            Comment

            Working...
            X