SCM

Forum: help

Monitor Forum | Start New Thread Start New Thread
RE: Export sfa results using latex or formattable table [ Reply ]
By: Dieter Koemle on 2020-12-21 11:36
[forum:48571]
Hey,
a bit late to the party here, but I faced a similar issue a while ago: the following code simply produces a "tidy" object that can then be used in huxreg (huxtable package) to produce Latex and other tables. It is not my own code, I found it somewhere on the internet and modified it a bit...


glance.frontier <- function(x, ...)
{
with(
summary(x),
tibble(
logLik = mleLogl,
nobs = nob,
nn = nn,
nt=nt,
AIC = stats::AIC(x),
BIC = stats::BIC(x)
)
)
}

tidy.frontier <- function(x, conf.int = FALSE, conf.level = .95,
exponentiate = FALSE, quick = FALSE, ...)
{

ret <- as_tibble(summary(x)$mleParam, rownames = "term")
colnames(ret) <- c("term", "estimate", "std.error", "statistic", "p.value")

coefs <- tibble::enframe(stats::coef(x), name = "term", value = "estimate")
ret <- left_join(coefs, ret, by = c("term", "estimate"))

if (conf.int) {
ci <- broom_confint_terms(x, level = conf.level)
ret <- dplyr::left_join(ret, ci, by = "term")
}

ret
}


After running these, simply use huxreg(model_name) to produce the tables. you may want to add the options for the statistics shown manually, as in

huxreg(model_name, statistics = c("Log Likelihood" = "logLik",
"AIC" = "AIC",
"BIC" = "BIC",
"Total observations" = "nobs",
"# of firms" = "nn",
"# of time periods" = "nt"))

Best,

Dieter

RE: Export sfa results using latex or formattable table [ Reply ]
By: Josh Brown on 2020-01-23 18:24
[forum:47341]
Hi Robert,

If you're still interested, I was able to find a workaround to export the sfa results to LaTeX. It's not perfect, but it automates most of the work of the table making.

First, run your models as normal:
sfaResult1 <- sfa(log(y1) ~ log(x1) + log(x2) | z1 + z2, data = data)
sfaResult2<- sfa(log(y2) ~ log(x3) + log(x4) | z1 + z2, data = data)

Then save the coefficients and standard errors as vectors:
c1 <- as.vector(coef(sfaResult1))
c2 <- as.vector(coef(sfaResult2))

se1 <- as.vector(coef(summary(sfaResult1))[,2])
se2 <- as.vector(coef(summary(sfaResult2))[,2])

Then run the same specifications using a linear model (remember to change the "|" before the z variables to a "+" in the linear model):
lm1 <- lm(log(y1) ~ log(x1) + log(x2) + z1 + z2, data = data)
lm2 <- lm(log(y2) ~ log(x3) + log(x4) + z1 + z2, data = data)


Finally, use stargazer on the linear models, and change the coefficients and the standard errors reported using the "coef" and "se" arguments:
latexModels <- stargazer(lm1, lm2,
coef = list(c1, c2),
se = list(se1, se2),
digits = 2, 1float.env = "table")

The table produced isn't perfect, but it has all of the correct standard errors and coefficient estimates. You just have to take out the other things the lm reports like the R-squared value.

Hope this helps,
Josh Brown

RE: Export sfa results using latex or formattable table [ Reply ]
By: Arne Henningsen on 2019-11-03 13:50
[forum:47115]
I do the export manually using the "xtable" package but this requires much more manual adjustments than, e.g., the stargazer package. It would be great if someone could write a stargazer method for the "frontier" package. I could assist with this...

RE: Export sfa results using latex or formattable table [ Reply ]
By: Luca Elisei on 2019-09-15 09:24
[forum:46960]
Hi Robert,
For SFA output and others method I used excel2latex.

Cheers,
l.

Export sfa results using latex or formattable table [ Reply ]
By: Robert Walker on 2019-09-14 23:37
[forum:46959]
Hi,

I have used the frontier package to run a sfa regression. I am unable to find a solution to exporting the regression results in a table format to use in a report. the frontier and summary.frontier packages are not compatible with stargazer and other export packages like broom.

Could someone please point me in the right direction for what package or what method to export the regression summary results, preferably in a latex form?

Cheers,

Thanks to:
Vienna University of Economics and Business Powered By FusionForge