How to choose between including categorical variable as factor or continuous? I am fitting a regression model for a binary valued outcome as a function of an ordinal exposure taking as many as 21 different levels. Ordinal exposures can be coded continuously or categorically. How do I choose between controlling for this ordinal variable as categorical or continuous?
The reason for asking is that, in some sense, I could pick either in my logistic model, but factored and continuous produce very different predicted values. So there's a noticeable difference in the predictions as can be seen in the following plots:


So what to use in deciding which one is more accurate?

This particular variable, to which the numbers correspond, means "number of past skin cancers" (range is 1-21) and the risk I'm plotting is the risk of getting skin cancer again. x-axis is age. 
 A: So, the underlying scale is continuous. Given that, in my view it's your choice how you use this feature in a predictive model -- there is no hard and fast, much less theoretically driven, rule. If you choose to treat it as continuous, one workaround could be to plug in the midpoints of the range for each level of the discretization. For instance, if the first level is zero, then reset it to zero. If the next level is 1 to 2, plug in 1.5, and so on, until the final level which might be "21 and greater." For this final level, use the minimum value of 21. The resulting feature will be lumpily continuous but more informative than relying on the ranges assigned to each level. Of course, if you have the original information, replacing the categorizations with the actual counts would be a much better solution. 
To address your question about which approach is more "accurate," an empirical approach to answering this could be to randomly break out train vs test (or holdout) data samples. Train the two versions of the model on the same data and see which one provides a better fit in the test (validation or holdout) subset. To expand on this approach, you could also employ k-fold cross-validation which would lessen the potential for a spurious result simply as a consequence of a one-off finite data sample.
