Mix of variable types as control variables in MatchIt This is my first time using R and MatchIt. I am trying to conduct 2:1 optimal matching to match 396 controls to 28 treated. The covariates are age, sex, BMI, smoking status, and presence of co-morbidities. I am not sure whether it is okay to mix different types of variables. Age and BMI are continuous variables, the rest are categorical. Smoking status and the presence of co-morbidities have multiple categories (e.g. 0=no diabetes, 1= type 1 diabetes, 2 = type 2 diabetes). Do I need to create dummy variables for the categorical variables to make them only binary?
Please help. Thanks!
 A: Welcome to CV. The default form of matching used in MatchIt is propensity score matching. This involves computing a propensity score for each unit and then finding control units with similar propensity scores to treated units and discarding the rest. The propensity score acts as a summary of all the covariates included in its calculation, so it doesn't matter what types of variables they are; you are only performing the matching on the propensity score itself and all information about the covariates is lost during the match. For other types of matching, such as Mahalanobis distance matching, the types of the variables do matter because matching is done on the covariates in a more direct way.
Regarding the programming aspect, R automatically creates dummy variables when they are included in the model formula (i.e., A ~ X1 + X2) and are stored as factors or characters in your dataset. If the variable is stored literally in your dataset as the numbers 0, 1, 2, and 3, R has no way of knowing that you intend for that variable to be categorical rather than quantitative. Questions about specific programming languages are not on topic for this site, but you can ask questions on StackOverflow about how to use R.
