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!!