niceglm: Lisa's GLM Regression Table Reporting Function

Description Usage Arguments

View source: R/niceglm.R

Description

This function creates a nice looking table of regression results for a glm model. Input either a glm object or dataframe, outcome variable, vector of covariates, model family, and type of analysis (univariate or multiple regression). The function returns a dataframe of formatted regression results and prints the results table using kable or htmlTable.

Usage

1
2
3
4
5
niceglm(fit = NA, df = NA, family = NA, covs = NA, out = NA,
  regtype = "multi", exp = NA, estname = NA, intercept = FALSE,
  refcat = FALSE, labels = NA, overallp = FALSE, est.dec = 2,
  ci.dec = 2, pval.dec = 3, color = "#EEEEEE", kable = TRUE,
  htmlTable = FALSE, title = "", footer = TRUE)

Arguments

fit

GLM model object [fit or family/covs/out are REQUIRED].

df

Dataframe [fit or df/family/covs/out].

family

Character. Model family name in quotes ("guassian", "binomial", "poisson") [fit or df/family/covs/out are REQUIRED].

covs

Character. Vector of covariates to include in model [fit or df/family/covs/out are REQUIRED].

out

Character. Outcome for regression model [fit or df/family/covs/out are REQUIRED].

regtype

Logical. Should the covariates be run separately ("uni") or together in a multiple regression model ("multi") [REQUIRED if no fit].

exp

Logical. Option to exponentiate coefficients and CI's. Default is NA (estimates exponentiated for binomial and poisson models by default).

estname

Character. Label for regression estimate. Default is NA (program will choose a reasonable name depending on model type).

intercept

Logical. If TRUE the intercept will be included in the table (muliple regression only). Default is FALSE.

refcat

Logical. If TRUE the table will create a separate line for the reference category. Default is FALSE.

labels

Character. Vector of labels for covariates. Default is NA (use variable names).

overallp

Logical. If TRUE, a likelihood ratio test pvalue will be calculated for each variable (via drop1, Chisq test). Default is FALSE.

est.dec

Numeric. Number of decimal places for estimates. Default is 2.

ci.dec

Numeric. Number of decimal places for 95 percent confidence interval. Default is 2.

pval.dec

Numeric. Number of decimal places for pvalues. Must be an integer from 1 to 4. Default is 3.

color

Character. Color to use for htmlTable striping. Default is "#EEEEEE" (light grey). Use "white" for no striping.

kable

Logical. If TRUE, table will be formatted using the kable packge. Default is TRUE.

htmlTable

Logical. If TRUE, the table will be printed using htmlTable. Default is FALSE.

title

Character. Optional title above table. Default is "".

footer

Logical. If TRUE, table will include a footnote with model details, nobs, R2. Default is TRUE.


lisaerein/nicereg documentation built on July 4, 2020, 9:04 p.m.