我已经安装了一些GLM模型,我试图将它们绘制成可视化。我一直在寻找关于绘制GLM几个小时的示例和问题,但我无法输出任何显示我已经安装的GLM行的图表。如果有人能给我一个例子来了解如何实现这一目标,我将不胜感激。这是我第一次使用ggplot2
包。
这是我的数据的样子
df <- structure(list(var1 = c(3.758, 5.647, 4.499, 4.198, 3.89, 1.994,
4.557, 4.056, 3.635, 3.821, 4.221, 4.21, 4.332, 3.55, 4.137,
4.409, 4.141, 3.939, 4.263, 3.872, 4.526, 4.328, 3.974, 3.033,
3.897, 4.46, 4.258, 3.997, 4.067, 3.829, 4.435, 3.875, 3.911,
4.423, 4.127, 3.926, 3.831, 4.074, 4.785, 3.906, 4.212, 4.072,
4.189, 3.782, 3.994, 4.029, 4.378, 4.434, 4.127, 3.617, 1.075,
7.039, 2.661, 3.941, 3.758, 3.394, 3.164, 3.941, 3.937, 3.944,
4.043, 3.581, 3.979, 3.744, 2.152, 4.005, 2.787, 3.706, 3.283,
3.895, 5.673, 3.494, 3.867, 5.606, 4.057, 3.308, 3.309, 3.394,
4.006, 3.583, 3.598, 3.395, 3.209, 3.888, 3.911, 3.77, 3.629,
3.445, 1.726, 3.739, 3.29, 4.06, 3.68, 3.505, 3.811, 1.634, 3.91,
2.859, 3.696, 3.83, 3.148), var2 = c(2, 5, 1, 2, 2, 3, 4, 1,
3, 3, 2, 0, 0, 2, 1, 0, 2, 2, 12, 0, 2, 3, 3, 3, 4, 3, 4, 2,
4, 3, 2, 2, 2, 2, 1, 1, 5, 2, 1, 1, 0, 3, 4, 2, 1, 5, 1, 2, 6,
1, 1, 0, 1, 2, 2, 3, 1, 6, 5, 5, 1, 3, 1, 3, 1, 1, 1, 1, 2, 2,
0, 2, 0, 0, 0, 0, 0, 3, 0, 0, 1, 2, 1, 1, 5, 1, 1, 1, 3, 2, 2,
0, 1, 0, 0, 0, 1, 0, 1, 0, 2), group = structure(c(1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
2L, 2L), .Label = c("A", "B"), class = "factor")), row.names = c(NA,
-101L), class = "data.frame", .Names = c("var1", "var2", "group"
))
model <- glm(formula = group ~ var1 + var2, family = "binomial", data = df)
我正在寻找像这些数字之一的输出:
我见过很多例子,但没有错误就无法应用。