-
Notifications
You must be signed in to change notification settings - Fork 61
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Include mean of dependent variable as a row in "etable" #43
Comments
It is supported, there's the argument Here's an example: base = iris
names(base) = c("y", "x1", "x2", "x3", "species")
s = base$species
library(fixest)
est_setosa = feols(y ~ x1 + x2, base[s == "setosa",])
est_versicolor = feols(y ~ x1 + x2, base[s == "versicolor",])
est_virginica = feols(y ~ x1 + x2, base[s == "virginica",])
all_means = sapply(c("setosa", "versicolor", "virginica"),
function(v) mean(base[s == v, "y"]))
etable(est_setosa, est_versicolor, est_virginica, extraline = list("$\\bar{y}$"=all_means), tex = TRUE) To place the line after the statistics you need to add a special markup in curly brackets ( etable(est_setosa, est_versicolor, est_virginica, extraline = list("{where:stat}$\\bar{y}$"=all_means), tex = TRUE) You can add as many lines as you wish. For more customization of the table, there's this vignette. |
Many thanks Laurent! I was able to implement this procedure after updating R to the latest version, followed by updating fixest to the latest version.
Regards,
Bhargav
… On Aug 26, 2020, at 3:43 AM, Laurent Bergé ***@***.***> wrote:
It is supported, there's the argument extraline doing that. Of course, you have to compute the means on your own.
Here's an example:
base = iris
names(base) = c("y", "x1", "x2", "x3", "species")
s = base$species
library(fixest)
est_setosa = feols(y ~ x1 + x2, base[s == "setosa",])
est_versicolor = feols(y ~ x1 + x2, base[s == "versicolor",])
est_virginica = feols(y ~ x1 + x2, base[s == "virginica",])
all_means = sapply(c("setosa", "versicolor", "virginica"),
function(v) mean(base[s == v, "y"]))
etable(est_setosa, est_versicolor, est_virginica, extraline = list("$\\bar{y}$"=all_means), tex = TRUE)
This leads to:
To place the line after the statistics you need to add a special markup in curly brackets (where:stat) at the beginning of the row name:
etable(est_setosa, est_versicolor, est_virginica, extraline = list("{where:stat}$\\bar{y}$"=all_means), tex = TRUE)
Which leads to:
You can add as many lines as you wish. For more customization of the table, there's this vignette.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub, or unsubscribe.
|
Super :-), I'm closing then. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi Laurent,
In my regression tables, I'd like to have a row at the bottom indicating the mean of the dependent variable (along with the currently supported number of observations and r squared). Is there a way etable could support this feature?
The text was updated successfully, but these errors were encountered: