1

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’

  • Is `attitude` included in one of those packages? If not, run `dput(attitude)` and paste the output into your question. Typically it is best practice here to provide a reproducible dataset with your question, otherwise it is difficult for people to answer. – Shawn Hemelstrand Jan 25 '23 at 02:36
  • 1
    Yeah, I know. It's part of these packages. This is the example in https://easystats.github.io/parameters/articles/standardize_parameters_effsize.html which modelsummary uses. – astrae_research Jan 25 '23 at 02:43

1 Answers1

1

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(

Shawn Hemelstrand
  • 2,676
  • 4
  • 17
  • 30
  • Thank you, Shawn! If there is no other way, the basic approach will have to suffice. I should have expressed myself clearer in my original post. I was looking to build a pipeline using methods built in the mentioned packages especially given that `fixest` is great for my field, `easystats` offers several advanced ways to standardize coeffs and `modelsummary` can present all of the standardized coefficients in a polished way. I also wondered if i found a bug or a way to help improve already excellent packages even more. – astrae_research Jan 25 '23 at 03:20
  • I tried it with the `iris` data and had a similar problem even with multiple predictors. Seems to be a bug. You could possibly file an issue with on Github with either the `fixest` authors (to tell them the limitations of getting betas) or the `modelsummary`/`standardized_parameters` authors (informing them that it doesn't seem to work on `fixest` objects. – Shawn Hemelstrand Jan 25 '23 at 03:33