Announcement

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

  • Unexpected error: factor variables may not contain noninteger values

    Hi, When executing a linear regression with an interaction term, I’m getting an unexpected error message from Stata: factor variables may not contain noninteger values.
    I'm using Stata 17.0 for Windows.

    I know that this question has been asked before on this forum, however, when I tried all the answers, the error remains.
    In a normal regression, Stata runs without problems. It is only when I add the interaction term that I keep getting this error.
    The fact is; the variables that I am trying to test for their interaction term are containing noninteger values.
    Is there a possibility to keep the numbers with decimals or should I create new variables containing only whole numbers?
    And if so, how do I create a new variable in Stata containing no decimals?

    Thanks in advance,




  • #2
    add the prefix c. if the variable you are interacting is continuous or i. if it is categorical (e.g. binary)

    Comment


    • #3
      And in doing what Maxence Morlet recommends, take a few minutes to read the output of
      Code:
      help factor variables
      to understand the basics of factor variable notation like "i.varname" and "c.varname"

      Comment


      • #4
        Hi Maxence Morlet and William Lisowski, thank you so much for taking the time to reply to my post.
        Unfortunately, the variable that I am trying to use is in fact a continuous variable.
        So I tried using the c. before the variable, however, if I run that regression, I end up with numerous rows, showing me per category.

        I also tried the following:
        format varname %2.0f

        But unfortunately, I still get the same error over and over again.
        i. before the variable remains in the same error: factor variables may not contain noninteger values.

        How come Stata still thinks there are noninteger values when I transferred the values to no decimals?

        Thanks in advance!

        Comment


        • #5
          Hi,
          It already worked, I added the c. before each of the 2 interaction variables which caused me to only have 1 regression variable.
          Thanks for your advice!

          Comment

          Working...
          X