Announcement

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

  • Qualitative variables in the regression

    Hi everyone, I would like to know if there is a way, besides creating dummy variables, to include qualitative variables in a regression.

    Thanks.

  • #2
    Massimiliano:
    welcome to this forum.
    If by qualitative variables you mean non-numerical predictors, I'm not aware of anything else than categorical variables (see -help fvvarlist- for more details).
    If your query implies something different, please provide the list with more details (and please read and act on the FAQ on how to post [more] effectively). Thanks.
    Kind regards,
    Carlo
    (Stata 19.0)

    Comment


    • #3

      Unfortunately, I mean non-numeric variables. However, thanks for your help. Kind regards, Massimiliano

      Comment


      • #4
        If you have character variables you want to include in your model - for example, a variable containing country names - then you can use the encode command to create a numeric categorical variable that takes a distinct values for each country, and then you can use the factor variable notation Carlo discussed to avoid the work of creating individual indicator (so-called "dummy") variables. For details, see the output of
        Code:
        help encode
        help fvvarlist
        Beyond that advice, your question really isn't clear without more detail, or at a minimum it is too difficult to guess at a good answer from what you have shared. Please help us help you. Show example data. Show the sort of regression you want to run. The Statalist FAQ linked to from the top of this page, and from the page you used to create your post, provides advice on effectively posing your questions, posting data, and sharing Stata output.

        Comment


        • #5
          Massimiliano:
          as William wisely pointed out, you canniot expect to get more help from interested listers if you do not provide more details in line with the recommendations reported in the FAQ, in addition, please take a look at -help dataex-.
          That said, what do you mean by non-numeric variables? Something unordered such as colors, races, languages, else?
          Last edited by Carlo Lazzaro; 23 Sep 2021, 00:58.
          Kind regards,
          Carlo
          (Stata 19.0)

          Comment


          • #6
            Sorry I'm only replying now but I've been a bit busy.
            First of all, thank you for your help and sorry if I was not very clear. I will try to explain my problem better.
            I have to do a linear regression and, among the control variables used, there are two that are non-numerical, namely country and sector of the companies analysed.
            I would like to know how to include these two variables in my regression without creating a large number of dummy variables.
            I hope my explanation is clearer.
            Thank you.

            Comment


            • #7
              Massimiliano:
              take a look at -encode-.
              Kind regards,
              Carlo
              (Stata 19.0)

              Comment


              • #8
                I just tried it and it works.
                Thank you both very much for solving my problem.

                Kind regards,
                Massimiliano

                Comment


                • #9
                  Massimiliano:
                  happy with reading that you were successful.
                  As William Lisowski wisely remind to Statalist new members, one of the most rewarding (although a bit intimidating) way to get the most out of Stata is to devote a (relevant) share of your time to read/study the Stata .pdf manual.
                  You will benefit so much from this investement as you get yourself more familiar with Stata jargon, thanks to your increased ability of picking up the right Stata command(s) for you research needs.
                  Kind regards,
                  Carlo
                  (Stata 19.0)

                  Comment


                  • #10
                    Thanks for the advice. In my spare time, I will definitely look into reading the manual.
                    Thanks again for your help.

                    Comment

                    Working...
                    X