niceglmer: Lisa's GLMER Regression Table Reporting Function

Description Usage Arguments

View source: R/niceglmer.R

Description

This function creates a nice looking table of regression results for a lmer or glmer (lme4 package) model. Input either a lmer/glmer object or dataframe, outcome variable, vector of covariates, random effects statement, 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
niceglmer(fit = NA, df = NA, family = NA, covs = NA, out = NA,
  random = NA, optimizer = "bobyqa", regtype = "multi", exp = NA,
  estname = NA, intercept = FALSE, refcat = FALSE, labels = NA,
  est.dec = 2, ci.dec = 2, pval.dec = 3, color = "#EEEEEE",
  kable = TRUE, htmlTable = FALSE, title = "", footer = TRUE)

Arguments

fit

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

df

Dataframe [fit or family/covs/out/random REQUIRED].

family

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

covs

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

out

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

random

Character. Random effects statement to add to formula, ex. "(1|study_id)" for random intercept by study_id. [fit or family/covs/out/random are REQUIRED].

optimizer

Character. Option to pass to glmerControl. Default is "bobyqa".

regtype

Logical. Should the covariates be run separately ("uni") or together in a multiple regression model ("multi") [fit or family/covs/out/id/corstr are REQUIRED].

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. Covariate labels in same order as covs. Default is NA (variable names are used).

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.