Let Y be a logical vector and X1 a factor with 3 levels. Since Y is binary, logistic regression is used.
Y <- c(0,0,0,0,0,0,1,1,1,0,1,1,0,1,1,0,1,1,0,0) X1 <- rep(1:4,5) factor.X1 <- as.factor(X1) fit.overall <- glm(Y~X1,family = binomial(link="logit")) fit.levelwise <- glm(Y~factor.X1,family = binomial(link="logit")) exp(fit.overall$coefficients) exp(fit.levelwise$coefficients)
Both these fits are not significant. Assuming the variables were significant, we could interpret the coefficients of the variables in terms of odds-ratio. When using as.factor(X1), it seems that dummy variables are created.
How can one interpret a general coefficient (here X1) versus levelwise coefficients (factor.X12 factor.X13 factor.X14) ?
> exp(fit.overall$coefficients) (Intercept) X1 0.6680935 1.0842614 > exp(fit.levelwise$coefficients) (Intercept) factor.X12 factor.X13 factor.X14 0.6666667 1.0000000 2.2500000 1.0000000
Attempt to answer
Here is how I would interpret these odd-ratios :
- With fit.overall, the odds of Y increase by a factor of 1.08 if X1 is increased of one unit.
- With fit.levelwise, the odds of Y are equal whether X1 is 1,2 or 3 and are multiplied by 2.25 if X1 is 3.