Reputation: 37
I'm currently trying to fit a linear regression in Stata as follows: xi:reg Dependent IV_Rating IV_Size
I aim to see if the impact (coefficient) of IV_Rating
on the dependent variable is significantly different for the small size, compared to the large size (both derived from IV_Size
). I've made two dummies (0
= false and 1
= true) for IV_Size
called Small
and Large
(medium is excluded). I've ran the following: xi:reg Dependent IV_Rating IV_Size IV_Rating#Small IV_Rating#Large
Error: factor variables may not contain negative values
I found the following fix: I add c
. (continuous variable) although the IV_Rating
variable only goes from -3 to +3. xi:reg Dependent IV_Rating IV_Size c.IV_Rating#Small c.IV_Rating#Large
The P values for both interactions are not significant, which is as expected (both IVs themselves are still significant). But I also read you can use ##
instead of #
, and I'm starting to get really confused, among other things. Am I doing this right?
Upvotes: 0
Views: 4998
Reputation: 9460
Just change the coding to positive integers (perhaps using recode
):
x x2
-3 1
-2 2
-1 3
1 4
2 5
3 6
Also, you can use factor variable notation directly (instead of xi
):
reg y i.x2##i.z
This will include main effects for the two categorical variables as well as their interaction.
Upvotes: 1