I am working with regression models of a class not supported by stargazer
.
Below is the model I am working with:
data(mtcars)
model.fixest <- feols(mpg ~ hp + drat + wt, data=subset(mtcars))
I can dilute down the basic statistics to the following table
model.fixest[["coeftable"]]
Estimate Std. Error t value Pr(>|t|)
(Intercept) 29.3949345 6.156303365 4.774770 5.133678e-05
hp -0.0322304 0.008924543 -3.611434 1.178415e-03
drat 1.6150485 1.226982656 1.316277 1.987554e-01
wt -3.2279541 0.796398312 -4.053190 3.642961e-04
Is there any way I could graft these values onto a regression model?
Best
you can export the coeftable to stargazer like this:
library(fixest)
library(dplyr)
library(stargazer)
data(mtcars)
model.fixest <- feols(mpg ~ hp + drat + wt, data=subset(mtcars))
# Manual coefficient extraction
export_manual_stargazer <- function(fixest_model) {
# Extract coefficient table
coef_table <- fixest_model[["coeftable"]]
# Create a data frame with coefficients
model_df <- data.frame(
term = rownames(coef_table),
estimate = coef_table[, "Estimate"],
std.error = coef_table[, "Std. Error"],
statistic = coef_table[, "t value"],
p.value = coef_table[, "Pr(>|t|)"]
)
# Create stargazer output manually
stargazer(model_df,
summary = FALSE,
type = "text", # Change to "latex" for LaTeX output
rownames = FALSE)
}
export_manual_stargazer(model.fixest)
Output:
> export_manual_stargazer(model.fixest)
================================================
term estimate std.error statistic p.value
------------------------------------------------
(Intercept) 29.395 6.156 4.775 0.0001
hp -0.032 0.009 -3.611 0.001
drat 1.615 1.227 1.316 0.199
wt -3.228 0.796 -4.053 0.0004
------------------------------------------------