Reputation: 161
I am computing probit marginal effects from R mfx
package. I want to generate Latex code for the marginal effects output. I tried stargazer
package for OLS and probit coefficients, it works fine for both, however for probit marginal effects (by using probitmfx
command) it doesn't work.
Please help me in this regard, thanks.
Upvotes: 4
Views: 2256
Reputation: 571
You can use texreg
(documentation):
model <- probitmfx(formula = y ~ x, data = your_data)
texreg(model)
Upvotes: 0
Reputation: 8380
Analogous to bixiou's answer, maybe slightly more elegant (at least we don't fit twice):
ols <- lm(your_formula, data=your_data, family="binomial")
probit_margins <- probitmfx(your_formula, your_data, atmean=FALSE)
your_table <- stargazer(ols, probit_margins$fit,
coef = list(NULL, probit_margins$mfxest[,1]),
se = list(NULL, probit_margins$mfxest[,2]))
This exploits the fact that a probitmfx
object's fit
attribute is the original model.
Upvotes: 2
Reputation: 149
I haven't found an easy solution, but here is the hack that I use:
ols <- lm(your_formula, data=your_data, family="binomial")
probit <- glm(your_formula, data=your_data, family="binomial")
probit_margins <- probitmfx(your_formula, your_data, atmean=FALSE)$mfxest
your_table <- stargazer(ols, probit, coef = list(NULL, probit_margins[,1]),
se = list(NULL, probit_margins[,2]))
It works the same with logit, and you don't necessarily want the atmean=FALSE
option. I included an OLS in the example to show you how to include other specifications that stargazer
can handle, without the need to specify it the coefficients and standard errors.
Upvotes: 2