Closed eohne closed 1 month ago
Another quick question. Is there a way to render the summary table as a LaTeX table? Like etable, stargazer do?
You can write some quick custom tidiers, which would enable integration with the (fantastic) modelsummary
package.
library(alpaca)
data(psid, package = "bife")
mod = feglm(
LFP ~ KID1 + KID2 + KID3 + log(INCH) | ID + TIME,
data = psid,
family = binomial("probit")
)
apes = getAPEs(mod)
bcapes = getAPEs(biasCorr(mod))
# add custom functions to extract estimates (tidy) and goodness-of-fit (glance) information
tidy.APEs = function(x, ...) {
cm = summary(x, ...)$cm
cm = cbind(rownames(cm), data.frame(cm, row.names=NULL))
ci = data.frame(confint(x, ...), row.names=NULL)
ret = setNames(
cbind(cm, ci),
c('term', 'estimate', 'std.error', 'statistic', 'p.value', 'conf.low', 'conf.high')
)
ret
}
glance.APEs = function(x, ...) {
data.frame(class = 'APE')
}
library(modelsummary)
modelsummary(
list('Naive' = apes, 'Bias-corrected' = bcapes),
output = 'markdown' # change to e.g. 'regtab.tex' for latex writing
)
Naive | Bias-corrected | |
---|---|---|
KID1 | -0.088 | -0.097 |
(0.008) | (0.008) | |
KID2 | -0.045 | -0.049 |
(0.007) | (0.007) | |
KID3 | -0.001 | -0.001 |
(0.005) | (0.005) | |
log(INCH) | -0.030 | -0.034 |
(0.008) | (0.008) | |
class | APE | APE |
Created on 2024-09-20 with reprex v2.1.1
Hi,
thanks for your question.
Currently, alpaca does not support clustered SEs for APEs but only for the coefficients. This extension is on our agenda, but requires some careful thoughts and derivations first due to some complications with bias-correted APEs.
I admit that it’s a bit unfortunate that there is no warning, when you are trying to compute clustered SEs for APEs. So it’s good that we aware of it now.
Although not perfect, in the meanwhile it might be ok to test the signicance of the effect of your variable of interest with the bias corrected coefficients and clustered SEs.
Best wishes, Amrei
modelsummary
package and the code snippet. Thanks again for your awsome package!
Will close this issue as I now know all that I need to know. Thanks again to you both!
Best wishes Elias
Hi, first thanks for the awesome package. I have a quick question. Does the summary output of getAPEs actually allow for clustering?
I run a Logit model with two fixed effects using
feglm
.I next use the
biasCorr
command.If I use
summary(bias_corr_res, cluster = ~cluster_var, type="clustered")
I get clustered standard errors back and all is okay. i.e.If I instead want the output for getAPEs instead standard errors are not clustered. The command I run is this:
which gives the same standard error as:
or this:
Edit: Another quick question. Is there a way to render the summary table as a LaTeX table? Like etable, stargazer do?