【问题标题】:Plotting a mixed effects model with three fixed effects绘制具有三个固定效应的混合效应模型
【发布时间】:2019-04-30 16:57:59
【问题描述】:

我正在尝试为我正在处理的项目找到一种可视化混合效果模型的方法,但我不确定在使用多个固定和随机效果时如何做到这一点。

我正在进行的项目是尝试根据几个不同的因素来估计在线评论的有用性。数据样本如下所示:

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 名参与者,每人看到大约两打评论,产生大约 700 条条目)。每个参与者都会看到各种产品、产品类型和星级评分,但他们看到的所有评论要么是匿名的,要么是非匿名的(没有混合)。

因此,我尝试使用以下内容拟合最大混合模型:

mixed(helpfulness ~ product_type * star_rating * anonymity 
    + (product_type * star_rating | participant) 
    + (star_rating * anonymity | product))

我现在想做的是找到一种直观地表示数据的方法,可能对 8 个不同的“组”进行颜色编码(本质上是 3 个二进制自变量的不同独特组合(2 种产品 * 2 种星级评分 * 2 种匿名),以显示它们与乐于助人评分的关系。

【问题讨论】:

    标签: r ggplot2


    【解决方案1】:

    试试这样的:

    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

    【讨论】:

      猜你喜欢
      • 2020-06-10
      • 2015-09-13
      • 1970-01-01
      • 2020-03-18
      • 1970-01-01
      • 1970-01-01
      • 2018-11-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多