Last active
September 30, 2019 22:12
-
-
Save edwinhu/56ef1dbd180733b4c16448ec3f406106 to your computer and use it in GitHub Desktop.
extract functions for bife and feglm
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extract.bife <- function(model) { | |
s <- summary(model) | |
names <- rownames(s$coefmat_beta) | |
co <- s$coef[, 1] | |
se <- s$coef[, 2] | |
tstat <- s$coef[, 3] | |
pval <- s$coef[, 4] | |
aic <- s$AIC | |
bic <- s$BIC | |
n <- s$nobs | |
gof <- c(n, aic, bic) | |
gof.names <- c("Num.\\ obs.", "AIC", "BIC") | |
gof.decimal <- c(F,T,T) | |
tr <- createTexreg( | |
coef.names = names, | |
coef = co, | |
se = se, | |
pvalues = pval, | |
gof.names = gof.names, | |
gof = gof, | |
gof.decimal = gof.decimal | |
) | |
return(tr) | |
} | |
extract.feglm <- function(model) { | |
s <- summary(model, type="clustered", cluster.vars=names(model$lvls.k)) | |
names <- rownames(s$cm) | |
co <- s$cm[, 1] | |
se <- s$cm[, 2] | |
tstat <- s$cm[, 3] | |
pval <- s$cm[, 4] | |
dev <- s$deviance | |
n <- s$nobs[['nobs']]+s$nobs[['nobs.pc']] | |
gof <- c(n, dev) | |
gof.names <- c("Obs.", "Deviance") | |
gof.decimal <- c(F,T) | |
tr <- createTexreg( | |
coef.names = names, | |
coef = co, | |
se = se, | |
pvalues = pval, | |
gof.names = gof.names, | |
gof = gof, | |
gof.decimal = gof.decimal | |
) | |
return(tr) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment