# Considering a numeric factor as categorical

This is a confusion sparked by problem 9.12 in Gelman and Hill (2007). An experiment on 50 cows was conducted to estimate effect of feed additive on milk fat. Four diets (treatments) were considered with different levels of additive (0.0, 0.1, 0.2, 0.3). Other covariates measured were lactation(seasons of lactation), age and initial weight of the cow. For the sake of argument lets assume that the cows were assigned to to treatments completely at random.

To facilitate meaningful interpretation of the regression coefficients, I centered the covariates.

cows$c_lactation <- (cows$lactation - mean(cows$lactation)) cows$c_initial_weight <- (cows$initial_weight - mean(cows$initial_weight))
cows$c_age <- (cows$age - mean(cows$age)) str(cows) 'data.frame': 50 obs. of 13 variables:$ level           : num  0 0 0 0 0 0 0 0 0 0 ...
$lactation : int 3 3 2 2 2 1 1 1 3 3 ...$ age             : int  49 47 36 33 31 22 34 21 65 61 ...
$initial_weight : int 1360 1498 1265 1190 1145 1035 1090 960 1495 1439 ...$ fat             : num  3.88 3.4 3.44 3.42 3.01 2.97 2.99 3.54 2.65 4.04 ...
$c_lactation : num 0.62 0.62 -0.38 -0.38 -0.38 -1.38 -1.38 -1.38 0.62 0.62 ...$ c_initial_weight: num  101.94 239.94 6.94 -68.06 -113.06 ...
$c_age : num 6.84 4.84 -6.16 -9.16 -11.16 ...  Then I run the following two linear models. Model1: summary(lm(fat ~ level + c_lactation + c_age + c_initial_weight, data = cows)) Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 3.2926488 0.1020850 32.254 < 2e-16 *** level 1.8970077 0.5532560 3.429 0.00131 ** c_lactation 0.2840070 0.1693474 1.677 0.10046 c_age -0.0168047 0.0128543 -1.307 0.19775 c_initial_weight 0.0003718 0.0005342 0.696 0.48999 Residual standard error: 0.4204 on 45 degrees of freedom Multiple R-squared: 0.3085, Adjusted R-squared: 0.247 F-statistic: 5.018 on 4 and 45 DF, p-value: 0.001976  Model 2: summary(lm(fat ~ factor(level) + c_lactation + c_age + c_initial_weight, data = cows)) Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 3.3351919 0.1254831 26.579 < 2e-16 *** factor(level)0.1 0.1201635 0.1738695 0.691 0.49321 factor(level)0.2 0.2722551 0.1750208 1.556 0.12714 factor(level)0.3 0.5832468 0.1796321 3.247 0.00226 ** c_lactation 0.2880063 0.1722065 1.672 0.10170 c_age -0.0168912 0.0130611 -1.293 0.20283 c_initial_weight 0.0002952 0.0005606 0.527 0.60113 --- Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 Residual standard error: 0.4268 on 43 degrees of freedom Multiple R-squared: 0.3187, Adjusted R-squared: 0.2236 F-statistic: 3.352 on 6 and 43 DF, p-value: 0.008469 contrasts(factor(cows$level))

0.1 0.2 0.3
0     0   0   0
0.1   1   0   0
0.2   0   1   0
0.3   0   0   1


Questions:

1. In interpreting the coefficient of level in model 1, is it correct to say that with a unit change in additive level (and other covariates at their mean) the milk fat level changes by 1.89 units? The intercept is the fat level without additive and at other covariates at their mean? Additive levels in this experiment vary only from 0.0 to 0.3, so is this a valid interpretation?

2. How would I reconcile model 2 to model 1, given that some of the factor levels are now not significant?

3. Why have the regression coefficients of the covariates changed by this conversion of the numeric factor to categorical (model 1 to model 2)?

4. Why have the $R^2$ and the $F-$statistic changed (model 1 to model 2)?

4. Because the models are again completely different, the $R^2$ and F-statistic will also change.