1
$\begingroup$

I am currently doing an exercise question asking me to construct a model to test whether the coefficients of two categorical variables ($X_2$ and $X_3$) are same in R.

Specifically, these two categorical variables contribute equally to the response variable.

I am a bit confused in terms of what I should do since it is not about to test whether these two categorical variables are significant contributors to the overall model (which i will just use a F-test to find out).

Instead, it is asking whether the coefficients of these two categorical variables are same given these two categorical variables are considered to contribute equally to the response variable and I need to test it by a model. Does anyone have any ideas?

Note: these two categorical variables are in my current model (if this info is helpful) where it has 3 predictors, one is quantitative and two are categorical. Also, each categorical variable has 2 levels only.

$\endgroup$
1
  • $\begingroup$ thanks all who helped me to edit and improve this question post, I really appreciate! $\endgroup$
    – Li K
    May 16, 2019 at 11:24

1 Answer 1

0
$\begingroup$

When I read "the same coefficients" I'm thinking of comparing their weights in a linear regression. What if you changed these categorical variables to dummy variables (since they're binary), applied a linear regression on your 3 predictors and checked whether the coefficients on each dummy variable are similar ? That should solve your problem.

If you have the same weights for each dummy variable, then it means that they have the same importance in the model. This is true because those are binary categorical variables, if they were not you would have to check the coefficients of each level of a one hot encoding.

For example : let's say you have beta_dummy_X2 = 10, beta_dummy_X3 = 10, beta_0 = -3. Then if dummy_X2 = 1 it affects your regression the same way (-3+10=+7) as if dummy_X3 = 1. If dummy_X2 = 0, it also affects the same way (-3) as if dummy_X3 = 0. You only need approximate equality between beta_dummy_X2 and beta_dummy_X3.

$\endgroup$
8
  • $\begingroup$ thanks for the suggestion, but this exercise question is for my Uni statistics course, which I don't think is a very advanced one (more like an introductory or intermediate one course, and it is related to linear regression that includes both SLR and MLR), so i actually haven't heard this "one-hot-encoded" term.. . $\endgroup$
    – Li K
    May 16, 2019 at 9:32
  • $\begingroup$ One hot encoding is not very advanced and is just a way to treat categorical variables as features. Instead of having categorical_column whose values can be level1 or level2, you instead have 2 columns cat_col_lvl_1 and cat_col_lvl_2 whose values are 1 or 0. If you don't want to use such a one hot encoding, you can replace level1 with 0 and level2 with 1 but the coefficient of level1 will be included in the intercept. Those are the only ways to my knowledge to treat categorical variables as features of a model. $\endgroup$ May 16, 2019 at 9:40
  • $\begingroup$ i see, i think i understand the second one, which in my course refers to create a dummy variable (e.g X_2 =1, if level 1, 0 if otherwise, is it what you mean?). so, are you suggesting me to fit two simple linear regressions where one SLR only has the first categorical variable say A, and another SLR only includes the second categorical variable as a predictor? and then... just to compare the estimated coefficient and to see whether they are same? $\endgroup$
    – Li K
    May 16, 2019 at 9:48
  • $\begingroup$ I noticed you mentioned that "If you have the same weights for each level, then each level of these categorical variables contribute equally likely. " but the question I have asked is more like to compare whether the two categorical variables (not each level of a categorical variable) is same. $\endgroup$
    – Li K
    May 16, 2019 at 10:03
  • $\begingroup$ Like the background info in the question said: A theory suggests that the first categorical variable and the second categorical variable contribute equally to the response variable (and I think that's probably why the question asked "to test whether the coefficients of these two categorical variables are same). Please let me know how you think, thanks a lot: ) $\endgroup$
    – Li K
    May 16, 2019 at 10:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.