0
$\begingroup$

I'm new to mixed effects modeling and definitely lme4 and would greatly appreciate some advice.

My research question: what factors determine a business' number of online reviews per day?

The data is cross-sectional and the observations are businesses.

Dependent variable : number of online reviews (interested in its ratio = number of reviews per day)

Independent variables are either business-related or location-related as shown in the table below. Except concentration, location factors are not of interest to me and are included as controls.

Here's a sample of 4 rows of the data. There are a few more variables related to the businesses and locations which I’m leaving out for brevity:

enter image description here

Since one of my focal independent variables (concentration of competitors) is at zip code level and these businesses are nested in zip codes (and thus can share concentration values), I've decided to use mixed effect models with zip code as random effect. Also, since the dependent variable is count, I've decided to go with either Poisson or negative binomial regression with the span of online reviews in days as offset. I'm using lme4 in R and my questions mainly revolve around my formula below and if it is sound or not.

Formula: number of online reviews ~ price * concentration + number of services provided + offset(log of time span of online reviews) + (1|zipcode) + (1|price)

One of my main intended theoretical contributions is to highlight how the effects of different factors depend on locational-factors especially concentration. Does my formula (specifically 1|zipcode) accurately reflect that? I will note that the concentration variable has a very limited range (75% if data points are between 0 and 4) so I could not categorize it into numerous categories to use it as a random effect separate from zipcode).

Feel free to address any other concerns you see or even rewrite the formula to clear things up for me.

$\endgroup$
5
  • $\begingroup$ Why are you including price as both a fixed and a random effect? $\endgroup$
    – EdM
    Commented Jul 17 at 19:40
  • $\begingroup$ Correct me if I'm wrong but my rationale is that price has a population-wide effect on the number of reviews, regardless of zip code. I've modeled that as a fixed effect. But I also believe that depending on what zip code a business is located in, the effect of price will vary, mostly due to different competitive pressures (operationalized as the "concentration" variable). $\endgroup$ Commented Jul 17 at 19:46
  • $\begingroup$ Then you would need to invoke a random slope for price as part of the random effect for zipcode, which in your current model only provides a random intercept. See the lmer cheat sheet for different ways to do that, depending on your assumptions, with price as the fixed effect in those examples. $\endgroup$
    – EdM
    Commented Jul 17 at 19:56
  • $\begingroup$ @EdM thanks for sharing the useful link. It took me to some other useful sources, too. So, as I understand now, you were implying (1 + price|zipcode). I have another lingering question if you don't mind: the literature says that locational factors such as average home value or population density affects my dependent variable. Given I am using zipcode as random effect, would it be superfluous or even wrong to include those locational factors as fixed effects? Of course, I do want to have one locational factor of interest to me (concentration) as fixed effect if possible. $\endgroup$ Commented Jul 18 at 20:55
  • 1
    $\begingroup$ The way I think about this is that random effects account for associations with outcome beyond those modeled with the fixed effects. So you should include fixed effects that you think might be associated with outcome (like average price and population density); then the random effects handle unobserved variables associated with zipcode and within-zipcode correlations. Note that (1+price|zipcode) imposes a correlation between the random intercepts and slopes; see this answer for how to remove that restriction if appropriate. $\endgroup$
    – EdM
    Commented Jul 19 at 14:26

1 Answer 1

2
$\begingroup$

The approach to using mixed effects modeling with zipcode as a grouping variable for random intercepts to account for the nested structure of the data is appropriate. However, there are a few important considerations and improvements to your model formulation.

Points to Consider:

Random Effects:

Using (1|zipcode) is correct as it accounts for the variability in the number of online reviews across different zip codes. Including price as a grouping variable for random intercepts does not seem appropriate since it is also included as a fixed effect and is not a grouping variable in the traditional sense. Instead, you can consider using random slopes for price if you hypothesize that the effect of price on the number of reviews varies across zip codes.

Offset and Dependent Variable:

Using the log of the time span of online reviews as an offset is correct since it adjusts for the differing time spans across businesses, allowing you to model the rate of reviews per day. Interaction Effects:

If you are particularly interested in how the effect of price interacts with concentration, including the interaction term price * concentration is appropriate. This allows you to examine how the effect of price on the number of reviews changes at different levels of concentration.

Count Data:

Since your dependent variable is count data, using Poisson or negative binomial regression is appropriate. Negative binomial regression is preferred if there is overdispersion in the data (ie, the variance is greater than the mean).

Revised Formula:

Based on these points, here is a revised version of your formula:


# Poisson model (or you could use glmer.nb for a negative binomial model if overdispersion is present)
model <- glmer(
  number_of_online_reviews ~ price * concentration + number_of_services_provided + 
  offset(log(time_span_of_online_reviews)) + (1 + price|zipcode),
  family = poisson(link = "log"), data = your_data_frame
)

Explanation:

Fixed Effects:

  • price * concentration: This includes both main effects and the interaction effect.
  • number_of_services_provided: As a control variable.
  • offset(log(time_span_of_online_reviews)): Adjusts for differing time spans of review collection.

Random Effects:

  • (1 + price|zipcode): Random slopes for price within zip codes to allow the effect of price to vary across zip codes.

This model will help you understand the main effects of your variables of interest, the interaction between price and concentration, and how these effects may vary by location.

Additional Considerations:

  • Model Diagnostics: After fitting the model, perform diagnostics to check for overdispersion (for Poisson models) and the goodness-of-fit.

  • Variable Transformations: Ensure that your independent variables are appropriately scaled or transformed if necessary.

If you encounter convergence issues or other model fitting problems, you may need to adjust your model specifications (eg., by removing the random slopes for price) or consider alternative modeling approaches.

$\endgroup$
2
  • $\begingroup$ Thanks for this thorough and well-organized response. I feel much clearer now. I do have one follow-up question if you don't mind. I want to include some zipcode-level factors such as median home values or population average age as fixed effects either because I'm interested in knowing their coefficients or as a control variables following the literature. However, is that appropriate given that I'm already accounting for zipcode level variations by using zipcode as a random effect? How are the two technically and conceptually different? $\endgroup$ Commented Jul 19 at 13:03
  • 1
    $\begingroup$ You are very welcome. I don’t see any issues with adding group-level variables as fixed effects. If you would like to provide more details then please go ahead and post a new question, and if you ping me here on this thread after doing so, I will be happy to take a look :) $\endgroup$ Commented Jul 19 at 14:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.