My data includes total hospital expenditure, age, gender, length of stay and race. When I loaded the dataset from excel to R, they were all numeric. So I changed gender(2 cats) and race(5cats) to factor.
GENDERfac <- as.factor(hospital$GENDER)
RACEfac <- as.factor(hospital$RACE)
Now I need to build a multiple linear regression to best predict hospital expenditure using the other variables as predictors. So in the model for categorical IVs, should I be using their numerical variables or factor form?
costmodel <- lm(formula= COST ~ AGE+GENDER+LOS+RACE, data=hospital)
Or
costmodel <- lm(formula= hospital$COST ~ hospital$AGE + GENDERfac + hospital$LOS + RACEfac)
What difference do the two have? I understand that using the factor variables, model will return values for each category of that variable. In that case, how would the interpretation be?
RACEfac2 269.7343 408.6436 0.660 0.509563
RACEfac3 641.3334 862.2531 0.744 0.457413 **
RACEfac4 106.4079 458.4198 0.232 0.816557
RACEfac5 1577.1875 908.2736 1.736 0.083201 .
RACEfac6 -73.8266 566.3145 -0.130 0.896340
Also, what if few categories of that variable are significant while others are not? How should the interpretation be?