如何在GLM图上显示数据点
我在R中制作了一个模型,以查看Wikipedia的不同鸟类的景色,并根据各种生活历史特征绘制了它。
该模型输出了一些有用的不错的图形,但它们没有显示各个数据点。我希望能够看到图上的数据点,以便清楚它们的分布。
这是我第一次在堆栈溢出上发布,我不确定如何做一个可复制的示例,希望我在下面做的事情就足够了。我不想将数据子集的时间太长,因此我还没有包含我在模型中使用的所有列,但是如果有必要回答问题,我可以。我已经从代码开始,并在下面显示了数据结构。
谢谢。
m2.0_human_sedentary = glm(log_av_total_views ~ log_life_s * human_sett * log_weight_u_m + sedentary,
data = model_totalcount_lifeh)
plot_model(m2.0_human_sedentary, type = "int")
这很好,但是要尝试查看数据点,我添加了一个函数...
plot_model(m2.0_human_sedentary, type = "int", show.data = TRUE)
它在3/4的图上起作用,但是弄乱了最后一个函数,这恰好是我最感兴趣的一个。是没有错误的,但输出甚至不像图形。
model_totalcount_lifeh <-
structure(
list(
title = c(
"Peregrine falcon",
"Golden eagle",
"Osprey",
"Common raven",
"Mallard"
),
category.x = structure(
c(1L,
1L, 1L, 1L, 1L),
levels = c("LC", "NT", "VU"),
class = "factor"
),
av_total_views = c(
69717.4912280702,
53478.4210526316,
49867.9473684211,
39600.8245614035,
33459.8771929825
),
av_summer_views = c(
78226.962962963,
54020.7777777778,
58687.5925925926,
46819.7037037037,
36948.7777777778
),
Wing = c(332.5, 626, 482, 421.4, 272),
life_s = c(17,
32, 27, 23, 23)
),
class = c("grouped_df", "tbl_df", "tbl",
"data.frame"),
row.names = c(NA,-5L),
groups = structure(
list(
title = c(
"Common raven",
"Golden eagle",
"Mallard",
"Osprey",
"Peregrine falcon"
),
.rows = structure(
list(4L, 2L, 5L, 3L,
1L),
ptype = integer(0),
class = c("vctrs_list_of", "vctrs_vctr",
"list")
)
),
class = c("tbl_df", "tbl", "data.frame"),
row.names = c(NA,-5L),
.drop = TRUE
)
)
I have made a model in R looking at Wikipedia page views for different birds and plotted it according to various various life history traits.
The model outputs some nice graphs which are useful, but they don't show the individual data points. I would like to be able to see the data points on the graph so that the distribution of them is clear.
This is my first time posting on Stack overflow and I wasn't sure how to make a replicable example, hopefully what I have done below is enough. I didn't want to make the data subset too long so I haven't included all of the columns which I use in my model, but I could if that is necessary to answer the question. I have started with my code and shown the data structure below that.
Thank you.
m2.0_human_sedentary = glm(log_av_total_views ~ log_life_s * human_sett * log_weight_u_m + sedentary,
data = model_totalcount_lifeh)
plot_model(m2.0_human_sedentary, type = "int")
This works nicely, but to try and see the data points I added a function...
plot_model(m2.0_human_sedentary, type = "int", show.data = TRUE)
Which works on 3/4 of the plots, but messes up the last one, which happens to be the one I'm most interested in. There is no error, but the output doesn't even resemble a graph.
model_totalcount_lifeh <-
structure(
list(
title = c(
"Peregrine falcon",
"Golden eagle",
"Osprey",
"Common raven",
"Mallard"
),
category.x = structure(
c(1L,
1L, 1L, 1L, 1L),
levels = c("LC", "NT", "VU"),
class = "factor"
),
av_total_views = c(
69717.4912280702,
53478.4210526316,
49867.9473684211,
39600.8245614035,
33459.8771929825
),
av_summer_views = c(
78226.962962963,
54020.7777777778,
58687.5925925926,
46819.7037037037,
36948.7777777778
),
Wing = c(332.5, 626, 482, 421.4, 272),
life_s = c(17,
32, 27, 23, 23)
),
class = c("grouped_df", "tbl_df", "tbl",
"data.frame"),
row.names = c(NA,-5L),
groups = structure(
list(
title = c(
"Common raven",
"Golden eagle",
"Mallard",
"Osprey",
"Peregrine falcon"
),
.rows = structure(
list(4L, 2L, 5L, 3L,
1L),
ptype = integer(0),
class = c("vctrs_list_of", "vctrs_vctr",
"list")
)
),
class = c("tbl_df", "tbl", "data.frame"),
row.names = c(NA,-5L),
.drop = TRUE
)
)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论