# Mulitple Logistic Regression for count data using glm

I am having some difficulties fitting a multiple logistic regression model for my data which looks like this, As you can see from the screenshot above there are 4 explanatory variables, age, gender, disability and race taking the binomial form as 1 and 0. The data can be presented as count data, where Y is the binary response variable (1 for Yes and 0 for No).

Data reproducible example:

set.seed(10)
age <- round(runif(186, 0,1))
gender <- round(runif(186, 0, 1))
disability <- round(runif(186, 0, 1))
race <- round(runif(186, 0, 1))

dat <- data.frame(age, gender, disability, race)

m <- cbind(table(dat$$age), table(dat$$gender), table(dat$$disability), table(dat$$race))

colnames(m) <- c("Age", "Gender", "Disability", "Race")

dt <- data.frame(m)
dt <- tibble::rownames_to_column(dt, "Y")
new_dt <- dt %>% select(Age, Gender, Disability, Race, Y)
new_dt


This seems like a very simple problem but I still can't figure out an appropriate solution to fit a multiple logistic model using glm() for this type of data specifically.

Sources

Logistic regression in r for aggregated counts

This doesn't work since it can only be applied to contingency table

Any help or advice would be greatly appreciated!!

• I don't see the issue. Your DV is binary. It does not matter if your IVs are count data or something else. For regression you only really care about the type of your DV. Just do glm(Y ~ age + gender + disability + race, data = new_dt, family = binomial) (add interactions as appropriate). – Roland Aug 24 at 6:08
• @Roland Thank you for your reply. I have tried this and got an error message in return, "Error in weights * y : non-numeric argument to binary operator". – Minh Chau Aug 24 at 6:15
• You need to coerce your Y variable to numeric. Row names are character strings. – Roland Aug 24 at 6:16
• @MinhChau Can you post a link to your actual data? I don't think your data is too small for the glm function. You can paste your data here: pastebin.com in plain text and share the link. – StatsStudent Aug 24 at 7:15
• @StatsStudent No worries it's not a biggie but I did attempt that and was getting the same problem so I am going to find another alternative. Thanks! – Minh Chau Aug 24 at 8:35

So I had an opportunity to recreate the raw dataset and run the logistic regression. It does in fact, run in R and SAS, but you have a problem with what is known as "quasi-complete separation of data points." This happens when a linear combination of predictor variables completely determines or separates the outcome variable, and so the maximum likelihood does estimates do not exist. Here is the output from SAS which indicates the issue:

Probability modeled is Y='1'.


Model Convergence Status Quasi-complete separation of data points detected.

**Warning: The maximum likelihood estimate may not exist.**

Warning: The LOGISTIC procedure continues in spite of the above warning. Results shown are based on the last maximum likelihood iteration. Validity of the model fit is questionable.

Model Fit Statistics
Criterion Intercept Only Intercept and
Covariates
AIC 1032.865 982.586
SC 1037.477 1005.646
-2 Log L 1030.865 972.586

Testing Global Null Hypothesis: BETA=0
Test Chi-Square DF Pr > ChiSq
Likelihood Ratio 58.2791 4 <.0001
Score 42.0614 4 <.0001
Wald 0.0543 4 0.9996

Analysis of Maximum Likelihood Estimates
Parameter DF Estimate Standard
Error Wald
Chi-Square Pr > ChiSq
Intercept 1 0.0633 0.0863 0.5380 0.4633
Age 1 -12.2182 119.4 0.0105 0.9185
Gender 1 12.1913 182.3 0.0045 0.9467
Disability 1 2.3E-11 152.7 0.0000 1.0000
Race 1 -984E-13 205.7 0.0000 1.0000

Odds Ratio Estimates
Effect Point Estimate 95% Wald
Confidence Limits
Age <0.001 <0.001 >999.999
Gender >999.999 <0.001 >999.999
Disability 1.000 <0.001 >999.999
Race 1.000 <0.001 >999.999