# Independent variable is correlated with intercept, creating singularities

I am building a logistic model with about 20 variables. I have used the following code:

fullmod = glm(cancer ~ B_SEX+BLINE_AGE_AT_BASELINE+B_BMI+B_chro+B_fdrc+B_hrt+B_LMET+ B_MET+B_FV+B_EDU+B_INC+B_MAR+B_EMP+B_sm_status+B_sm_y+CDHQ1_ALCOHOL_MYP+CDHQ1_HEI_2005_DERV+red.meat.w.g+red.meat_cat+location,family=binomial,data=all)

Summary(fullmod)  I got the following output:

I have investigated the correlation structure/linear dependencies of independent variables , found this:

So, Sex is correlated with the intercept, I found some explanation regarding this situation here enter link description here

But what is the solution, how I can remove this singularity

• The link you included is unrelated. That's about the coefficients being correlated, not the predictors. Are you positive B_SEX has more than one value in it? This would occur if all values were the same. Are there any missing values in the predictors?
– Noah
Nov 28 '20 at 19:30
• Yes, B_Sex has two values 1=Female with 34436 entry, 0=Male with 19493. and Yes, Other predictors have missing values, but not in the B_SEX. Nov 28 '20 at 20:47
• If you run with(na.omit(all), table(B_SEX)), are there still two unique values? When missing data are present, all rows with missing data are removed by glm(), so the dataset that glm() fits the model on may not have the same levels as the data you submitted.
– Noah
Nov 28 '20 at 23:54
• Thanks a lot. I got it now, after running your code, I got only one value in B_SEX, which is 1=Female. Then I have tried na.action=na.pass code, but it gives me the following error: "Error in glm.fit(x = c(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, : NA/NaN/Inf in 'x' ". apperantly "glm" will not use rows containing NAs. do you have any suggestion? Nov 29 '20 at 2:11
• glm() cannot include missing values in the predictors or outcome. Search on this site for how to deal with missing values in regression. It's a big topic and the best answer depends on your purpose.
– Noah
Nov 29 '20 at 22:37