Announcement

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

  • regression with "grouped" variables.

    Hello,
    First I'd like to apologize for the probably rather beginner question I'm going to ask, but I'm really new to stata.
    Second:
    I have a problem concerning a regression I'm trying to do:

    I have datas about subjective well-being, Income, age and so on.
    To get a better view about the correlations between these variables, I tried to, for example, group "age" in groups from 25-30,31-35, 36-40
    by using commands as:

    . generate low_age1 = Age if Age >= 25 & Age < 30.

    Now my problem is that when I'm trying to make a linear regression as following:
    . regress SWB low_age1 low_age2
    for example, it just tells me that there are "no observations r(2000)";

    If I make other groups including the previous ages with commands as:
    . generate low_age1 = Age if Age < 30
    . generate low_age2 = Age if Age < 35

    It gives me a regression but says "low_age2 omitted because of collinearity" and therefore doesn't show me a coefficient for "low_age2".
    I hope this kind of makes sense and is understandable.
    I'd be really greatful, if someone could help me with this probably newbish question.
    Thanks a lot in advance
    Marcel M.

  • #2
    Marcel:
    welcome to the list.
    The issue there seems to be related to (too many) dummies created mistakenly.
    You should be better off with -fvvarlist- and -label- for categorizing age (please note that you should categorize -Age- for all the values included in your dataset, otherwise Stata will listwise delete those observation with missing -low_age-) as :
    Code:
    generate low_age = 0 if Age >= 25 & Age < 30
    replace low_age=1 if Age >= 30 & Age < 35
    replace low_age=2 if Age >= 35 & Age <= 40
    label define low_age 0 "25-29" 1 "30-34" 2 "35-40"
    label val low_age low_age
    regess SWB i.low_age <other_controls>
    Kind regards,
    Carlo
    (Stata 19.0)

    Comment


    • #3
      Originally posted by Carlo Lazzaro View Post
      Marcel:
      welcome to the list.
      The issue there seems to be related to (too many) dummies created mistakenly.
      You should be better off with -fvvarlist- and -label- for categorizing age (please note that you should categorize -Age- for all the values included in your dataset, otherwise Stata will listwise delete those observation with missing -low_age-) as :
      Code:
      generate low_age = 0 if Age >= 25 & Age < 30
      replace low_age=1 if Age >= 30 & Age < 35
      replace low_age=2 if Age >= 35 & Age <= 40
      label define low_age 0 "25-29" 1 "30-34" 2 "35-40"
      label val low_age low_age
      regess SWB i.low_age <other_controls>
      This has solved my problem really fast, thank you very much.
      I wish you a happy easter !
      Kind regards,
      Marcel

      Comment


      • #4
        Marcel:
        you're welcome.
        I do reciprocate the same to you and your dears.
        Kind regards,
        Carlo
        (Stata 19.0)

        Comment

        Working...
        X