# Variable for logistic regression is categorical and continuous so creates “missingness” in R

I am doing a logistic regression analysis using the glm command in R. It is to identify causes of valve narrowing beyond a certain threshold; 0=no narrowing, 1=narrowed. One of my variables is the size of a medical device that is implanted (range 25-36mm). Sometimes the device isn't implanted and I've left this as a blank field, but of course this is interpreted as a missing field. Not implanting the device seems to have a significant effect using Chi-sq analysis, and the size of the device has a significant effect using a t-test. How do I get around this in a linear regression model?

To make it more complicated I actually have two different makes of the device: "C" and "D" with sizes 25-36mm, another device without a size "S" and then no device "N". Can it all be entered together or is it best to analyze separately outside of regression?

What effect does the "missingness" have on various other variables that are in the analysis?

• Easiest thing to do would be to put zero when there is no implant. Then create a dummy for no implant and add it as a predictor. Jun 18, 2019 at 13:30

Approaches you could take for your primary problem:

1. You could put in a zero (instead of a blank). This is somewhat logically consistent with the variable of size - implanting something of zero size is perhaps equivalent to not implanting anything.

2. Related to this, you could put in a value that is substantially higher or lower than the range of values you have. This is particularly helpful when you are using modelling techniques that do not assume a linear relationship (such as a random forest). If not, you would have to give some thought to the shape of the relationship and how to model it (this advice is worth considering for approach #1 as well).

3. Use two variables, one categorical (was the device implanted or not?) and the other continuous (size, with missing values for no device i.e. the same as your present variable).

I don't know how to address your secondary problem (different devices, some with size unknown) well, but you could try using the device identity as a third variable (categorical, of course).

This question has some similarity to this question about nested variables. One measurement (size) is irrelevant when the device is not used. This is not necessarily the same as the device having size 0, so I would be careful with coding it as zero. Rather, the situation is more like a dataset with information about men and women, and one variable is being (or having been) pregnant. Since men cannot be pregnant, that variable is irrelevant for men. It must be coded in a way such that the values given for men does not influence the results of the analysis.