简体   繁体   中英

Plotting a mixed effects model with three fixed effects

I am trying to find a way to visualize a mixed effects model for a project I am working on, but am unsure how to do this when using multiple fixed and random effects.

The project I am working on is an attempt to estimate the helpfulness of online reviews, based on several different factors. A sample of the data looks like this:

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

The data is significantly longer than this (30 participants, who each saw roughly two dozen reviews, resulting in approx. 700 entries). Each participant sees a mix of products, product types, and star ratings, but all of the reviews they see will either be anonymous or not anonymous (no mix).

As a result, I tried to fit a maximal mixed model, with the following:

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

What I would like to do now is to find a way of visually representing the data, likely color-coding the 8 different "groups" (essentially, the different unique combinations of the 3 binary independent variables (2 types of products * 2 types of star ratings * 2 types of anonymity), to show how they relate to the helpfulness rating.

Try something like this:

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'))

This captures all six variables in your data. You can also work with alpha and other aesthetics to include the variables. Using alpha might be better if you do not want to use a facet_grid . If you include alpha as an aesthetic, I would recommend using facet_wrap instead of facet_grid .

情节

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM