Reputation: 83
I was wondering what would be the best way to calculate and present standardized coefficients using fixest
. Here is what I tried using easystats
library(parameters)
library(effectsize)
library(fixest)
m <- lm(rating ~ complaints, data = attitude)
standardize_parameters(m, method="basic")# works
m <- feols(rating ~ complaints, data = attitude)
standardize_parameters(m, method="basic")# Error in stats::model.frame(model)[[1]] : subscript out of bounds
I also tried the modelsummary
approach, but it shows unstandardized coefficients with no error.
library(parameters)
library(effectsize)
m <- lm(rating ~ complaints, data = attitude)
modelsummary(m, standardize="refit") # works, coeffs are different
m <- feols(rating ~ complaints, data = attitude)
modelsummary(m, standardize="refit")# doesn't work, coeffs are the same
Any insight or advice on how to elegantly and easily pull standardized coefficients out of fixest
estimation results would be greatly appreciated. My goal is to replicate the venerable to use listcoef
package in Stata. Many thanks to the authors of the packages mentioned in this post!
Edit: ``` > packageVersion("modelsummary") [1] ‘1.1.0.9000’
Upvotes: 2
Views: 376
Reputation: 3228
One potential solution is to just manually calculate the standardized coefficients yourself, as [detailed here][1]. As an example, below I scale your predictor and outcome, then calculate the standardized beta coefficient of the only predictor in your model.
#### Scale Predictor and Outcome ####
scale.x <- sd(attitude$complaints)
scale.y <- sd(attitude$rating)
#### Obtain Standardized Coefficients ####
sb <- coef(m)[2] * scale.x / scale.y
sb
Which gives you this (you can ignore the column name, as it is just borrowing it from the original coef
vector):
complaints
0.8254176
[1]: https://www.sciencedirect.com/topics/mathematics/standardized-regression-coefficient#:~:text=The%20standardized%20regression%20coefficient%2C%20found,one%20of%20its%20standardized%20units%20(
Upvotes: 2