How to treat discrete variables while modelling in regression

I have a small dataset Friends,Gender,Social 280,female,"13" 250,female,"12" 320,female,"15" 190,female,"14" 320,female,"11" 340,female,"15" 180,male,"10" 220,male,"8" 300,male,"11" 240,male,"9" 270,male,"10" 260,male,"9"

social is a score which means how socially active they were with people at their school(range from 0-20) with high score indicating highly social. Do I use social variable as a categorical variable while modelling?

In case of ordinal variables, you can go either way (treating them as categorical or numeric), and the choice depends on few factors:

If your "social" score is not-linear and you're actually testing to check if it has any significant link to your dependent variable, then treat it as Categorical. While this is conservative, this does lose the ordering information.

If "social" score is roughly equally spaced, then they might be considered as numeric in regression. Just beware of spurious "good" fits, you might get better $$r^2$$ , which won't be as good in predicting out of sample Y's. The upside is that you preserve the ordering information.

Since social is an ordinal variable, if you treat it as categorical, it will lose the order (size comparison).

In short, for ordinal variables, you can treat them directly as a numerical variable and your model should just work fine.

You treat variable as categorical only if there's no size comparison between the levels.

• So no need to factor the ordinal variable before modelling? Doesn't the ordinal variable is giving me different groups or score. Mar 8 '18 at 5:07
• Yes and no. Yes since it might be generated from more details however if you did convert them to categorical, you will lose the numerical relationship between levels. One thing you can try is called the “ordered categorical” in R. I personally don’t do anything with ordinal variables during my analysis.
– TYZ
Mar 8 '18 at 5:11
• social_f=factor(soc_int\$Social,ordered = TRUE,levels=c("8","9","10","11","12","13","14","15"), labels=c("8","9","10","11","12","13","14","15")) Do you mean this? Mar 8 '18 at 5:25