0
$\begingroup$

I have a cross-sectional dataset with the data example below, where the variable (id) refers to each individual in the df and rows represent the different number of Reddit posts written by each username, which vary across individuals. My goal is to use OLS regression to predict average sentiment, based on individual-level covariates which are all measured at the username-level. For instance, the indicator "collective_action_prop" counts the proportion of collective action mentions across all posts for a given username.

Currently, I ran the OLS model as follows:

regress avg_sentiment avg_response collective_action_prop economic_demand_prop

However, I am not sure if I am correctly running the OLS regression at the username-level with the current data structure where each row represents a Reddit post but the variable id refers to usernames:


* Example generated by -dataex-. For more info, type help dataex
clear
input float id double avg_sentiment float avg_response double(collective_action_prop economic_demand_prop)
 1                 -1         1                  0                 1
 2                 -1         0                  0                 1
 3                  0         0                  0                 0
 4                  0         .                  0                 0
 4                  0         .                  0                 0
 5                  1         6                  0                 0
 6 -.2105263157894737  .2105263                  0 .2631578947368421
 6 -.2105263157894737  .2105263                  0 .2631578947368421
 6 -.2105263157894737         .                  0 .2631578947368421
 6 -.2105263157894737         .                  0 .2631578947368421
 6 -.2105263157894737         .                  0 .2631578947368421
 6 -.2105263157894737  .2105263                  0 .2631578947368421
 6 -.2105263157894737  .2105263                  0 .2631578947368421
 6 -.2105263157894737  .2105263                  0 .2631578947368421
 7 -.2307692307692307  .6923077 .07692307692307693 .3461538461538461
 7 -.2307692307692307  .6923077 .07692307692307693 .3461538461538461
 7 -.2307692307692307  .6923077 .07692307692307693 .3461538461538461
 7 -.2307692307692307  .6923077 .07692307692307693 .3461538461538461
 7 -.2307692307692307  .6923077 .07692307692307693 .3461538461538461
 7 -.2307692307692307  .6923077 .07692307692307693 .3461538461538461
 7 -.2307692307692307  .6923077 .07692307692307693 .3461538461538461
 7 -.2307692307692307  .6923077 .07692307692307693 .3461538461538461
end
----
```
$\endgroup$
5
  • 1
    $\begingroup$ Are you using avg_sentiment for convenience or because you don't know the value of sentiment associated with each individual post? $\endgroup$ Feb 22 at 11:27
  • $\begingroup$ Good question, for convenience where I am trying to estimate average sentiment at the reddit username-level. $\endgroup$
    – nesta1992
    Feb 22 at 14:52
  • 1
    $\begingroup$ In that case, I would suggest individual post sentiment as your response variable, as this would give you a measure of how much sentiment varies from post to post, once you have accounted for everything else. Also, this looks like a natural setup for a random-effects model, as you would expect the correlation between posts by the same user to be higher than the correlation between posts of different users. This also takes care of the fact that some users post more than others. $\endgroup$ Feb 22 at 16:23
  • $\begingroup$ Thanks for the feedback! So it makes sense to use sentiment per post as the outcome, with controls like avg_response or collective_action_prop that are measured at the individual-level, rather than post-level? I ask because I thought that my unit of analysis (e.g. username or post) has to be consistent across both my Y and control variables. $\endgroup$
    – nesta1992
    Feb 22 at 17:30
  • 1
    $\begingroup$ Yes, that's totally fine. I'll post a proper answer. $\endgroup$ Feb 22 at 17:45

1 Answer 1

1
$\begingroup$

Seeing as you know the sentiment for each post (not just the average sentiment by user), I would suggest a random-effects model.

In your case this would look like $$ y_{ij} = \beta_0 + \beta_1 x_j + u_j + \varepsilon_{ij} $$ where $y_{ij}$ is the sentiment for the $i$th post by user $j$, $x_j$ is a covariate at the individual level (you can have more than one, obviously), $u_j \sim \mathcal{N}(0, \sigma^2_u)$ are the random intercepts, and $\varepsilon_{ij} \sim \mathcal{N}(0, \sigma^2_\varepsilon)$ are the error terms.

This sort of model is very easy to fit in Stata, which is what I assume you're using. Take a look here: https://www.stata.com/features/overview/random-effects-panel-data-estimators/

$\endgroup$
2
  • $\begingroup$ Thanks for the useful advice! The example in the Stata link uses a binary outcome variable, yet the one I shall use would be an OLS regression with random effects, correct? $\endgroup$
    – nesta1992
    Feb 22 at 19:01
  • 1
    $\begingroup$ Ah, good point. Here's the full list: stata.com/features/panel-longitudinal-data The approach I suggested is a linear model with random intercepts. It's been a while since I used Stata, but I think it's the xtreg function with the re option. $\endgroup$ Feb 22 at 19:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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