Here is a logistic regression with a factor independent variable having three levels 0, 1, 2. The regression creates two dummy variables x1and x2. Is x1 equal to my level 0 or my level 1? And why does the regression only show two variables rather than three?

df <- data.frame(cbind(x=c(0,0,0,0,0,1,1,1,1,1,2,2,2,2,2), y=c(0,1,0,1,1,0,0,1,1,1,0,1,1,1,1)))

df$x <- factor(df$x)

model <- glm(y~x, data=df, family="binomial")

summary(model)

'data.frame': 15 obs. of 2 variables:

x: Factor w/ 3 levels "0","1","2": 1 1 1 1 1 2 2 2 2 2 ...
y: num 0 1 0 1 1 0 0 1 1 1 ...

Call:

glm(formula = y ~ x, family = "binomial", data = df)

Deviance Residuals:

Min 1Q Median 3Q Max

-1.7941 -1.3537 0.6681 1.0108 1.0108

Coefficients:

Estimate Std. Error z value Pr(>|z|)

(Intercept) 4.055e-01 9.129e-01 0.444 0.657

x1 1.282e-16 1.291e+00 0.000 1.000

x2 9.808e-01 1.443e+00 0.680 0.497

(Dispersion parameter for binomial family taken to be 1)

```
Null deviance: 19.095 on 14 degrees of freedom
```

Residual deviance: 18.464 on 12 degrees of freedom

AIC: 24.464

Number of Fisher Scoring iterations: 4