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.
You did not post any code, so it's not obvious what's wrong, but it's probably one of these three issues.
You forgot to properly code the firms as factors, and it may be reading them as numeric.
When you reordered, you maybe accidentally dropped some firms or somehow equated two to be the same.
(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.