strengejacke / sjPlot

sjPlot - Data Visualization for Statistics in Social Science
https://strengejacke.github.io/sjPlot
603 stars 91 forks source link

Wrong number of significance starts in plot_model #805

Open ECon87 opened 2 years ago

ECon87 commented 2 years ago
feols(y ~ x0 + to_factor(xtreat) |  to_factor(FE1) + to_factor(FE2), data = data)

plot_model(model2_treat,
           colors = "bw",
           show.values = T,
           value.offset = 0.4,
           value.size = 4,
           line.size = 1.4,
           vline.color = "grey",
           width = .5,
           axis.labels = "")

Returns:

wrong_stars

Clearly some coefficients are not significant, but everything gets 3 stars.

strengejacke commented 2 years ago

Do you have a reproducible example?

ECon87 commented 2 years ago

So, I cannot share the data that led to the previous graph, because they are from a research project.

I tried to create an artificial database, but I run into the opposite problem. I think the problem has to with the fixest::feols estimator. For model0 below (using feols), I get no stars. For model1 (using lm) everything works fine.

library(sjPlot)
library(sjmisc)
library(fixest)

x1 <- c(rnorm(100))
x2 <- c(rnorm(100))
x3 <- c(rnorm(100))
x4 <- c(rnorm(100))
e <- c(rnorm(100))
fe <- c(rep(1, 25), rep(2, 25), rep(3, 25), rep(4, 25))

df <- data.frame(x1, x2, x3, x4, e, fe)

df$y <- .5 * x1 - .25 * x2 + 1.1 * x3 + fe + e

model0 <- feols(y ~ x1 + x2 + x3 + x4| to_factor(fe), data = df)
model1 <- lm(y ~ x1 + x2 + x3 + x4, data = df)

plot_model(model0,
           show.values = TRUE,
           value.size = 4)

plot_model(model1,
           show.values = TRUE,
           value.size = 4)