Announcement

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

  • Confusing about interaction term and covariate pattern in logistic regression

    Hi everyone,

    I had 3 variables in my data as following;
    1. HIV testing (y) --> coded 0 for no, 1 for yes
    2. Gender (gender) --> coded 0 for Male, 1 for Female
    3. Age group (agegr) --> coded 0 for <=25 yrs, 1 for >25 yrs.

    I tried to find the factors associated with HIV testing.
    I used the logistic model to identify factors and interaction term;

    Case1: Model with main effect and interaction term

    Code:
    logit y i.gender i.agegr gender#agegr
    predict y     // find probability in each covariate pattern
    predict n, n     // identify covariate pattern
    Case2: Model with only the main effect

    Code:
    logit y i.gender i.agegr
    predict y2
    predict n2, n
    After I ran the commands already, I was wondering that why both cases had the same covariate pattern?
    So, Case1 and Case2 had 4 patterns.
    Gender Agegr Pattern no. (n)
    0 0 1
    0 1 2
    1 1 3
    1 1 4
    In Case1, Why the program did not include an interaction term for covariate pattern?

    Example;
    In my imagination of Case1;
    Should I have 16 patterns?
    Gender Agegr Interaction of Gender and Agegr Pattern no.
    0 0 0 (Gender=0, Agegr=0) 1
    0 0 1 (Gender=0, Agegr=1) 2
    0 0 2 (Gender=1, Agegr=0) 3
    0 0 3 (Gender=1, Agege=1) 4
    0 1 0 (Gender=0, Agegr=0) 5
    0 1 1 (Gender=0, Agegr=1) 6
    0 1 2 (Gender=1, Agegr=0) 7
    0 1 3 (Gender=1, Agege=1) 8
    1 0 0 (Gender=0, Agegr=0) 9
    1 0 1 (Gender=0, Agegr=1) 10
    1 0 2 (Gender=1, Agegr=0) 11
    1 0 3 (Gender=1, Agege=1) 12
    1 1 0 (Gender=0, Agegr=0) 13
    1 1 1 (Gender=0, Agegr=1) 14
    1 1 2 (Gender=1, Agegr=0) 15
    1 1 3 (Gender=1, Agege=1) 16
    Apologize for my mistake. This is my first post for Statalist.

    Thank you in advance,
    Mink
    Last edited by Tanarat Muangmool; 05 Dec 2018, 00:00.

  • #2
    No. You are misunderstanding what gender#age does. It is the product of gender and age. So, it takes on only two values. It is 1 when gender = 1 (male) and age = 1 (> 25 years) and is 0 for all other combinations of gender and age.

    Comment


    • #3
      I apologize for my mistake, thank you Clyde. I will correct it.

      Comment

      Working...
      X