_SeanBock Profile Banner
Sean Bock Profile
Sean Bock

@_SeanBock

Followers
347
Following
665
Media
29
Statuses
308

Research Scientist @Meta. Sociology PhD @Harvard. Tweeting about #rstats, #dataviz

New York, NY
Joined November 2017
Don't wanna be here? Send us removal request.
@_SeanBock
Sean Bock
2 years
The hardest thing about transitioning from @Stata to #Rstats was giving up the incredible margins command. That's why @VincentAB's marginaleffects package is a godsend! But slight differences in terminology make it a bit confusing to nav. Here's a short thread comparing the two:.
1
40
242
@_SeanBock
Sean Bock
1 year
RT @LandonSchnabel: New article on what happened to religion, and the measurement of religion, during the pandemic: .
0
6
0
@_SeanBock
Sean Bock
2 years
RT @ccanonne_: Wait, did they REALLY go with \mathbb{X} as their logo? .They cannot possibly be THAT lazy?
Tweet media one
0
2K
0
@_SeanBock
Sean Bock
2 years
RT @bartbonikowski: My AJS article (link in thread below) on the partisan sorting of nationalist beliefs in the United States, co-authored….
0
10
0
@_SeanBock
Sean Bock
2 years
I'd also highly recommend checking the incredibly thorough documentation for the marginaleffects package. Great overview of these methods.
2
0
6
@_SeanBock
Sean Bock
2 years
There's WAY more functionality with both of these libraries of course, but these are probably the most common usages, especially in #Sociology. Hopefully this helps clear up some confusion for former #Stata users who'd like to work with average predictions and AMES in #Rstats!.
1
1
4
@_SeanBock
Sean Bock
2 years
Next, let's look at how they handle "Average marginal effects" (AMEs). In Stata, this is done with the "dydx()" argument after margins. In marginaleffects, we obtain these with the avg_slopes() function, specifying the predictor variable of interest with the "variables" argument
Tweet media one
Tweet media two
1
0
1
@_SeanBock
Sean Bock
2 years
Importantly, the "by" argument, as opposed to "variables", averages predictions over each subgroup specified, rather than averaging over all respondents under counterfactual scenarios. This is equivalent to using the "over()" argument with margins.
Tweet media one
Tweet media two
1
0
0
@_SeanBock
Sean Bock
2 years
The results are close, but not exactly the same. By default, the marginaleffects package averages preds on the link scale and then backtransforms to the response scale. Stata average directly on the response scale. We can match the Stata procedure by setting type = "response").
Tweet media one
1
0
2
@_SeanBock
Sean Bock
2 years
The marginaleffects packages refers to these types of predictions as "average counterfactual adjusted predictions", which can be obtained with the avg_predictions() function. Importantly, we obtain the average predicted probs for college with the "variable" argument.
Tweet media one
1
0
1
@_SeanBock
Sean Bock
2 years
The default in margins returns average predictions based on a given model. Here, we see the average predicted probabilities of identifying as middle class (or higher) by college degree attainment, adjusting for sex and income.
Tweet media one
1
0
2
@_SeanBock
Sean Bock
3 years
Ah yes. Further justification for my regular Excel diatribes. Excellent tool for many tasks—but it absolutely blows my mind that it’s central to the workflows of many (most?) organizations and researchers!.
@emollick
Ethan Mollick
3 years
🤯Because of Excel, a THIRD of all genetics papers published in top journals have errors, as many genes have names like SEPT2 (the official name of Septin 2), which Excel automatically makes dates. The issue was found in 2016, but still hasn’t improved!
Tweet media one
Tweet media two
0
0
1
@_SeanBock
Sean Bock
3 years
RT @emollick: 🤯Because of Excel, a THIRD of all genetics papers published in top journals have errors, as many genes have names like SEPT2….
0
1K
0
@_SeanBock
Sean Bock
3 years
Which season season of Stranger Things is the scariest? Based on a sentiment analysis of scripts, it looks like it's Season 4 (seems right to me!). I walk through how I made this graph in my latest blog post: #rstats #TidyTuesday #tidyverse #textmining
Tweet media one
1
5
14
@_SeanBock
Sean Bock
3 years
RT @alan_bastable: This new app from @_SeanBock is great fun. Computes the odds of any given handicap beating any other given handicap in a….
0
2
0
@_SeanBock
Sean Bock
3 years
9PM to 12PM? ULTIMATE KARAOKE might be an understatement.
Tweet media one
1
1
2
@_SeanBock
Sean Bock
3 years
RT @LandonSchnabel: In the 2021 GSS, religion appears to have declined dramatically. Did the COVID-19 pandemic precipitate rapid religious….
0
11
0
@_SeanBock
Sean Bock
3 years
RT @TheSocietyPages: New on the site S Ericson writes up recent research from @bartbonikowski, @YuvalFeinstein, & @_SeanBock in @ChicagoJou….
0
2
0
@_SeanBock
Sean Bock
3 years
Glad to learn that Gollum survived the fall at Mount Doom and is now the editor of a prestigious biomedical journal. #LordOfTheRings #Sociology
Tweet media one
0
0
5