To see whether there is an interactive effect over and above any potential additive effect of a house being in a rural area or not, we first want to refer back to the earlier discussion of number of observations. We want to only deal with houses with positive sale values, by typing keep if sale_val>=0. Notice that in this case, the variable rural is already in a dummy variable format.
tab rural
rural home |
indicator | Freq. Percent Cum.
------------+-----------------------------------
0 | 245 49.49 49.49
1 | 250 50.51 100.00
------------+-----------------------------------
Total | 495 100.00
We therefore do not have to generate a dummy variable for each category. Looking at the regression of the resale value of a home on how many rooms it has and if it is in a rural area, we can see that the rural location of a home has a significant additive effect on the resale value.
reg sale_val rooms_to rural
Source | SS df MS Number of obs = 495 ---------+------------------------------ F( 2, 492) = 149.41 Model | 2.2667e+12 2 1.1333e+12 Prob > F = 0.0000 Residual | 3.7320e+12 492 7.5853e+09 R-squared = 0.3779 ---------+------------------------------ Adj R-squared = 0.3753 Total | 5.9986e+12 494 1.2143e+10 Root MSE = 87093 ------------------------------------------------------------------------------ sale_val | Coef. Std. Err. t P>|t| [95% Conf. Interval] ---------+-------------------------------------------------------------------- rooms_to | 21121.16 1647.527 12.820 0.000 17884.1 24358.21 rural | -75722.17 7917.301 -9.564 0.000 -91278.06 -60166.28 _cons | -3921.999 10052.5 -0.390 0.697 -23673.12 15829.12 ------------------------------------------------------------------------------
A rural location will decrease the resale value of a home by 43,292.12 Rand. We can test for an interaction effect for this term by first creating the variable,
gen rurinte=rural*rooms_to
We get the following results when we insert this term into our regression.
reg sale_val rooms_to rural rurinte
Source | SS df MS Number of obs = 495 ---------+------------------------------ F( 3, 491) = 188.02 Model | 3.2070e+12 3 1.0690e+12 Prob > F = 0.0000 Residual | 2.7916e+12 491 5.6856e+09 R-squared = 0.5346 ---------+------------------------------ Adj R-squared = 0.5318 Total | 5.9986e+12 494 1.2143e+10 Root MSE = 75403 ------------------------------------------------------------------------------ sale_val | Coef. Std. Err. t P>|t| [95% Conf. Interval] ---------+-------------------------------------------------------------------- rooms_to | 40615.1 2081.428 19.513 0.000 36525.5 44704.7 rural | 98734.72 15199.13 6.496 0.000 68871.37 128598.1 rurinte | -36754.89 2858.046 -12.860 0.000 -42370.4 -31139.39 _cons | -102983.1 11622.42 -8.861 0.000 -125818.9 -80147.24 ------------------------------------------------------------------------------
All terms are significant for this regression. We get the additive effects of the rural variable by adding the coefficient of rural to the constant term. We get the interactive effect by adding the coefficients of number of rooms in a house and number of rooms in a house if the house is in a rural area. Our interpretations are as follows. If the house is in a rural area, its resale value is worth about 4000 Rand times the number of rooms in the house, minus about 4000 Rand. If the house is not in a rural area, its resale value is worth 40,615 Rand times the number of rooms in the house, minus 102,983.1 Rand.