Skip to content

Instantly share code, notes, and snippets.

@edwinhu
Last active September 30, 2019 22:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save edwinhu/56ef1dbd180733b4c16448ec3f406106 to your computer and use it in GitHub Desktop.
Save edwinhu/56ef1dbd180733b4c16448ec3f406106 to your computer and use it in GitHub Desktop.
extract functions for bife and feglm
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