# prepare dummy variables for binary logistic regression
y1 <- ifelse(swiss$Fertility < median(swiss$Fertility), 0, 1)
y2 <- ifelse(swiss$Infant.Mortality < median(swiss$Infant.Mortality), 0, 1)
y3 <- ifelse(swiss$Agriculture<median(swiss$Agriculture), 0, 1)
# Now fit the models. Note that all models share the same predictors
# and only differ in their dependent variable (y1, y2 and y3)
fitOR1 <- glm(y1 ~ swiss$Education + swiss$Examination + swiss$Catholic,
family = binomial(link = "logit"))
fitOR2 <- glm(y2 ~ swiss$Education + swiss$Examination + swiss$Catholic,
family = binomial(link = "logit"))
fitOR3 <- glm(y3 ~ swiss$Education + swiss$Examination + swiss$Catholic,
family = binomial(link = "logit"))
# plot multiple models
sjp.glmm(fitOR1, fitOR2, fitOR3, facet.grid = TRUE, fade.ns = FALSE)
# plot multiple models with legend labels and point shapes instead of value labels
sjp.glmm(fitOR1, fitOR2, fitOR3,
labelDependentVariables = c("Fertility",
"Infant Mortality",
"Agriculture"),
showValueLabels = FALSE,
showPValueLabels = FALSE,
usePShapes = TRUE)
# plot multiple models from nested lists parameter
all.models <- list()
all.models[[1]] <- fitOR1
all.models[[2]] <- fitOR2
all.models[[3]] <- fitOR3
sjp.glmm(all.models)
Run the code above in your browser using DataLab