0
$\begingroup$

I have a clinical dataset of 1,100 observations of 22 variables. The dataset is mildly sparse (819/24,200 data points missing) with no particular row or column being particularly affected.

Both the dependent (disease present) and independent/predictor (symptoms) variables are binary, where 0 represents absent and 1 represents present for the disease or symptom. The independent variables are relevant to the disease itself, i.e. they're not randomly selected variables.

I want to perform binary logistic regression to determine the probability of disease presence.

However, this is my first time with logistic regression and binary data and I am a bit lost. I think I've read over 100 StackOverflow/CrossValidated posts now, but because I'm so new to it all and there seem to be conflicting responses, I'm still not sure and have a few questions.

  1. Do I need to generate dummy variables from my binary dataset after reading it into R? It's already in 0/1 (csv) format. This is my code to do this:

df <- na.omit(read.table("data.csv", header = TRUE, sep = ","))

This imports 773 observations.

  1. Is it possible to perform logistic regression with the sparse dataset? If so, that would allow for 1,100 observations in total.

  2. This is my code for creating the glm model (I've removed some of the independent variables from the function below for brevity):

model.fit <- glm(has_disease ~ symptomOne + symptomTwo + symptomThree + symptomFour + symptomFive + SymptomSix, data = df, family = binomial)

When I run this, I receive this warning message:

glm.fit: fitted probabilities numerically 0 or 1 occurred

Any help would be very much appreciated.

$\endgroup$

1 Answer 1

1
$\begingroup$

Ad 1. No, R generates the dummy coding as part of the GLM-call (through a call to model.matrix).

Ad 2. Yes/no. So you can hand over the data to GLM with values missing, but when you fit the full model, they will simply be dropped. So I would impute missing values (e.g. using mice). You currently lose 1/3 of your data points (i.e. a lot).

Ad 3. The warning comes up to indicate that with your model, you yield perfect separation for some of the data points (How to deal with perfect separation in logistic regression?). It is a case where the model may be fine, or not. One diagnostic is to check whether the estimates (and their standard errors) look plausible (i.e. -0.3 and 0.02, say): if so I would not worry (vulgo: I ignore the warning). If estimates and errors are sky-high (5000 and 250000, say), your model has attempted to construct a vertical line for separating 0s and 1s. In this case the above link towards regularisation can offer a solution. Before going down that route, I would check for correlation between your categorical predictors (https://en.wikipedia.org/wiki/Polychoric_correlation): maybe you can remove a few of them, reducing the dimensionality of the predictor space, and reducing the chance of perfect separation.

$\endgroup$
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.