Is there a way to restrict the variables to control for in multivariate logistic regression?

Viewed 46

I would like to perform multivariate logistic regression in R and just control for specific variables in question. Like the case below I just want to control for age and gender. Is there a way to do that? I tried the control argument but it seem to work...

library(tidyverse)

set.seed(123)

df <- tibble(
  outcome = factor(rbinom(100, 1, 0.2), labels = c("No", "Yes")),
  pred1 = factor(rbinom(100, 1, 0.4), labels = c("No", "Yes")),
  pred2 = factor(rbinom(100, 1, 0.4), labels = c("No", "Yes")),
  pred3 = factor(rbinom(100, 1, 0.6), labels = c("No", "Yes")),
  pred4 = factor(rbinom(100, 1, 0.7), labels = c("No", "Yes")),
  gender = factor(rbinom(100, 1, 0.7), labels = c("Male", "Female")),
  age = round(rnorm(100, 24, 4))
)

# Not working
(glm(outcome ~ ., family = binomial,
                control = list("age", "gender"),
                data = df))

0 Answers
Related