Announcement

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

  • lincom and nlcom commands

    Hi Dear,

    Can you please tell me if there is a maximum limit on the number of coefficients which can be possibly combined using lincom and nlcom commands in Stata? Please inform me about both commands separately if such limits exist.

    Thank you.

  • #2
    To clarify my question further, what I am trying to ask is whether lincom and nlcom only work for 2 coefficients at a time like beta1+beta2 or beta1-beta2 or any other possible combinations of 2 coefficients or they can work for more than 2 coefficients at a time like beta1+beta2+beta3 etc.? If they can be be used for more than 2 coefficients at a time, then is there any maximum limit on the number of coefficients which can be combined at a time?

    Regards.

    Comment


    • #3
      this is the kind of thing you can easily check yourself; for example:
      Code:
      sysuse auto
      regress price weight mpg gear
      lincom weight+mpg+gear_ratio

      Comment


      • #4
        Thanks Rich.

        I am having some trouble with my machine and I am not being able to check it myself. And it is kind of urgent for me to know. I am actually interested in the maximum number of coefficients that can be combined using both commands.

        Regards.

        Comment


        • #5
          I don't know - why not write to tech support ([email protected]) and ask - and then, please, report back to Statalist

          Comment


          • #6
            Thanks Rich for the email address and for your kind advice.

            I have written them and will surely update here if I get any response.

            Best wishes.

            Comment


            • #7
              Hi Rich,

              I have received the following response:

              Technically, it is not the number of coefficients that will cause problems, but
              the number of operators. Stata SE (versions 14 & 15) have a limit of 800 dyadic
              operators (such as +, *, and #) or 249 pairs of nested parentheses that can be
              used in an expression.

              If your expression for -lincom- or -nlcom- uses only one dyadic operator between
              each coefficient, you could use up to 800 coefficients, as in this example:

              ************************************************** ******************* BEGIN CODE
              // Create toy data with 1 outcome & 800 predictors
              clear
              set obs 1000
              set seed 123
              local xvarlist
              forvalues i=1/800 {
              gen x`i' = runiform()
              local xvarlist `xvarlist' x`i'
              }
              gen y = runiform()

              // Increase -matsize- and run linear regression
              set matsize 803
              reg y `xvarlist'

              // Create a local macro -expression-
              local expression x1
              forvalues i=2/800 {
              local expression `expression' + x`i'
              }
              display "`expression'"

              // The following has 799 dyadic operators (plus signs "+", in this case)
              lincom `expression'

              // Try adding one more dyadic operator and we get an error
              lincom `expression' + 1
              ************************************************** ********************* END CODE

              However, if your coefficients themselves contain dyadic operators
              (e.g. interactions, which contain the "#" operator), the number of coefficients
              you may use will be smaller. And if you perform additional mathematical
              operations that use dyadic operators (e.g. x1^2 + x2/2 + x3^3*3 + ...), you will
              similarly restrict the number of coefficients you may use.

              Comment


              • #8
                thank you for reporting back to us

                Comment

                Working...
                X