glmText: Generates strings of text for the use in markdown documents

Description Usage Arguments Value Examples

View source: R/glmText.R

Description

This function takes as input one object containing a test result and returns its most important informations. Function glmText takes the result of a generalized linear model (returned from a call to the glm function), returning either its global statistics – pseudo-R², F-value or chi-squared statistics with corresponding P-value – or statistics for specific coefficients. In addition, it offers options to customize the output, like replacing names of some parameters, changing separators and decimal markers (helpful in case you are producing a manuscript in German or Portuguese), and choosing the number of digits to round numbers to.

Usage

1
2
glmText(x, type = "global", test = FALSE, contrast = "~ 1",
  which.coef = NULL, sep = "; ", dec = ".", digits = c(3, 3, 3))

Arguments

x

Name of the object containing the result of the analysis from which stats should be extracted.

type

Either "global" for global model statistics or "coefs", for specific variable betas and their significance. The default is "global".

test

Whether the model provided should be constrasted to another possibly simpler alternative. Can be logic or may directly provide the test name for one option available in anova.glm.

contrast

If test is required, the model provided is constrasted to a possibly simpler alternative. The default is the intercept-only model (contrast="~ 1"). Setting different models will change the output of delta-AIC and the deviance statistics.

which.coef

Vector indexing which of the potential many variables should be accessed when type = "coefs".

sep

How to separate pieces of information displayed. Defaults to a semicolon followed by a space (sep = "; ").

dec

Which decimal separator should be used? Defaults to ".". Allows to quickly changing to a comma in case you are producing a manuscript in German or Portuguese.

digits

How many digits should be kept for each piece of numeric information? Defaults to c(3, 3, 3). Importantly, when a P-value rounded to the number of digits hereby defined results in zero, the result is replaced by a more theoretically meaningful alternative (e.g. P < 0.001).

adj.r.squared

Logic value indicating whether an automatic shift to adjusted R² should be allowed for multivariate models. Default is TRUE.

Value

A string of text to be included in a markdown object.

Examples

1
2
3
4
5
6
## loading the anorexia dataset
utils::data(anorexia, package = "MASS")
anorex.1 <- glm(Postwt ~ Prewt, data = anorexia, family=Gamma(link="log"))
glmText(anorex.1, type="global")
glmText(anorex.1, type="global", contrast="~ Prewt", test=TRUE)
glmText(anorex.1, type="coefs", which.coef="Prewt")

eduardohet/resulteR documentation built on Dec. 14, 2017, 4:13 p.m.