leeper / margins

An R Port of Stata's 'margins' Command
https://cloud.r-project.org/package=margins
Other
263 stars 40 forks source link

Regression output for polr() together with margins() #174

Open LuiNov opened 3 years ago

LuiNov commented 3 years ago

I am doing proportional odds function in R by M <- polr(Y ~ X1 + X2 ……). As I wan't to show the marginal effects I used margins (m) or ocME(m) after that.

MY PROBLEM:

I can't export the regression output together with the marginal effects in a "nice way".

WHAT I TRIED:

stargazer(M, summary(margins(m)), type = 'text', summary = FALSE) => SO I only got the output with a table of the margins output.

stargazer(M, coeff = list(c(NA, summary(margins(m)))))………

also with ocME(m)$out it didn't work

SO I TRIED OTHER PACKAGES:

export_summs, huxtable, modelsummary() etc. WORKED…… BUT PROBLEM the regression outputs coefficients are without labels while margins output is with labels (gender_L vs. gender_female). => SO: I got like two pages of table that isn't really readable .....

Does someone has a clue what I am doing wrong and what could help?

FOR CLEARANCE MY CODE (all variables are ordered factors with levels from 0 to the max fe. TM_4F = factor(TM_4, levels = c(0:3), labels = c('Immer', '1', '2', 'Nie'), ordered = T)

MODEL:

CSimple2 <- polr(TM_4F ~ Country + Sex_F + Age + Marital_F + NoChild + Edu_F + SEmp + AttRelServ_F, method = 'probit', weights = Mult_dpWeight1000, Hess = T)

margins(CSimple2) I am really bothered bc. I am stuck with this "simple problem". Thanks for your help in advance I am happy about everything :-) Bildschirmfoto 2021-07-23 um 08 35 42