Title: | Automated Reporting of Results and Statistical Models |
---|---|
Description: | The aim of the 'report' package is to bridge the gap between R’s output and the formatted results contained in your manuscript. This package converts statistical models and data frames into textual reports suited for publication, ensuring standardization and quality in results reporting. |
Authors: | Dominique Makowski [aut] (<https://orcid.org/0000-0001-5375-9967>, @Dom_Makowski), Daniel Lüdecke [aut] (<https://orcid.org/0000-0002-8895-3206>, @strengejacke), Indrajeet Patil [aut] (<https://orcid.org/0000-0003-1995-6531>, @patilindrajeets), Rémi Thériault [aut, cre] (<https://orcid.org/0000-0003-4315-6788>, @rempsyc), Mattan S. Ben-Shachar [aut] (<https://orcid.org/0000-0002-4287-4801>, @mattansb), Brenton M. Wiernik [aut] (<https://orcid.org/0000-0001-9560-6336>, @bmwiernik), Rudolf Siegel [ctb] , Camden Bock [ctb] |
Maintainer: | Rémi Thériault <[email protected]> |
License: | MIT + file LICENSE |
Version: | 0.5.9 |
Built: | 2024-11-03 09:20:59 UTC |
Source: | https://github.com/easystats/report |
Allows to create or test whether an object is of the report
class.
as.report_text(x, ...) as.report(text, table = NULL, plot = NULL, ...) is.report(x) as.report_effectsize(x, summary = NULL, prefix = " - ", ...) as.report_info(x, summary = NULL, ...) as.report_intercept(x, summary = NULL, ...) as.report_model(x, summary = NULL, ...) as.report_parameters(x, summary = NULL, prefix = " - ", ...) as.report_performance(x, summary = NULL, ...) as.report_priors(x, summary = NULL, ...) as.report_random(x, summary = NULL, ...) as.report_statistics(x, summary = NULL, prefix = " - ", ...) as.report_table(x, ...)
as.report_text(x, ...) as.report(text, table = NULL, plot = NULL, ...) is.report(x) as.report_effectsize(x, summary = NULL, prefix = " - ", ...) as.report_info(x, summary = NULL, ...) as.report_intercept(x, summary = NULL, ...) as.report_model(x, summary = NULL, ...) as.report_parameters(x, summary = NULL, prefix = " - ", ...) as.report_performance(x, summary = NULL, ...) as.report_priors(x, summary = NULL, ...) as.report_random(x, summary = NULL, ...) as.report_statistics(x, summary = NULL, prefix = " - ", ...) as.report_table(x, ...)
x |
An arbitrary R object. |
... |
Args to be saved as attributes. |
text |
Text obtained via |
table |
Table obtained via |
plot |
Plot obtained via |
summary |
Add a summary as attribute (to be extracted via |
prefix |
The prefix to be displayed in front of each parameter. |
A report object or a TRUE/FALSE
value.
A convenient function for those who wish to cite the easystats packages.
cite_easystats( packages = "easystats", format = c("text", "markdown", "biblatex"), intext_prefix = TRUE, intext_suffix = "." ) ## S3 method for class 'cite_easystats' summary(object, what = "all", ...) ## S3 method for class 'cite_easystats' print(x, what = "all", ...)
cite_easystats( packages = "easystats", format = c("text", "markdown", "biblatex"), intext_prefix = TRUE, intext_suffix = "." ) ## S3 method for class 'cite_easystats' summary(object, what = "all", ...) ## S3 method for class 'cite_easystats' print(x, what = "all", ...)
packages |
A character vector of packages to cite. Can be |
format |
The format to generate citations. Can be |
intext_prefix |
A character vector of length 1 containing text to include
before in-text citations. If |
intext_suffix |
A character vector of length 1 containing text to include
after in-text citations. Defaults to |
what |
What elements of the citations to print, can be |
... |
Not used. Included for compatibility with the generic function. |
x , object
|
A |
A list of class "cite_easystats"
with elements:
intext
: In-text citations in the requested format
refs
: References or bibliography in the requested format
# Cite just the 'easystats' umbrella package: cite_easystats() summary(cite_easystats(), what = "all") # Cite every easystats package: cite_easystats(packages = "all") summary(cite_easystats(packages = "all"), what = "all") # Cite specific packages: cite_easystats(packages = c("modelbased", "see")) summary(cite_easystats(packages = c("modelbased", "see")), what = "all") # To cite easystats packages in an RMarkdown document, use: ## In-text citations: print(cite_easystats(format = "markdown"), what = "intext") ## Bibliography (print with the `output = 'asis'` option on the code chunk) print(cite_easystats(format = "markdown"), what = "refs")
# Cite just the 'easystats' umbrella package: cite_easystats() summary(cite_easystats(), what = "all") # Cite every easystats package: cite_easystats(packages = "all") summary(cite_easystats(packages = "all"), what = "all") # Cite specific packages: cite_easystats(packages = c("modelbased", "see")) summary(cite_easystats(packages = c("modelbased", "see")), what = "all") # To cite easystats packages in an RMarkdown document, use: ## In-text citations: print(cite_easystats(format = "markdown"), what = "intext") ## Bibliography (print with the `output = 'asis'` option on the code chunk) print(cite_easystats(format = "markdown"), what = "refs")
Convenient formatting of text components
format_algorithm(x) format_formula(x, what = "conditional") format_model(x)
format_algorithm(x) format_formula(x, what = "conditional") format_model(x)
x |
The R object that you want to report (see list of of supported objects above). |
what |
The name of the item returned by |
A character string.
A character string.
A character string.
model <- lm(Sepal.Length ~ Species, data = iris) format_algorithm(model) # Mixed models library(lme4) model <- lme4::lmer(Sepal.Length ~ Sepal.Width + (1 | Species), data = iris) format_algorithm(model) model <- lm(Sepal.Length ~ Species, data = iris) format_formula(model) # Mixed models library(lme4) model <- lme4::lmer(Sepal.Length ~ Sepal.Width + (1 | Species), data = iris) format_formula(model) format_formula(model, "random") model <- lm(Sepal.Length ~ Species, data = iris) format_model(model) # Mixed models library(lme4) model <- lme4::lmer(Sepal.Length ~ Sepal.Width + (1 | Species), data = iris) format_model(model)
model <- lm(Sepal.Length ~ Species, data = iris) format_algorithm(model) # Mixed models library(lme4) model <- lme4::lmer(Sepal.Length ~ Sepal.Width + (1 | Species), data = iris) format_algorithm(model) model <- lm(Sepal.Length ~ Species, data = iris) format_formula(model) # Mixed models library(lme4) model <- lme4::lmer(Sepal.Length ~ Sepal.Width + (1 | Species), data = iris) format_formula(model) format_formula(model, "random") model <- lm(Sepal.Length ~ Species, data = iris) format_model(model) # Mixed models library(lme4) model <- lme4::lmer(Sepal.Length ~ Sepal.Width + (1 | Species), data = iris) format_model(model)
Convenience functions to manipulate and format citations. Only works with APA formatted citations, for now.
format_citation(citation, authorsdate = FALSE, short = FALSE, intext = FALSE) cite_citation(citation) clean_citation(citation)
format_citation(citation, authorsdate = FALSE, short = FALSE, intext = FALSE) cite_citation(citation) clean_citation(citation)
citation |
A character string of a citation. |
authorsdate |
Only show authors and date (remove title, journal, etc.). |
short |
If more than one authors, replace by |
intext |
Remove brackets around the date (so that it can be placed inside larger parentheses). |
A character string.
library(report) citation <- "Makowski, D., Ben-Shachar, M. S., Patil, I., & Ludecke, D. (2020). Methods and Algorithms for Correlation Analysis in R. Journal of Open Source Software, 5(51), 2306." format_citation(citation, authorsdate = TRUE) format_citation(citation, authorsdate = TRUE, short = TRUE) format_citation(citation, authorsdate = TRUE, short = TRUE, intext = TRUE) cite_citation(citation) clean_citation(citation())
library(report) citation <- "Makowski, D., Ben-Shachar, M. S., Patil, I., & Ludecke, D. (2020). Methods and Algorithms for Correlation Analysis in R. Journal of Open Source Software, 5(51), 2306." format_citation(citation, authorsdate = TRUE) format_citation(citation, authorsdate = TRUE, short = TRUE) format_citation(citation, authorsdate = TRUE, short = TRUE, intext = TRUE) cite_citation(citation) clean_citation(citation())
Create reports of different objects. See the documentation for your object's class:
report(x, ...)
report(x, ...)
x |
The R object that you want to report (see list of of supported objects above). |
... |
Arguments passed to or from other methods. |
System and packages (sessionInfo
)
Correlations and t-tests (htest
)
ANOVAs (aov, anova, aovlist, ...
)
Regression models (glm, lm, ...
)
Mixed models (glmer, lmer, glmmTMB, ...
)
Bayesian models (stanreg, brms...
)
Bayes factors (from bayestestR
)
Structural Equation Models (SEM) (from lavaan
)
Model comparison (from performance()
)
Most of the time, the object created by the report()
function can be
further transformed, for instance summarized (using summary()
), or
converted to a table (using as.data.frame()
).
report_table
and report_text
are the two distal representations
of a report, and are the two provided in report()
. However,
intermediate steps are accessible (depending on the object) via specific
functions (e.g., report_parameters
).
The report()
function generates a report-object that contain in itself
different representations (e.g., text, tables, plots). These different
representations can be accessed via several functions, such as:
as.report_text(r)
: Detailed text.
as.report_text(r, summary=TRUE)
: Minimal text giving
the minimal information.
as.report_table(r)
: Comprehensive table including most
available indices.
as.report_table(r, summary=TRUE)
: Minimal table.
Note that for some report objects, some of these representations might be identical.
A list-object of class report
, which contains further
list-objects with a short and long description of the model summary, as
well as a short and long table of parameters and fit indices.
Specific components of reports (especially for stats models):
Other types of reports:
Methods:
Template file for supporting new models:
library(report) model <- t.test(mtcars$mpg ~ mtcars$am) r <- report(model) # Text r summary(r) # Tables as.data.frame(r) summary(as.data.frame(r))
library(report) model <- t.test(mtcars$mpg ~ mtcars$am) r <- report(model) # Text r summary(r) # Tables as.data.frame(r) summary(as.data.frame(r))
Other convenient or totally useless reports.
report_date(...) report_story(...)
report_date(...) report_story(...)
... |
Arguments passed to or from other methods. |
Objects of class report_text()
.
Specific components of reports (especially for stats models):
Other types of reports:
Methods:
Template file for supporting new models:
library(report) report_date() summary(report_date()) report_story()
library(report) report_date() summary(report_date()) report_story()
Computes, interpret and formats the effect sizes of a variety of models and
statistical tests (see list of supported objects in report()
).
report_effectsize(x, ...)
report_effectsize(x, ...)
x |
The R object that you want to report (see list of of supported objects above). |
... |
Arguments passed to or from other methods. |
An object of class report_effectsize()
.
library(report) # h-tests report_effectsize(t.test(iris$Sepal.Width, iris$Sepal.Length)) # ANOVAs report_effectsize(aov(Sepal.Length ~ Species, data = iris)) # GLMs report_effectsize(lm(Sepal.Length ~ Petal.Length * Species, data = iris)) report_effectsize(glm(vs ~ disp, data = mtcars, family = "binomial")) # Mixed models library(lme4) model <- lme4::lmer(Sepal.Length ~ Petal.Length + (1 | Species), data = iris) report_effectsize(model) # Bayesian models library(rstanarm) model <- suppressWarnings(stan_glm(Sepal.Length ~ Species, data = iris, refresh = 0, iter = 600)) report_effectsize(model, effectsize_method = "basic")
library(report) # h-tests report_effectsize(t.test(iris$Sepal.Width, iris$Sepal.Length)) # ANOVAs report_effectsize(aov(Sepal.Length ~ Species, data = iris)) # GLMs report_effectsize(lm(Sepal.Length ~ Petal.Length * Species, data = iris)) report_effectsize(glm(vs ~ disp, data = mtcars, family = "binomial")) # Mixed models library(lme4) model <- lme4::lmer(Sepal.Length ~ Petal.Length + (1 | Species), data = iris) report_effectsize(model) # Bayesian models library(rstanarm) model <- suppressWarnings(stan_glm(Sepal.Length ~ Species, data = iris, refresh = 0, iter = 600)) report_effectsize(model, effectsize_method = "basic")
Reports additional information relevant to the report (see list of supported
objects in report()
).
report_info(x, ...)
report_info(x, ...)
x |
The R object that you want to report (see list of of supported objects above). |
... |
Arguments passed to or from other methods. |
An object of class report_info()
.
library(report) # h-tests report_info(t.test(iris$Sepal.Width, iris$Sepal.Length)) # ANOVAs report_info(aov(Sepal.Length ~ Species, data = iris)) # GLMs report_info(lm(Sepal.Length ~ Petal.Length * Species, data = iris)) report_info(lm(Sepal.Length ~ Petal.Length * Species, data = iris), include_effectsize = TRUE) report_info(glm(vs ~ disp, data = mtcars, family = "binomial")) # Mixed models library(lme4) model <- lme4::lmer(Sepal.Length ~ Petal.Length + (1 | Species), data = iris) report_info(model) # Bayesian models library(rstanarm) model <- suppressWarnings(stan_glm(Sepal.Length ~ Species, data = iris, refresh = 0, iter = 300)) report_info(model)
library(report) # h-tests report_info(t.test(iris$Sepal.Width, iris$Sepal.Length)) # ANOVAs report_info(aov(Sepal.Length ~ Species, data = iris)) # GLMs report_info(lm(Sepal.Length ~ Petal.Length * Species, data = iris)) report_info(lm(Sepal.Length ~ Petal.Length * Species, data = iris), include_effectsize = TRUE) report_info(glm(vs ~ disp, data = mtcars, family = "binomial")) # Mixed models library(lme4) model <- lme4::lmer(Sepal.Length ~ Petal.Length + (1 | Species), data = iris) report_info(model) # Bayesian models library(rstanarm) model <- suppressWarnings(stan_glm(Sepal.Length ~ Species, data = iris, refresh = 0, iter = 300)) report_info(model)
Reports intercept of regression models (see list of supported objects in
report()
).
report_intercept(x, ...)
report_intercept(x, ...)
x |
The R object that you want to report (see list of of supported objects above). |
... |
Arguments passed to or from other methods. |
An object of class report_intercept()
.
library(report) # GLMs report_intercept(lm(Sepal.Length ~ Species, data = iris)) report_intercept(glm(vs ~ disp, data = mtcars, family = "binomial")) # Mixed models library(lme4) model <- lme4::lmer(Sepal.Length ~ Petal.Length + (1 | Species), data = iris) report_intercept(model) # Bayesian models library(rstanarm) model <- suppressWarnings(stan_glm(Sepal.Length ~ Species, data = iris, refresh = 0, iter = 600)) report_intercept(model)
library(report) # GLMs report_intercept(lm(Sepal.Length ~ Species, data = iris)) report_intercept(glm(vs ~ disp, data = mtcars, family = "binomial")) # Mixed models library(lme4) model <- lme4::lmer(Sepal.Length ~ Petal.Length + (1 | Species), data = iris) report_intercept(model) # Bayesian models library(rstanarm) model <- suppressWarnings(stan_glm(Sepal.Length ~ Species, data = iris, refresh = 0, iter = 600)) report_intercept(model)
Reports the type of different R objects (see list of supported objects in
report()
).
report_model(x, table = NULL, ...)
report_model(x, table = NULL, ...)
x |
The R object that you want to report (see list of of supported objects above). |
table |
A table obtained via |
... |
Arguments passed to or from other methods. |
A character
string.
library(report) # h-tests report_model(t.test(iris$Sepal.Width, iris$Sepal.Length)) # ANOVA report_model(aov(Sepal.Length ~ Species, data = iris)) # GLMs report_model(lm(Sepal.Length ~ Petal.Length * Species, data = iris)) report_model(glm(vs ~ disp, data = mtcars, family = "binomial")) # Mixed models library(lme4) model <- lme4::lmer(Sepal.Length ~ Petal.Length + (1 | Species), data = iris) report_model(model) # Bayesian models library(rstanarm) model <- suppressWarnings(stan_glm(Sepal.Length ~ Species, data = iris, refresh = 0, iter = 600)) report_model(model)
library(report) # h-tests report_model(t.test(iris$Sepal.Width, iris$Sepal.Length)) # ANOVA report_model(aov(Sepal.Length ~ Species, data = iris)) # GLMs report_model(lm(Sepal.Length ~ Petal.Length * Species, data = iris)) report_model(glm(vs ~ disp, data = mtcars, family = "binomial")) # Mixed models library(lme4) model <- lme4::lmer(Sepal.Length ~ Petal.Length + (1 | Species), data = iris) report_model(model) # Bayesian models library(rstanarm) model <- suppressWarnings(stan_glm(Sepal.Length ~ Species, data = iris, refresh = 0, iter = 600)) report_model(model)
Creates a list containing a description of the parameters of R objects (see
list of supported objects in report()
).
report_parameters(x, ...)
report_parameters(x, ...)
x |
The R object that you want to report (see list of of supported objects above). |
... |
Arguments passed to or from other methods. |
A vector
.
library(report) # Miscellaneous r <- report_parameters(sessionInfo()) r summary(r) # Data report_parameters(iris$Sepal.Length) report_parameters(as.character(round(iris$Sepal.Length, 1))) report_parameters(iris$Species) report_parameters(iris) # h-tests report_parameters(t.test(iris$Sepal.Width, iris$Sepal.Length)) # ANOVA report_parameters(aov(Sepal.Length ~ Species, data = iris)) # GLMs report_parameters(lm(Sepal.Length ~ Petal.Length * Species, data = iris)) report_parameters(lm(Petal.Width ~ Species, data = iris), include_intercept = FALSE) report_parameters(glm(vs ~ disp, data = mtcars, family = "binomial")) # Mixed models library(lme4) model <- lme4::lmer(Sepal.Length ~ Petal.Length + (1 | Species), data = iris) report_parameters(model) # Bayesian models library(rstanarm) model <- suppressWarnings(stan_glm(Sepal.Length ~ Species, data = iris, refresh = 0, iter = 600)) report_parameters(model)
library(report) # Miscellaneous r <- report_parameters(sessionInfo()) r summary(r) # Data report_parameters(iris$Sepal.Length) report_parameters(as.character(round(iris$Sepal.Length, 1))) report_parameters(iris$Species) report_parameters(iris) # h-tests report_parameters(t.test(iris$Sepal.Width, iris$Sepal.Length)) # ANOVA report_parameters(aov(Sepal.Length ~ Species, data = iris)) # GLMs report_parameters(lm(Sepal.Length ~ Petal.Length * Species, data = iris)) report_parameters(lm(Petal.Width ~ Species, data = iris), include_intercept = FALSE) report_parameters(glm(vs ~ disp, data = mtcars, family = "binomial")) # Mixed models library(lme4) model <- lme4::lmer(Sepal.Length ~ Petal.Length + (1 | Species), data = iris) report_parameters(model) # Bayesian models library(rstanarm) model <- suppressWarnings(stan_glm(Sepal.Length ~ Species, data = iris, refresh = 0, iter = 600)) report_parameters(model)
A helper function to help you format the participants data (age, sex, ...) in the participants section.
report_participants( data, age = NULL, sex = NULL, gender = NULL, education = NULL, country = NULL, race = NULL, participants = NULL, by = NULL, spell_n = FALSE, digits = 1, threshold = 10, group = NULL, ... )
report_participants( data, age = NULL, sex = NULL, gender = NULL, education = NULL, country = NULL, race = NULL, participants = NULL, by = NULL, spell_n = FALSE, digits = 1, threshold = 10, group = NULL, ... )
data |
A data frame. |
age |
The name of the column containing the age of the participant. |
sex |
The name of the column containing the sex of the participant. The
classes should be one of |
gender |
The name of the column containing the gender of the
classes should be one of |
education |
The name of the column containing education information. |
country |
The name of the column containing country information. |
race |
The name of the column containing race/ethnicity information. |
participants |
The name of the participants' identifier column (for instance in the case of repeated measures). |
by |
A character vector indicating the name(s) of the column(s) used for stratified description. |
spell_n |
Logical, fully spell the sample size ( |
digits |
Number of significant digits. |
threshold |
Percentage after which to combine, e.g., countries (default is 10%, so countries that represent less than 10% will be combined in the "other" category). |
group |
Deprecated. Use |
... |
Arguments passed to or from other methods. |
A character vector with description of the "participants", based on
the information provided in data
.
library(report) data <- data.frame( "Age" = c(22, 23, 54, 21, 8, 42), "Sex" = c("Intersex", "F", "M", "M", "NA", NA), "Gender" = c("N", "W", "W", "M", "NA", NA) ) report_participants(data, age = "Age", sex = "Sex") # Years of education (relative to high school graduation) data$Education <- c(0, 8, -3, -5, 3, 5) report_participants(data, age = "Age", sex = "Sex", gender = "Gender", education = "Education" ) # Education as factor data$Education2 <- c( "Bachelor", "PhD", "Highschool", "Highschool", "Bachelor", "Bachelor" ) report_participants(data, age = "Age", sex = "Sex", gender = "Gender", education = "Education2") # Country data <- data.frame( "Age" = c(22, 23, 54, 21, 8, 42, 18, 32, 24, 27, 45), "Sex" = c("Intersex", "F", "F", "M", "M", "M", "F", "F", "F", "F", "F"), "Gender" = c("N", "W", "W", "M", "M", "M", "W", "W", "W", "W", "W"), "Country" = c( "USA", NA, "Canada", "Canada", "India", "Germany", "USA", "USA", "USA", "USA", "Canada" ) ) report_participants(data) # Country, control presentation treshold report_participants(data, threshold = 5) # Race/ethnicity data <- data.frame( "Age" = c(22, 23, 54, 21, 8, 42, 18, 32, 24, 27, 45), "Sex" = c("Intersex", "F", "F", "M", "M", "M", "F", "F", "F", "F", "F"), "Gender" = c("N", "W", "W", "M", "M", "M", "W", "W", "W", "W", "W"), "Race" = c( "Black", NA, "White", "Asian", "Black", "Arab", "Black", "White", "Asian", "Southeast Asian", "Mixed" ) ) report_participants(data) # Race/ethnicity, control presentation treshold report_participants(data, threshold = 5) # Repeated measures data data <- data.frame( "Age" = c(22, 22, 54, 54, 8, 8), "Sex" = c("I", "F", "M", "M", "F", "F"), "Gender" = c("N", "W", "W", "M", "M", "M"), "Participant" = c("S1", "S1", "s2", "s2", "s3", "s3") ) report_participants(data, age = "Age", sex = "Sex", gender = "Gender", participants = "Participant") # Grouped data data <- data.frame( "Age" = c(22, 22, 54, 54, 8, 8, 42, 42), "Sex" = c("I", "I", "M", "M", "F", "F", "F", "F"), "Gender" = c("N", "N", "W", "M", "M", "M", "Non-Binary", "Non-Binary"), "Participant" = c("S1", "S1", "s2", "s2", "s3", "s3", "s4", "s4"), "Condition" = c("A", "A", "A", "A", "B", "B", "B", "B") ) report_participants(data, age = "Age", sex = "Sex", gender = "Gender", participants = "Participant", by = "Condition" ) # Spell sample size paste( report_participants(data, participants = "Participant", spell_n = TRUE), "were recruited in the study by means of torture and coercion." )
library(report) data <- data.frame( "Age" = c(22, 23, 54, 21, 8, 42), "Sex" = c("Intersex", "F", "M", "M", "NA", NA), "Gender" = c("N", "W", "W", "M", "NA", NA) ) report_participants(data, age = "Age", sex = "Sex") # Years of education (relative to high school graduation) data$Education <- c(0, 8, -3, -5, 3, 5) report_participants(data, age = "Age", sex = "Sex", gender = "Gender", education = "Education" ) # Education as factor data$Education2 <- c( "Bachelor", "PhD", "Highschool", "Highschool", "Bachelor", "Bachelor" ) report_participants(data, age = "Age", sex = "Sex", gender = "Gender", education = "Education2") # Country data <- data.frame( "Age" = c(22, 23, 54, 21, 8, 42, 18, 32, 24, 27, 45), "Sex" = c("Intersex", "F", "F", "M", "M", "M", "F", "F", "F", "F", "F"), "Gender" = c("N", "W", "W", "M", "M", "M", "W", "W", "W", "W", "W"), "Country" = c( "USA", NA, "Canada", "Canada", "India", "Germany", "USA", "USA", "USA", "USA", "Canada" ) ) report_participants(data) # Country, control presentation treshold report_participants(data, threshold = 5) # Race/ethnicity data <- data.frame( "Age" = c(22, 23, 54, 21, 8, 42, 18, 32, 24, 27, 45), "Sex" = c("Intersex", "F", "F", "M", "M", "M", "F", "F", "F", "F", "F"), "Gender" = c("N", "W", "W", "M", "M", "M", "W", "W", "W", "W", "W"), "Race" = c( "Black", NA, "White", "Asian", "Black", "Arab", "Black", "White", "Asian", "Southeast Asian", "Mixed" ) ) report_participants(data) # Race/ethnicity, control presentation treshold report_participants(data, threshold = 5) # Repeated measures data data <- data.frame( "Age" = c(22, 22, 54, 54, 8, 8), "Sex" = c("I", "F", "M", "M", "F", "F"), "Gender" = c("N", "W", "W", "M", "M", "M"), "Participant" = c("S1", "S1", "s2", "s2", "s3", "s3") ) report_participants(data, age = "Age", sex = "Sex", gender = "Gender", participants = "Participant") # Grouped data data <- data.frame( "Age" = c(22, 22, 54, 54, 8, 8, 42, 42), "Sex" = c("I", "I", "M", "M", "F", "F", "F", "F"), "Gender" = c("N", "N", "W", "M", "M", "M", "Non-Binary", "Non-Binary"), "Participant" = c("S1", "S1", "s2", "s2", "s3", "s3", "s4", "s4"), "Condition" = c("A", "A", "A", "A", "B", "B", "B", "B") ) report_participants(data, age = "Age", sex = "Sex", gender = "Gender", participants = "Participant", by = "Condition" ) # Spell sample size paste( report_participants(data, participants = "Participant", spell_n = TRUE), "were recruited in the study by means of torture and coercion." )
Investigating the fit of statistical models to data often involves selecting
the best fitting model amongst many competing models. This function helps
report indices of model fit for various models. Reports the type of
different R objects . For a list of supported objects, see
report()
).
report_performance(x, table = NULL, ...)
report_performance(x, table = NULL, ...)
x |
The R object that you want to report (see list of of supported objects above). |
table |
A table obtained via |
... |
Arguments passed to or from other methods. |
An object of class report_performance()
.
# GLMs report_performance(lm(Sepal.Length ~ Petal.Length * Species, data = iris)) report_performance(glm(vs ~ disp, data = mtcars, family = "binomial")) # Mixed models library(lme4) model <- lme4::lmer(Sepal.Length ~ Petal.Length + (1 | Species), data = iris) report_performance(model) # Bayesian models library(rstanarm) model <- suppressWarnings(stan_glm(Sepal.Length ~ Species, data = iris, refresh = 0, iter = 600)) report_performance(model) # Structural Equation Models (SEM) library(lavaan) structure <- "ind60 =~ x1 + x2 + x3 dem60 =~ y1 + y2 + y3 dem60 ~ ind60 " model <- lavaan::sem(structure, data = PoliticalDemocracy) suppressWarnings(report_performance(model))
# GLMs report_performance(lm(Sepal.Length ~ Petal.Length * Species, data = iris)) report_performance(glm(vs ~ disp, data = mtcars, family = "binomial")) # Mixed models library(lme4) model <- lme4::lmer(Sepal.Length ~ Petal.Length + (1 | Species), data = iris) report_performance(model) # Bayesian models library(rstanarm) model <- suppressWarnings(stan_glm(Sepal.Length ~ Species, data = iris, refresh = 0, iter = 600)) report_performance(model) # Structural Equation Models (SEM) library(lavaan) structure <- "ind60 =~ x1 + x2 + x3 dem60 =~ y1 + y2 + y3 dem60 ~ ind60 " model <- lavaan::sem(structure, data = PoliticalDemocracy) suppressWarnings(report_performance(model))
Reports priors of Bayesian models (see list of supported objects in
report()
).
report_priors(x, ...)
report_priors(x, ...)
x |
The R object that you want to report (see list of of supported objects above). |
... |
Arguments passed to or from other methods. |
An object of class report_priors()
.
# Bayesian models library(rstanarm) model <- stan_glm(mpg ~ disp, data = mtcars, refresh = 0, iter = 1000) r <- report_priors(model) r summary(r)
# Bayesian models library(rstanarm) model <- stan_glm(mpg ~ disp, data = mtcars, refresh = 0, iter = 1000) r <- report_priors(model) r summary(r)
Reports random effects of mixed models (see list of supported objects in
report()
).
report_random(x, ...)
report_random(x, ...)
x |
The R object that you want to report (see list of of supported objects above). |
... |
Arguments passed to or from other methods. |
An object of class report_random()
.
# Mixed models library(lme4) model <- lme4::lmer(Sepal.Length ~ Petal.Length + (1 | Species), data = iris) r <- report_random(model) r summary(r) # Bayesian models library(rstanarm) model <- suppressWarnings(stan_lmer( mpg ~ disp + (1 | cyl), data = mtcars, refresh = 0, iter = 1000 )) r <- report_random(model) r summary(r) library(brms) model <- suppressWarnings(brm(mpg ~ disp + (1 | cyl), data = mtcars, refresh = 0, iter = 1000)) r <- report_random(model) r summary(r)
# Mixed models library(lme4) model <- lme4::lmer(Sepal.Length ~ Petal.Length + (1 | Species), data = iris) r <- report_random(model) r summary(r) # Bayesian models library(rstanarm) model <- suppressWarnings(stan_lmer( mpg ~ disp + (1 | cyl), data = mtcars, refresh = 0, iter = 1000 )) r <- report_random(model) r summary(r) library(brms) model <- suppressWarnings(brm(mpg ~ disp + (1 | cyl), data = mtcars, refresh = 0, iter = 1000)) r <- report_random(model) r summary(r)
Reports interpretation of S- and p-values in easy language.
report_s(s = NULL, p = NULL, test_value = 0, test_parameter = "parameter")
report_s(s = NULL, p = NULL, test_value = 0, test_parameter = "parameter")
s |
An S-value. Either |
p |
A p-value. Either |
test_value |
The value of the test parameter under the null hypothesis. |
test_parameter |
The name of the test parameter under the null hypothesis. |
A string with the interpretation of the S- or p-value.
report_s(s = 1.5) report_s(p = 0.05)
report_s(s = 1.5) report_s(p = 0.05)
Create sample description table (also referred to as "Table 1").
report_sample( data, by = NULL, centrality = "mean", ci = NULL, ci_method = "wilson", ci_correct = FALSE, select = NULL, exclude = NULL, weights = NULL, total = TRUE, digits = 2, n = FALSE, group_by = NULL, ... )
report_sample( data, by = NULL, centrality = "mean", ci = NULL, ci_method = "wilson", ci_correct = FALSE, select = NULL, exclude = NULL, weights = NULL, total = TRUE, digits = 2, n = FALSE, group_by = NULL, ... )
data |
A data frame for which descriptive statistics should be created. |
by |
Character vector, indicating the column(s) for possible grouping
of the descriptive table. Note that weighting (see |
centrality |
Character, indicates the statistics that should be
calculated for numeric variables. May be |
ci |
Level of confidence interval for relative frequencies (proportions).
If not |
ci_method |
Character, indicating the method how to calculate confidence
intervals for proportions. Currently implemented methods are
|
ci_correct |
Logical, it |
select |
Character vector, with column names that should be included in the descriptive table. |
exclude |
Character vector, with column names that should be excluded from the descriptive table. |
weights |
Character vector, indicating the name of a potential
weight-variable. Reported descriptive statistics will be weighted by
|
total |
Add a |
digits |
Number of decimals. |
n |
Logical, actual sample size used in the calculation of the reported descriptive statistics (i.e., without the missing values). |
group_by |
Deprecated. Use |
... |
Arguments passed to or from other methods. |
A data frame of class report_sample
with variable names and
their related summary statistics.
Newcombe, R. G. (1998). Two-sided confidence intervals for the single proportion: comparison of seven methods. Statistics in Medicine. 17 (8): 857–872
Wilson, E. B. (1927). Probable inference, the law of succession, and statistical inference. Journal of the American Statistical Association. 22 (158): 209–212
library(report) report_sample(iris[, 1:4]) report_sample(iris, select = c("Sepal.Length", "Petal.Length", "Species")) report_sample(iris, by = "Species") report_sample(airquality, by = "Month", n = TRUE, total = FALSE) # confidence intervals for proportions set.seed(123) d <- data.frame(x = factor(sample(letters[1:3], 100, TRUE, c(0.01, 0.39, 0.6)))) report_sample(d, ci = 0.95, ci_method = "wald") # ups, negative CI report_sample(d, ci = 0.95, ci_method = "wilson") # negative CI fixed report_sample(d, ci = 0.95, ci_correct = TRUE) # continuity correction
library(report) report_sample(iris[, 1:4]) report_sample(iris, select = c("Sepal.Length", "Petal.Length", "Species")) report_sample(iris, by = "Species") report_sample(airquality, by = "Month", n = TRUE, total = FALSE) # confidence intervals for proportions set.seed(123) d <- data.frame(x = factor(sample(letters[1:3], 100, TRUE, c(0.01, 0.39, 0.6)))) report_sample(d, ci = 0.95, ci_method = "wald") # ups, negative CI report_sample(d, ci = 0.95, ci_method = "wilson") # negative CI fixed report_sample(d, ci = 0.95, ci_correct = TRUE) # continuity correction
Creates a list containing a description of the parameters' values of R
objects (see list of supported objects in report()
). Useful to
insert in parentheses in plots or reports.
report_statistics(x, table = NULL, ...)
report_statistics(x, table = NULL, ...)
x |
The R object that you want to report (see list of of supported objects above). |
table |
A table obtained via |
... |
Arguments passed to or from other methods. |
An object of class report_statistics()
.
library(report) # Data report_statistics(iris$Sepal.Length) report_statistics(as.character(round(iris$Sepal.Length, 1))) report_statistics(iris$Species) report_statistics(iris) # h-tests report_statistics(t.test(iris$Sepal.Width, iris$Sepal.Length)) # ANOVA report_statistics(aov(Sepal.Length ~ Species, data = iris)) # GLMs report_statistics(lm(Sepal.Length ~ Petal.Length * Species, data = iris)) report_statistics(glm(vs ~ disp, data = mtcars, family = "binomial")) # Mixed models library(lme4) model <- lme4::lmer(Sepal.Length ~ Petal.Length + (1 | Species), data = iris) report_statistics(model) # Bayesian models library(rstanarm) model <- suppressWarnings(stan_glm(Sepal.Length ~ Species, data = iris, refresh = 0, iter = 600)) report_statistics(model)
library(report) # Data report_statistics(iris$Sepal.Length) report_statistics(as.character(round(iris$Sepal.Length, 1))) report_statistics(iris$Species) report_statistics(iris) # h-tests report_statistics(t.test(iris$Sepal.Width, iris$Sepal.Length)) # ANOVA report_statistics(aov(Sepal.Length ~ Species, data = iris)) # GLMs report_statistics(lm(Sepal.Length ~ Petal.Length * Species, data = iris)) report_statistics(glm(vs ~ disp, data = mtcars, family = "binomial")) # Mixed models library(lme4) model <- lme4::lmer(Sepal.Length ~ Petal.Length + (1 | Species), data = iris) report_statistics(model) # Bayesian models library(rstanarm) model <- suppressWarnings(stan_glm(Sepal.Length ~ Species, data = iris, refresh = 0, iter = 600)) report_statistics(model)
Creates tables to describe different objects (see list of supported objects
in report()
).
report_table(x, ...)
report_table(x, ...)
x |
The R object that you want to report (see list of of supported objects above). |
... |
Arguments passed to or from other methods. |
An object of class report_table()
.
# Miscellaneous r <- report_table(sessionInfo()) r summary(r) # Data report_table(iris$Sepal.Length) report_table(as.character(round(iris$Sepal.Length, 1))) report_table(iris$Species) report_table(iris) # h-tests report_table(t.test(mtcars$mpg ~ mtcars$am)) # ANOVAs report_table(aov(Sepal.Length ~ Species, data = iris)) # GLMs report_table(lm(Sepal.Length ~ Petal.Length * Species, data = iris)) report_table(glm(vs ~ disp, data = mtcars, family = "binomial")) # Mixed models library(lme4) model <- lme4::lmer(Sepal.Length ~ Petal.Length + (1 | Species), data = iris) report_table(model) # Bayesian models library(rstanarm) model <- suppressWarnings(stan_glm(Sepal.Length ~ Species, data = iris, refresh = 0, iter = 600)) report_table(model, effectsize_method = "basic") # Structural Equation Models (SEM) library(lavaan) structure <- "ind60 =~ x1 + x2 + x3 dem60 =~ y1 + y2 + y3 dem60 ~ ind60" model <- lavaan::sem(structure, data = PoliticalDemocracy) suppressWarnings(report_table(model))
# Miscellaneous r <- report_table(sessionInfo()) r summary(r) # Data report_table(iris$Sepal.Length) report_table(as.character(round(iris$Sepal.Length, 1))) report_table(iris$Species) report_table(iris) # h-tests report_table(t.test(mtcars$mpg ~ mtcars$am)) # ANOVAs report_table(aov(Sepal.Length ~ Species, data = iris)) # GLMs report_table(lm(Sepal.Length ~ Petal.Length * Species, data = iris)) report_table(glm(vs ~ disp, data = mtcars, family = "binomial")) # Mixed models library(lme4) model <- lme4::lmer(Sepal.Length ~ Petal.Length + (1 | Species), data = iris) report_table(model) # Bayesian models library(rstanarm) model <- suppressWarnings(stan_glm(Sepal.Length ~ Species, data = iris, refresh = 0, iter = 600)) report_table(model, effectsize_method = "basic") # Structural Equation Models (SEM) library(lavaan) structure <- "ind60 =~ x1 + x2 + x3 dem60 =~ y1 + y2 + y3 dem60 ~ ind60" model <- lavaan::sem(structure, data = PoliticalDemocracy) suppressWarnings(report_table(model))
Creates text containing a description of the parameters of R objects (see
list of supported objects in report()
).
report_text(x, table = NULL, ...)
report_text(x, table = NULL, ...)
x |
The R object that you want to report (see list of of supported objects above). |
table |
A table obtained via |
... |
Arguments passed to or from other methods. |
An object of class report_text()
.
library(report) # Miscellaneous r <- report_text(sessionInfo()) r summary(r) # Data report_text(iris$Sepal.Length) report_text(as.character(round(iris$Sepal.Length, 1))) report_text(iris$Species) report_text(iris) # h-tests report_text(t.test(iris$Sepal.Width, iris$Sepal.Length)) # ANOVA r <- report_text(aov(Sepal.Length ~ Species, data = iris)) r summary(r) # GLMs r <- report_text(lm(Sepal.Length ~ Petal.Length * Species, data = iris)) r summary(r) library(lme4) model <- lme4::lmer(Sepal.Length ~ Petal.Length + (1 | Species), data = iris) r <- report_text(model) r summary(r) # Bayesian models library(rstanarm) model <- suppressWarnings(stan_glm(mpg ~ cyl + wt, data = mtcars, refresh = 0, iter = 600)) r <- report_text(model) r summary(r)
library(report) # Miscellaneous r <- report_text(sessionInfo()) r summary(r) # Data report_text(iris$Sepal.Length) report_text(as.character(round(iris$Sepal.Length, 1))) report_text(iris$Species) report_text(iris) # h-tests report_text(t.test(iris$Sepal.Width, iris$Sepal.Length)) # ANOVA r <- report_text(aov(Sepal.Length ~ Species, data = iris)) r summary(r) # GLMs r <- report_text(lm(Sepal.Length ~ Petal.Length * Species, data = iris)) r summary(r) library(lme4) model <- lme4::lmer(Sepal.Length ~ Petal.Length + (1 | Species), data = iris) r <- report_text(model) r summary(r) # Bayesian models library(rstanarm) model <- suppressWarnings(stan_glm(mpg ~ cyl + wt, data = mtcars, refresh = 0, iter = 600)) r <- report_text(model) r summary(r)
Create reports for ANOVA models.
## S3 method for class 'aov' report(x, ...) ## S3 method for class 'aov' report_effectsize(x, ...) ## S3 method for class 'aov' report_table(x, ...) ## S3 method for class 'aov' report_statistics(x, table = NULL, ...) ## S3 method for class 'aov' report_parameters(x, ...) ## S3 method for class 'aov' report_model(x, table = NULL, ...) ## S3 method for class 'aov' report_info(x, effectsize = NULL, ...) ## S3 method for class 'aov' report_text(x, table = NULL, ...)
## S3 method for class 'aov' report(x, ...) ## S3 method for class 'aov' report_effectsize(x, ...) ## S3 method for class 'aov' report_table(x, ...) ## S3 method for class 'aov' report_statistics(x, table = NULL, ...) ## S3 method for class 'aov' report_parameters(x, ...) ## S3 method for class 'aov' report_model(x, table = NULL, ...) ## S3 method for class 'aov' report_info(x, effectsize = NULL, ...) ## S3 method for class 'aov' report_text(x, table = NULL, ...)
x |
Object of class |
... |
Arguments passed to or from other methods. |
table |
Provide the output of |
effectsize |
Provide the output of |
An object of class report()
.
Specific components of reports (especially for stats models):
Other types of reports:
Methods:
Template file for supporting new models:
data <- iris data$Cat1 <- rep(c("A", "B"), length.out = nrow(data)) model <- aov(Sepal.Length ~ Species * Cat1, data = data) r <- report(model) r summary(r) as.data.frame(r) summary(as.data.frame(r))
data <- iris data$Cat1 <- rep(c("A", "B"), length.out = nrow(data)) model <- aov(Sepal.Length ~ Species * Cat1, data = data) r <- report(model) r summary(r) as.data.frame(r) summary(as.data.frame(r))
Create reports of Bayes factors for model comparison.
## S3 method for class 'bayesfactor_models' report( x, interpretation = "jeffreys1961", exact = TRUE, protect_ratio = TRUE, ... ) ## S3 method for class 'bayesfactor_inclusion' report( x, interpretation = "jeffreys1961", exact = TRUE, protect_ratio = TRUE, ... )
## S3 method for class 'bayesfactor_models' report( x, interpretation = "jeffreys1961", exact = TRUE, protect_ratio = TRUE, ... ) ## S3 method for class 'bayesfactor_inclusion' report( x, interpretation = "jeffreys1961", exact = TRUE, protect_ratio = TRUE, ... )
x |
Object of class |
interpretation |
Effect size interpretation set of rules (see interpret_bf). |
exact |
Should very large or very small values be reported with a scientific format (e.g., 4.24e5), or as truncated values (as "> 1000" and "< 1/1000"). |
protect_ratio |
Should values smaller than 1 be represented as ratios? |
... |
Arguments passed to or from other methods. |
An object of class report()
.
Specific components of reports (especially for stats models):
Other types of reports:
Methods:
Template file for supporting new models:
library(bayestestR) # Bayes factor - models mo0 <- lm(Sepal.Length ~ 1, data = iris) mo1 <- lm(Sepal.Length ~ Species, data = iris) mo2 <- lm(Sepal.Length ~ Species + Petal.Length, data = iris) mo3 <- lm(Sepal.Length ~ Species * Petal.Length, data = iris) BFmodels <- bayesfactor_models(mo1, mo2, mo3, denominator = mo0) r <- report(BFmodels) r # Bayes factor - inclusion inc_bf <- bayesfactor_inclusion(BFmodels, prior_odds = c(1, 2, 3), match_models = TRUE) r <- report(inc_bf) r as.data.frame(r)
library(bayestestR) # Bayes factor - models mo0 <- lm(Sepal.Length ~ 1, data = iris) mo1 <- lm(Sepal.Length ~ Species, data = iris) mo2 <- lm(Sepal.Length ~ Species + Petal.Length, data = iris) mo3 <- lm(Sepal.Length ~ Species * Petal.Length, data = iris) BFmodels <- bayesfactor_models(mo1, mo2, mo3, denominator = mo0) r <- report(BFmodels) r # Bayes factor - inclusion inc_bf <- bayesfactor_inclusion(BFmodels, prior_odds = c(1, 2, 3), match_models = TRUE) r <- report(inc_bf) r as.data.frame(r)
BFBayesFactor
objects from the BayesFactor
packageInterpretation of the Bayes factor output from the BayesFactor
package.
## S3 method for class 'BFBayesFactor' report(x, h0 = "H0", h1 = "H1", ...) ## S3 method for class 'BFBayesFactor' report_statistics(x, table = NULL, ...)
## S3 method for class 'BFBayesFactor' report(x, h0 = "H0", h1 = "H1", ...) ## S3 method for class 'BFBayesFactor' report_statistics(x, table = NULL, ...)
x |
An object of class |
h0 , h1
|
Names of the null and alternative hypotheses. |
... |
Other arguments to be passed to effectsize::interpret_bf and insight::format_bf. |
table |
A |
library(BayesFactor) rez <- BayesFactor::ttestBF(iris$Sepal.Width, iris$Sepal.Length) report_statistics(rez, exact = TRUE) # Print exact BF report(rez, h0 = "the null hypothesis", h1 = "the alternative") rez <- BayesFactor::correlationBF(iris$Sepal.Width, iris$Sepal.Length) report(rez)
library(BayesFactor) rez <- BayesFactor::ttestBF(iris$Sepal.Width, iris$Sepal.Length) report_statistics(rez, exact = TRUE) # Print exact BF report(rez, h0 = "the null hypothesis", h1 = "the alternative") rez <- BayesFactor::correlationBF(iris$Sepal.Width, iris$Sepal.Length) report(rez)
Create reports for Bayesian models. The description of the parameters follows the Sequential Effect eXistence and sIgnificance Testing framework (see SEXIT documentation).
## S3 method for class 'brmsfit' report(x, ...)
## S3 method for class 'brmsfit' report(x, ...)
x |
Object of class |
... |
Arguments passed to or from other methods. |
An object of class report()
.
Specific components of reports (especially for stats models):
Other types of reports:
Methods:
Template file for supporting new models:
# Bayesian models library(brms) model <- suppressWarnings(brm(mpg ~ qsec + wt, data = mtcars, refresh = 0, iter = 300)) r <- report(model, verbose = FALSE) r summary(r) as.data.frame(r) summary(as.data.frame(r))
# Bayesian models library(brms) model <- suppressWarnings(brm(mpg ~ qsec + wt, data = mtcars, refresh = 0, iter = 300)) r <- report(model, verbose = FALSE) r summary(r) as.data.frame(r) summary(as.data.frame(r))
Create reports for data frames.
## S3 method for class 'character' report( x, n_entries = 3, levels_percentage = "auto", missing_percentage = "auto", ... ) ## S3 method for class 'data.frame' report( x, n = FALSE, centrality = "mean", dispersion = TRUE, range = TRUE, distribution = FALSE, levels_percentage = "auto", digits = 2, n_entries = 3, missing_percentage = "auto", ... ) ## S3 method for class 'factor' report(x, levels_percentage = "auto", ...) ## S3 method for class 'numeric' report( x, n = FALSE, centrality = "mean", dispersion = TRUE, range = TRUE, distribution = FALSE, missing_percentage = "auto", digits = 2, ... )
## S3 method for class 'character' report( x, n_entries = 3, levels_percentage = "auto", missing_percentage = "auto", ... ) ## S3 method for class 'data.frame' report( x, n = FALSE, centrality = "mean", dispersion = TRUE, range = TRUE, distribution = FALSE, levels_percentage = "auto", digits = 2, n_entries = 3, missing_percentage = "auto", ... ) ## S3 method for class 'factor' report(x, levels_percentage = "auto", ...) ## S3 method for class 'numeric' report( x, n = FALSE, centrality = "mean", dispersion = TRUE, range = TRUE, distribution = FALSE, missing_percentage = "auto", digits = 2, ... )
x |
The R object that you want to report (see list of of supported objects above). |
n_entries |
Number of different character entries to show. Can be "all". |
levels_percentage |
Show characters entries and factor levels by number or percentage. If "auto", then will be set to number and percentage if the length if n observations larger than 100. |
missing_percentage |
Show missing by number (default) or percentage. If "auto", then will be set to number and percentage if the length if n observations larger than 100. |
... |
Arguments passed to or from other methods. |
n |
Include number of observations for each individual variable. |
centrality |
Character vector, indicating the index of centrality
(either |
dispersion |
Show index of dispersion (sd if |
range |
Show range. |
distribution |
Show kurtosis and skewness. |
digits |
Number of significant digits. |
An object of class report()
.
r <- report(iris, centrality = "median", dispersion = FALSE, distribution = TRUE, missing_percentage = TRUE ) r summary(r) as.data.frame(r) summary(as.data.frame(r)) # grouped analysis using `{dplyr}` package library(dplyr) r <- iris %>% group_by(Species) %>% report() r summary(r) as.data.frame(r) summary(as.data.frame(r))
r <- report(iris, centrality = "median", dispersion = FALSE, distribution = TRUE, missing_percentage = TRUE ) r summary(r) as.data.frame(r) summary(as.data.frame(r)) # grouped analysis using `{dplyr}` package library(dplyr) r <- iris %>% group_by(Species) %>% report() r summary(r) as.data.frame(r) summary(as.data.frame(r))
Create reports for model comparison as obtained by the
performance::compare_performance()
function in the performance
package.
## S3 method for class 'compare_performance' report(x, ...) ## S3 method for class 'compare_performance' report_table(x, ...) ## S3 method for class 'compare_performance' report_statistics(x, table = NULL, ...) ## S3 method for class 'compare_performance' report_parameters(x, table = NULL, ...) ## S3 method for class 'compare_performance' report_text(x, table = NULL, ...)
## S3 method for class 'compare_performance' report(x, ...) ## S3 method for class 'compare_performance' report_table(x, ...) ## S3 method for class 'compare_performance' report_statistics(x, table = NULL, ...) ## S3 method for class 'compare_performance' report_parameters(x, table = NULL, ...) ## S3 method for class 'compare_performance' report_text(x, table = NULL, ...)
x |
Object of class |
... |
Arguments passed to or from other methods. |
table |
Provide the output of |
An object of class report()
.
Specific components of reports (especially for stats models):
Other types of reports:
Methods:
Template file for supporting new models:
library(report) library(performance) m1 <- lm(Sepal.Length ~ Petal.Length * Species, data = iris) m2 <- lm(Sepal.Length ~ Petal.Length + Species, data = iris) m3 <- lm(Sepal.Length ~ Petal.Length, data = iris) x <- performance::compare_performance(m1, m2, m3) r <- report(x) r summary(r) as.data.frame(r) summary(as.data.frame(r)) # Specific reports report_table(x) report_statistics(x) report_parameters(x)
library(report) library(performance) m1 <- lm(Sepal.Length ~ Petal.Length * Species, data = iris) m2 <- lm(Sepal.Length ~ Petal.Length + Species, data = iris) m3 <- lm(Sepal.Length ~ Petal.Length, data = iris) x <- performance::compare_performance(m1, m2, m3) r <- report(x) r summary(r) as.data.frame(r) summary(as.data.frame(r)) # Specific reports report_table(x) report_statistics(x) report_parameters(x)
Automatically report the results of Bayesian model comparison using the loo
package.
## S3 method for class 'compare.loo' report(x, include_IC = TRUE, include_ENP = FALSE, ...)
## S3 method for class 'compare.loo' report(x, include_IC = TRUE, include_ENP = FALSE, ...)
x |
An object of class brms::loo_compare. |
include_IC |
Whether to include the information criteria (IC). |
include_ENP |
Whether to include the effective number of parameters (ENP). |
... |
Additional arguments (not used for now). |
The rule of thumb is that the models are "very similar" if |elpd_diff| (the
absolute value of elpd_diff) is less than 4 (Sivula, Magnusson and Vehtari, 2020).
If superior to 4, then one can use the SE to obtain a standardized difference
(Z-diff) and interpret it as such, assuming that the difference is normally
distributed. The corresponding p-value is then calculated as 2 * pnorm(-abs(Z-diff))
.
However, note that if the raw ELPD difference is small (less than 4), it doesn't
make much sense to rely on its standardized value: it is not very useful to
conclude that a model is much better than another if both models make very
similar predictions.
Objects of class report_text()
.
library(brms) m1 <- brms::brm(mpg ~ qsec, data = mtcars) m2 <- brms::brm(mpg ~ qsec + drat, data = mtcars) m3 <- brms::brm(mpg ~ qsec + drat + wt, data = mtcars) x <- suppressWarnings(brms::loo_compare( brms::add_criterion(m1, "loo"), brms::add_criterion(m2, "loo"), brms::add_criterion(m3, "loo"), model_names = c("m1", "m2", "m3") )) report(x) report(x, include_IC = FALSE) report(x, include_ENP = TRUE)
library(brms) m1 <- brms::brm(mpg ~ qsec, data = mtcars) m2 <- brms::brm(mpg ~ qsec + drat, data = mtcars) m3 <- brms::brm(mpg ~ qsec + drat + wt, data = mtcars) x <- suppressWarnings(brms::loo_compare( brms::add_criterion(m1, "loo"), brms::add_criterion(m2, "loo"), brms::add_criterion(m3, "loo"), model_names = c("m1", "m2", "m3") )) report(x) report(x, include_IC = FALSE) report(x, include_ENP = TRUE)
Template file to add report support for new objects. Check-out the vignette on Supporting New Models.
## Default S3 method: report(x, ...) ## Default S3 method: report_effectsize(x, ...) ## Default S3 method: report_table(x, ...) ## Default S3 method: report_statistics(x, ...) ## Default S3 method: report_parameters(x, ...) ## Default S3 method: report_intercept(x, ...) ## Default S3 method: report_model(x, ...) ## Default S3 method: report_random(x, ...) ## Default S3 method: report_priors(x, ...) ## Default S3 method: report_performance(x, ...) ## Default S3 method: report_info(x, ...) ## Default S3 method: report_text(x, ...)
## Default S3 method: report(x, ...) ## Default S3 method: report_effectsize(x, ...) ## Default S3 method: report_table(x, ...) ## Default S3 method: report_statistics(x, ...) ## Default S3 method: report_parameters(x, ...) ## Default S3 method: report_intercept(x, ...) ## Default S3 method: report_model(x, ...) ## Default S3 method: report_random(x, ...) ## Default S3 method: report_priors(x, ...) ## Default S3 method: report_performance(x, ...) ## Default S3 method: report_info(x, ...) ## Default S3 method: report_text(x, ...)
x |
Object of class |
... |
Arguments passed to or from other methods. |
An object of class report()
.
Specific components of reports (especially for stats models):
Other types of reports:
Methods:
Template file for supporting new models:
library(report) # Add a reproducible example instead of the following model <- lm(Sepal.Length ~ Petal.Length * Species, data = iris) r <- report(model) r summary(r) as.data.frame(r) summary(as.data.frame(r))
library(report) # Add a reproducible example instead of the following model <- lm(Sepal.Length ~ Petal.Length * Species, data = iris) r <- report(model) r summary(r) as.data.frame(r) summary(as.data.frame(r))
estimate_contrasts
objectsCreate reports for estimate_contrasts
objects.
## S3 method for class 'estimate_contrasts' report(x, ...) ## S3 method for class 'estimate_contrasts' report_table(x, ...) ## S3 method for class 'estimate_contrasts' report_text(x, table = NULL, ...)
## S3 method for class 'estimate_contrasts' report(x, ...) ## S3 method for class 'estimate_contrasts' report_table(x, ...) ## S3 method for class 'estimate_contrasts' report_text(x, table = NULL, ...)
x |
Object of class |
... |
Arguments passed to or from other methods. |
table |
Provide the output of |
An object of class report()
.
Specific components of reports (especially for stats models):
Other types of reports:
Methods:
Template file for supporting new models:
library(modelbased) model <- lm(Sepal.Width ~ Species, data = iris) contr <- estimate_contrasts(model) report(contr)
library(modelbased) model <- lm(Sepal.Width ~ Species, data = iris) contr <- estimate_contrasts(model) report(contr)
htest
objects (Correlation, t-test...)Create reports for htest
objects (t.test()
, cor.test()
,
etc.).
## S3 method for class 'htest' report(x, ...) ## S3 method for class 'htest' report_effectsize(x, ...) ## S3 method for class 'htest' report_table(x, ...) ## S3 method for class 'htest' report_statistics(x, table = NULL, ...) ## S3 method for class 'htest' report_parameters(x, table = NULL, ...) ## S3 method for class 'htest' report_model(x, table = NULL, ...) ## S3 method for class 'htest' report_info(x, effectsize = NULL, ...) ## S3 method for class 'htest' report_text(x, table = NULL, ...)
## S3 method for class 'htest' report(x, ...) ## S3 method for class 'htest' report_effectsize(x, ...) ## S3 method for class 'htest' report_table(x, ...) ## S3 method for class 'htest' report_statistics(x, table = NULL, ...) ## S3 method for class 'htest' report_parameters(x, table = NULL, ...) ## S3 method for class 'htest' report_model(x, table = NULL, ...) ## S3 method for class 'htest' report_info(x, effectsize = NULL, ...) ## S3 method for class 'htest' report_text(x, table = NULL, ...)
x |
Object of class |
... |
Arguments passed to or from other methods. |
table |
Provide the output of |
effectsize |
Provide the output of |
An object of class report()
.
Specific components of reports (especially for stats models):
Other types of reports:
Methods:
Template file for supporting new models:
# t-tests report(t.test(iris$Sepal.Width, iris$Sepal.Length)) report(t.test(iris$Sepal.Width, iris$Sepal.Length, var.equal = TRUE)) report(t.test(mtcars$mpg ~ mtcars$vs)) report(t.test(mtcars$mpg, mtcars$vs, paired = TRUE), verbose = FALSE) report(t.test(iris$Sepal.Width, mu = 1)) # Correlations report(cor.test(iris$Sepal.Width, iris$Sepal.Length))
# t-tests report(t.test(iris$Sepal.Width, iris$Sepal.Length)) report(t.test(iris$Sepal.Width, iris$Sepal.Length, var.equal = TRUE)) report(t.test(mtcars$mpg ~ mtcars$vs)) report(t.test(mtcars$mpg, mtcars$vs, paired = TRUE), verbose = FALSE) report(t.test(iris$Sepal.Width, mu = 1)) # Correlations report(cor.test(iris$Sepal.Width, iris$Sepal.Length))
Create a report for lavaan
objects.
## S3 method for class 'lavaan' report(x, ...) ## S3 method for class 'lavaan' report_performance(x, table = NULL, ...)
## S3 method for class 'lavaan' report(x, ...) ## S3 method for class 'lavaan' report_performance(x, table = NULL, ...)
x |
Object of class |
... |
Arguments passed to or from other methods. |
table |
Provide the output of |
An object of class report()
.
Specific components of reports (especially for stats models):
Other types of reports:
Methods:
Template file for supporting new models:
# Structural Equation Models (SEM) library(lavaan) structure <- "ind60 =~ x1 + x2 + x3 dem60 =~ y1 + y2 + y3 dem60 ~ ind60" model <- lavaan::sem(structure, data = PoliticalDemocracy) r <- report(model) r summary(r) as.data.frame(r) summary(as.data.frame(r)) # Specific reports suppressWarnings(report_table(model)) suppressWarnings(report_performance(model))
# Structural Equation Models (SEM) library(lavaan) structure <- "ind60 =~ x1 + x2 + x3 dem60 =~ y1 + y2 + y3 dem60 ~ ind60" model <- lavaan::sem(structure, data = PoliticalDemocracy) r <- report(model) r summary(r) as.data.frame(r) summary(as.data.frame(r)) # Specific reports suppressWarnings(report_table(model)) suppressWarnings(report_performance(model))
Create reports for (general) linear models.
## S3 method for class 'lm' report(x, include_effectsize = TRUE, effectsize_method = "refit", ...) ## S3 method for class 'lm' report_effectsize(x, effectsize_method = "refit", ...) ## S3 method for class 'lm' report_table(x, include_effectsize = TRUE, ...) ## S3 method for class 'lm' report_statistics( x, table = NULL, include_effectsize = TRUE, include_diagnostic = TRUE, ... ) ## S3 method for class 'lm' report_parameters( x, table = NULL, include_effectsize = TRUE, include_intercept = TRUE, ... ) ## S3 method for class 'lm' report_intercept(x, table = NULL, ...) ## S3 method for class 'lm' report_model(x, table = NULL, ...) ## S3 method for class 'lm' report_performance(x, table = NULL, ...) ## S3 method for class 'lm' report_info( x, effectsize = NULL, include_effectsize = FALSE, parameters = NULL, ... ) ## S3 method for class 'lm' report_text(x, table = NULL, ...) ## S3 method for class 'merMod' report_random(x, ...)
## S3 method for class 'lm' report(x, include_effectsize = TRUE, effectsize_method = "refit", ...) ## S3 method for class 'lm' report_effectsize(x, effectsize_method = "refit", ...) ## S3 method for class 'lm' report_table(x, include_effectsize = TRUE, ...) ## S3 method for class 'lm' report_statistics( x, table = NULL, include_effectsize = TRUE, include_diagnostic = TRUE, ... ) ## S3 method for class 'lm' report_parameters( x, table = NULL, include_effectsize = TRUE, include_intercept = TRUE, ... ) ## S3 method for class 'lm' report_intercept(x, table = NULL, ...) ## S3 method for class 'lm' report_model(x, table = NULL, ...) ## S3 method for class 'lm' report_performance(x, table = NULL, ...) ## S3 method for class 'lm' report_info( x, effectsize = NULL, include_effectsize = FALSE, parameters = NULL, ... ) ## S3 method for class 'lm' report_text(x, table = NULL, ...) ## S3 method for class 'merMod' report_random(x, ...)
x |
Object of class |
include_effectsize |
If |
effectsize_method |
See documentation for
|
... |
Arguments passed to or from other methods. |
table |
Provide the output of |
include_diagnostic |
If |
include_intercept |
If |
effectsize |
Provide the output of |
parameters |
Provide the output of |
An object of class report()
.
Specific components of reports (especially for stats models):
Other types of reports:
Methods:
Template file for supporting new models:
library(report) # Linear models model <- lm(Sepal.Length ~ Petal.Length * Species, data = iris) r <- report(model) r summary(r) as.data.frame(r) summary(as.data.frame(r)) # Logistic models model <- glm(vs ~ disp, data = mtcars, family = "binomial") r <- report(model) r summary(r) as.data.frame(r) summary(as.data.frame(r)) # Mixed models library(lme4) model <- lme4::lmer(Sepal.Length ~ Petal.Length + (1 | Species), data = iris) r <- report(model) r summary(r) as.data.frame(r) summary(as.data.frame(r))
library(report) # Linear models model <- lm(Sepal.Length ~ Petal.Length * Species, data = iris) r <- report(model) r summary(r) as.data.frame(r) summary(as.data.frame(r)) # Logistic models model <- glm(vs ~ disp, data = mtcars, family = "binomial") r <- report(model) r summary(r) as.data.frame(r) summary(as.data.frame(r)) # Mixed models library(lme4) model <- lme4::lmer(Sepal.Length ~ Petal.Length + (1 | Species), data = iris) r <- report(model) r summary(r) as.data.frame(r) summary(as.data.frame(r))
Report R environment (packages, system, etc.)
## S3 method for class 'sessionInfo' report(x, ...) report_packages(session = NULL, include_R = TRUE, ...) cite_packages(session = NULL, include_R = TRUE, ...) report_system(session = NULL)
## S3 method for class 'sessionInfo' report(x, ...) report_packages(session = NULL, include_R = TRUE, ...) cite_packages(session = NULL, include_R = TRUE, ...) report_system(session = NULL)
x |
The R object that you want to report (see list of of supported objects above). |
... |
Arguments passed to or from other methods. |
session |
A sessionInfo object. |
include_R |
Include R in the citations. |
For report_packages
, a data frame of class with information on package
name, version and citation.
An object of class report()
.
library(report) session <- sessionInfo() r <- report(session) r summary(r) as.data.frame(r) summary(as.data.frame(r)) # Convenience functions report_packages(include_R = FALSE) cite_packages(prefix = "> ") report_system()
library(report) session <- sessionInfo() r <- report(session) r summary(r) as.data.frame(r) summary(as.data.frame(r)) # Convenience functions report_packages(include_R = FALSE) cite_packages(prefix = "> ") report_system()
Create reports for Bayesian models. The description of the parameters follows the Sequential Effect eXistence and sIgnificance Testing framework (see SEXIT documentation).
## S3 method for class 'stanreg' report(x, ...)
## S3 method for class 'stanreg' report(x, ...)
x |
Object of class |
... |
Arguments passed to or from other methods. |
An object of class report()
.
Specific components of reports (especially for stats models):
Other types of reports:
Methods:
Template file for supporting new models:
# Bayesian models library(rstanarm) model <- suppressWarnings(stan_glm(mpg ~ qsec + wt, data = mtcars, refresh = 0, iter = 500)) r <- report(model) r summary(r) as.data.frame(r)
# Bayesian models library(rstanarm) model <- suppressWarnings(stan_glm(mpg ~ qsec + wt, data = mtcars, refresh = 0, iter = 500)) r <- report(model) r summary(r) as.data.frame(r)
Create reports for model comparison as obtained by the
performance::compare_performance()
function in the performance
package.
## S3 method for class 'test_performance' report(x, ...) ## S3 method for class 'test_performance' report_table(x, ...) ## S3 method for class 'test_performance' report_statistics(x, table = NULL, ...) ## S3 method for class 'test_performance' report_parameters(x, table = NULL, ...) ## S3 method for class 'test_performance' report_text(x, table = NULL, ...)
## S3 method for class 'test_performance' report(x, ...) ## S3 method for class 'test_performance' report_table(x, ...) ## S3 method for class 'test_performance' report_statistics(x, table = NULL, ...) ## S3 method for class 'test_performance' report_parameters(x, table = NULL, ...) ## S3 method for class 'test_performance' report_text(x, table = NULL, ...)
x |
Object of class |
... |
Arguments passed to or from other methods. |
table |
Provide the output of |
An object of class report()
.
Specific components of reports (especially for stats models):
Other types of reports:
Methods:
Template file for supporting new models:
library(report) library(performance) m1 <- lm(Sepal.Length ~ Petal.Length * Species, data = iris) m2 <- lm(Sepal.Length ~ Petal.Length + Species, data = iris) m3 <- lm(Sepal.Length ~ Petal.Length, data = iris) x <- performance::test_performance(m1, m2, m3) r <- report(x) r summary(r) as.data.frame(r) summary(as.data.frame(r)) # Specific reports report_table(x) report_statistics(x) report_parameters(x)
library(report) library(performance) m1 <- lm(Sepal.Length ~ Petal.Length * Species, data = iris) m2 <- lm(Sepal.Length ~ Petal.Length + Species, data = iris) m3 <- lm(Sepal.Length ~ Petal.Length, data = iris) x <- performance::test_performance(m1, m2, m3) r <- report(x) r summary(r) as.data.frame(r) summary(as.data.frame(r)) # Specific reports report_table(x) report_statistics(x) report_parameters(x)