我正在尝试找到一种方法来可视化我正在工作的项目的混合效果模型,但当使用多个固定和随机效果时,我不确定如何做到这一点。
我正在做的这个项目是基于几个不同的因素来评估在线评论的帮助。数据示例如下所示:
Participant Product Type Star Rating Anonymous Product Helpfulness
1 Exp Extr Yes 12 8
1 Search Extr Yes 6 6
1 Search Mid Yes 13 7
...
30 Exp Mid No 11 2
30 Exp Mid No 14 4
30 Search Extr No 9 5数据比这要长得多(30名参与者,他们每个人都看到了大约24篇评论,结果大约是。700个条目)。每个参与者都看到了产品、产品类型和星级的混合,但他们看到的所有评论要么是匿名的,要么不是匿名的(没有混合)。
因此,我尝试使用以下内容来拟合最大混合模型:
mixed(helpfulness ~ product_type * star_rating * anonymity
+ (product_type * star_rating | participant)
+ (star_rating * anonymity | product))我现在想要做的是找到一种直观地表示数据的方法,可能对8个不同的“组”进行颜色编码(本质上,3个二进制自变量的不同的唯一组合(2种产品*2种星级*2种匿名),以显示它们与帮助评级的关系。
发布于 2019-05-01 21:04:58
尝试如下所示:
library(ggplot2)
# make notional data
df <- data.frame(participant = seq(1,30,1),
product_type = sample(x=c('Exp', 'Search'), size=30, replace=T),
star_rating = sample(x=c('Extr', 'Mid'), size=30, replace=T),
anonymous = sample(x=c('Yes', 'No'), size=30, replace=T),
product = rnorm(n=30, mean=10, sd=5),
helpfullness = rnorm(n=30, mean=5, sd=3))
ggplot(df) +
geom_col(aes(x=participant, y=helpfullness, fill=product, color=anonymous)) +
facet_grid(c('product_type', 'star_rating'))这将捕获数据中的所有六个变量。您还可以使用alpha和其他美学来包含变量。如果您不想使用facet_grid,那么使用alpha可能更好。如果您将alpha作为一种美学考虑,我建议您使用facet_wrap而不是facet_grid。

https://stackoverflow.com/questions/55925608
复制相似问题