0
$\begingroup$

I am building a linear regression model to analyze one cross-sectional dataset. In my dataset, there is one string variable called "firm_name", which includes 100 firms(name1, name2, name3....name100). I converted the 'firm_name' from string to numerical(the new variable's name is 'firm_id'), the values become 1, 2, 3 ....100 (name1 becomes 1, names 2 becomes 2, name3 becomes 3....name100 beocmes 100). I added firm_id dummy variables into regression by using i.firm_id to control the unobserved factors and got the parameter(Beta1)'s value of an interested variable(X1). Then, I reordered the value of firm_id (1 becomes 31, 2 becomes 32, 3 become 33,.... 70 becomes 100, and 71 becomes 1.... 100 becomes 30), I run the regression again with the firm_id dummy variables and got a new value of the parameter(Beta1) of the interested variable(X1). But I thought I should got a same value. Do you know why this happened? Thank you.

$\endgroup$
  • $\begingroup$ It may help to make your post a bit more clear, and maybe even provide some simulated toy example of your issue (which may also help you solve the problem). Additionally, the true solution will probably be a coding one, though I realize there may be some confusion about baseline changing meaning depending on dummies used, which has statistical merit. $\endgroup$ – doubled Jun 16 at 2:55
1
$\begingroup$

You did not post any code, so it's not obvious what's wrong, but it's probably one of these three issues.

  1. You forgot to properly code the firms as factors, and it may be reading them as numeric.

  2. When you reordered, you maybe accidentally dropped some firms or somehow equated two to be the same.

  3. (if the interested variable is also a categorical, or the intercept, or something similar) Whatever program you used, it is probably omitting the constant, and instead using the dummies, and so you have some issue with the baseline changing. Effects are relative, and by re-labeling firms, you're changing the baseline. To make this clear, suppose you have outcome $Y$ and dummies $W_1,W_2$ (suppose $W_1$ is dummy for male, and $W_2$ is dummy for female (you can replace them with firm1 and firm2 if you'd like). If you ran a linear regression by providing $(Y,W_1,W_2)$, most software will recognize multicollinearity of $W_1,W_2$ and a constant, so it will omit one. If $W_2$ is omitted, then you have $Y = a_1 + a_2W_1$, so the baseline is $W_1 = 0$. In contrast, if $W_1$ was omitted, you'd have $Y = a_1' + a_2'W_2$, so baseline is $W_2 = 0$, and so the interpretation of $a_1$ versus $a_1'$ is different, and thus affected.

| cite | improve this answer | |
$\endgroup$
  • $\begingroup$ Thank you very much for your explanation. I greatly appreciate it. $\endgroup$ – Amy Jun 17 at 20:34
  • $\begingroup$ @Amy hope you were able to figure it out! If so, feel free to accept the answer so it does not remain unanswered, or otherwise let us know if you're still running into problems, in which case providing a minimial working example could be quite helpful. $\endgroup$ – doubled Jun 17 at 21:34
  • 1
    $\begingroup$ Yes, I figured it out. Your answer is so helpful! I will provide working example in the future. Thank you very much again. :) $\endgroup$ – Amy Jun 17 at 21:37

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.