Skip to contents

Creates text containing a description of the parameters of R objects (see list of supported objects in report()).

Usage

report_text(x, table = NULL, ...)

Arguments

x

The R object that you want to report (see list of of supported objects above).

table

A table obtained via report_table(). If not provided, will run it.

...

Arguments passed to or from other methods.

Value

An object of class report_text().

Examples

library(report)

# Miscellaneous
r <- report_text(sessionInfo())
r
#> Analyses were conducted using the R Statistical language (version 4.2.2; R Core
#> Team, 2022) on Ubuntu 22.04.1 LTS, using the packages Matrix (version 1.5.3;
#> Bates D et al., 2022), lme4 (version 1.1.31; Bates D et al., 2015), Rcpp
#> (version 1.0.10; Eddelbuettel D, François R, 2011), rstanarm (version 2.21.3;
#> Goodrich B et al., 2022), performance (version 0.10.2; Lüdecke D et al., 2021),
#> bayestestR (version 0.13.0; Makowski D et al., 2019), report (version 0.5.6;
#> Makowski D et al., 2023), lavaan (version 0.6.13; Rosseel Y, 2012) and dplyr
#> (version 1.1.0; Wickham H et al., 2023).
#> 
#> References
#> ----------
#>   - Bates D, Maechler M, Jagan M (2022). _Matrix: Sparse and Dense Matrix Classes
#> and Methods_. https://Matrix.R-forge.R-project.org/,
#> https://Matrix.R-forge.R-project.org/doxygen/.
#>   - Bates D, Mächler M, Bolker B, Walker S (2015). “Fitting Linear Mixed-Effects
#> Models Using lme4.” _Journal of Statistical Software_, *67*(1), 1-48.
#> doi:10.18637/jss.v067.i01 <https://doi.org/10.18637/jss.v067.i01>.
#>   - Eddelbuettel D, François R (2011). “Rcpp: Seamless R and C++ Integration.”
#> _Journal of Statistical Software_, *40*(8), 1-18. doi:10.18637/jss.v040.i08
#> <https://doi.org/10.18637/jss.v040.i08>. Eddelbuettel D (2013). _Seamless R and
#> C++ Integration with Rcpp_. Springer, New York. doi:10.1007/978-1-4614-6868-4
#> <https://doi.org/10.1007/978-1-4614-6868-4>, ISBN 978-1-4614-6867-7.
#> Eddelbuettel D, Balamuta JJ (2018). “Extending extitR with extitC++: A Brief
#> Introduction to extitRcpp.” _The American Statistician_, *72*(1), 28-36.
#> doi:10.1080/00031305.2017.1375990
#> <https://doi.org/10.1080/00031305.2017.1375990>.
#>   - Goodrich B, Gabry J, Ali I, Brilleman S (2022). “rstanarm: Bayesian applied
#> regression modeling via Stan.” R package version 2.21.3,
#> <https://mc-stan.org/rstanarm/>. Brilleman S, Crowther M, Moreno-Betancur M,
#> Buros Novik J, Wolfe R (2018). “Joint longitudinal and time-to-event models via
#> Stan.” StanCon 2018. 10-12 Jan 2018. Pacific Grove, CA, USA.,
#> <https://github.com/stan-dev/stancon_talks/>.
#>   - Lüdecke D, Ben-Shachar M, Patil I, Waggoner P, Makowski D (2021).
#> “performance: An R Package for Assessment, Comparison and Testing of
#> Statistical Models.” _Journal of Open Source Software_, *6*(60), 3139.
#> doi:10.21105/joss.03139 <https://doi.org/10.21105/joss.03139>.
#>   - Makowski D, Ben-Shachar M, Lüdecke D (2019). “bayestestR: Describing Effects
#> and their Uncertainty, Existence and Significance within the Bayesian
#> Framework.” _Journal of Open Source Software_, *4*(40), 1541.
#> doi:10.21105/joss.01541 <https://doi.org/10.21105/joss.01541>,
#> <https://joss.theoj.org/papers/10.21105/joss.01541>.
#>   - Makowski D, Lüdecke D, Patil I, Thériault R (2023). “Automated Results
#> Reporting as a Practical Tool to Improve Reproducibility and Methodological
#> Best Practices Adoption.” _CRAN_. <https://easystats.github.io/report/>.
#>   - R Core Team (2022). _R: A Language and Environment for Statistical
#> Computing_. R Foundation for Statistical Computing, Vienna, Austria.
#> <https://www.R-project.org/>.
#>   - Rosseel Y (2012). “lavaan: An R Package for Structural Equation Modeling.”
#> _Journal of Statistical Software_, *48*(2), 1-36. doi:10.18637/jss.v048.i02
#> <https://doi.org/10.18637/jss.v048.i02>.
#>   - Wickham H, François R, Henry L, Müller K, Vaughan D (2023). _dplyr: A Grammar
#> of Data Manipulation_. https://dplyr.tidyverse.org,
#> https://github.com/tidyverse/dplyr.
summary(r)
#> The analysis was done using the R Statistical language (v4.2.2; R Core Team,
#> 2022) on Ubuntu 22.04.1 LTS, using the packages Matrix (v1.5.3), lme4
#> (v1.1.31), Rcpp (v1.0.10), rstanarm (v2.21.3), performance (v0.10.2),
#> bayestestR (v0.13.0), report (v0.5.6), lavaan (v0.6.13) and dplyr (v1.1.0).

# Data
report_text(iris$Sepal.Length)
#> iris$Sepal.Length: n = 150, Mean = 5.84, SD = 0.83, Median = 5.80, MAD = 1.04,
#> range: [4.30, 7.90], Skewness = 0.31, Kurtosis = -0.55, 0% missing
report_text(as.character(round(iris$Sepal.Length, 1)))
#> as.character(round(iris$Sepal.Length, 1)): 35 entries, such as 5 (6.67%); 5.1
#> (6.00%); 6.3 (6.00%) and 32 others (0 missing)
report_text(iris$Species)
#> iris$Species: 3 levels, namely setosa (n = 50, 33.33%), versicolor (n = 50,
#> 33.33%) and virginica (n = 50, 33.33%)
report_text(iris)
#> The data contains 150 observations of the following 5 variables:
#> 
#>   - Sepal.Length: n = 150, Mean = 5.84, SD = 0.83, Median = 5.80, MAD = 1.04,
#> range: [4.30, 7.90], Skewness = 0.31, Kurtosis = -0.55, 0% missing
#>   - Sepal.Width: n = 150, Mean = 3.06, SD = 0.44, Median = 3.00, MAD = 0.44,
#> range: [2, 4.40], Skewness = 0.32, Kurtosis = 0.23, 0% missing
#>   - Petal.Length: n = 150, Mean = 3.76, SD = 1.77, Median = 4.35, MAD = 1.85,
#> range: [1, 6.90], Skewness = -0.27, Kurtosis = -1.40, 0% missing
#>   - Petal.Width: n = 150, Mean = 1.20, SD = 0.76, Median = 1.30, MAD = 1.04,
#> range: [0.10, 2.50], Skewness = -0.10, Kurtosis = -1.34, 0% missing
#>   - Species: 3 levels, namely setosa (n = 50, 33.33%), versicolor (n = 50,
#> 33.33%) and virginica (n = 50, 33.33%)

# h-tests
report_text(t.test(iris$Sepal.Width, iris$Sepal.Length))
#> Effect sizes were labelled following Cohen's (1988) recommendations.
#> 
#> The Welch Two Sample t-test testing the difference between iris$Sepal.Width and
#> iris$Sepal.Length (mean of x = 3.06, mean of y = 5.84) suggests that the effect
#> is negative, statistically significant, and large (difference = -2.79, 95% CI
#> [-2.94, -2.64], t(225.68) = -36.46, p < .001; Cohen's d = -4.21, 95% CI [-4.66,
#> -3.76])

# ANOVA
r <- report_text(aov(Sepal.Length ~ Species, data = iris))
r
#> The ANOVA (formula: Sepal.Length ~ Species) suggests that:
#> 
#>   - The main effect of Species is statistically significant and large (F(2, 147)
#> = 119.26, p < .001; Eta2 = 0.62, 95% CI [0.54, 1.00])
#> 
#> Effect sizes were labelled following Field's (2013) recommendations.
summary(r)
#> The ANOVA suggests that:
#> 
#>   - The main effect of Species is statistically significant and large (F(2, 147)
#> = 119.26, p < .001, Eta2 = 0.62)

# GLMs
r <- report_text(lm(Sepal.Length ~ Petal.Length * Species, data = iris))
r
#> We fitted a linear model (estimated using OLS) to predict Sepal.Length with
#> Petal.Length and Species (formula: Sepal.Length ~ Petal.Length * Species). The
#> model explains a statistically significant and substantial proportion of
#> variance (R2 = 0.84, F(5, 144) = 151.71, p < .001, adj. R2 = 0.83). The model's
#> intercept, corresponding to Petal.Length = 0 and Species = setosa, is at 4.21
#> (95% CI [3.41, 5.02], t(144) = 10.34, p < .001). Within this model:
#> 
#>   - The effect of Petal Length is statistically non-significant and positive
#> (beta = 0.54, 95% CI [-4.76e-03, 1.09], t(144) = 1.96, p = 0.052; Std. beta =
#> 1.16, 95% CI [-0.01, 2.32])
#>   - The effect of Species [versicolor] is statistically significant and negative
#> (beta = -1.81, 95% CI [-2.99, -0.62], t(144) = -3.02, p = 0.003; Std. beta =
#> -0.88, 95% CI [-2.41, 0.65])
#>   - The effect of Species [virginica] is statistically significant and negative
#> (beta = -3.15, 95% CI [-4.41, -1.90], t(144) = -4.97, p < .001; Std. beta =
#> -1.75, 95% CI [-3.32, -0.18])
#>   - The effect of Petal Length × Species [versicolor] is statistically
#> non-significant and positive (beta = 0.29, 95% CI [-0.30, 0.87], t(144) = 0.97,
#> p = 0.334; Std. beta = 0.61, 95% CI [-0.63, 1.85])
#>   - The effect of Petal Length × Species [virginica] is statistically
#> non-significant and positive (beta = 0.45, 95% CI [-0.12, 1.03], t(144) = 1.56,
#> p = 0.120; Std. beta = 0.97, 95% CI [-0.26, 2.19])
#> 
#> Standardized parameters were obtained by fitting the model on a standardized
#> version of the dataset. 95% Confidence Intervals (CIs) and p-values were
#> computed using a Wald t-distribution approximation.
summary(r)
#> We fitted a linear model to predict Sepal.Length with Petal.Length and Species.
#> The model's explanatory power is substantial (R2 = 0.84, adj. R2 = 0.83). The
#> model's intercept is at 4.21 (95% CI [3.41, 5.02]). Within this model:
#> 
#>   - The effect of Petal Length is statistically non-significant and positive
#> (beta = 0.54, 95% CI [-4.76e-03, 1.09], t(144) = 1.96, p = 0.052, Std. beta =
#> 1.16)
#>   - The effect of Species [versicolor] is statistically significant and negative
#> (beta = -1.81, 95% CI [-2.99, -0.62], t(144) = -3.02, p = 0.003, Std. beta =
#> -0.88)
#>   - The effect of Species [virginica] is statistically significant and negative
#> (beta = -3.15, 95% CI [-4.41, -1.90], t(144) = -4.97, p < .001, Std. beta =
#> -1.75)
#>   - The effect of Petal Length × Species [versicolor] is statistically
#> non-significant and positive (beta = 0.29, 95% CI [-0.30, 0.87], t(144) = 0.97,
#> p = 0.334, Std. beta = 0.61)
#>   - The effect of Petal Length × Species [virginica] is statistically
#> non-significant and positive (beta = 0.45, 95% CI [-0.12, 1.03], t(144) = 1.56,
#> p = 0.120, Std. beta = 0.97)

# \donttest{
library(lme4)
model <- lme4::lmer(Sepal.Length ~ Petal.Length + (1 | Species), data = iris)
r <- report_text(model)
r
#> We fitted a linear mixed model (estimated using REML and nloptwrap optimizer)
#> to predict Sepal.Length with Petal.Length (formula: Sepal.Length ~
#> Petal.Length). The model included Species as random effect (formula: ~1 |
#> Species). The model's total explanatory power is substantial (conditional R2 =
#> 0.97) and the part related to the fixed effects alone (marginal R2) is of 0.66.
#> The model's intercept, corresponding to Petal.Length = 0, is at 2.50 (95% CI
#> [1.19, 3.82], t(146) = 3.75, p < .001). Within this model:
#> 
#>   - The effect of Petal Length is statistically significant and positive (beta =
#> 0.89, 95% CI [0.76, 1.01], t(146) = 13.93, p < .001; Std. beta = 1.89, 95% CI
#> [1.63, 2.16])
#> 
#> Standardized parameters were obtained by fitting the model on a standardized
#> version of the dataset. 95% Confidence Intervals (CIs) and p-values were
#> computed using a Wald t-distribution approximation.
summary(r)
#> We fitted a linear mixed model to predict Sepal.Length with Petal.Length. The
#> model included Species as random effect. The model's total explanatory power is
#> substantial (conditional R2 = 0.97) and the part related to the fixed effects
#> alone (marginal R2) is of 0.66. The model's intercept is at 2.50 (95% CI [1.19,
#> 3.82]). Within this model:
#> 
#>   - The effect of Petal Length is statistically significant and positive (beta =
#> 0.89, 95% CI [0.76, 1.01], t(146) = 13.93, p < .001, Std. beta = 1.89)
# }
# \donttest{
# Bayesian models
library(rstanarm)
model <- suppressWarnings(stan_glm(mpg ~ cyl + wt, data = mtcars, refresh = 0, iter = 600))
r <- report_text(model)
r
#> We fitted a Bayesian linear model (estimated using MCMC sampling with 4 chains
#> of 600 iterations and a warmup of 300) to predict mpg with cyl and wt (formula:
#> mpg ~ cyl + wt). Priors over parameters were set as normal (mean = 0.00, SD =
#> 8.44) distributions. The model's explanatory power is substantial (R2 = 0.82,
#> 95% CI [0.72, 0.90], adj. R2 = 0.80). The model's intercept, corresponding to
#> cyl = 0 and wt = 0, is at 39.71 (95% CI [36.25, 42.94]). Within this model:
#> 
#>   - The effect of cyl (Median = -1.49, 95% CI [-2.32, -0.69]) has a 100.00%
#> probability of being negative (< 0), 99.75% of being significant (< -0.30), and
#> 23.00% of being large (< -1.81). The estimation successfully converged (Rhat =
#> 1.003) but the indices are unreliable (ESS = 476)
#>   - The effect of wt (Median = -3.21, 95% CI [-4.71, -1.72]) has a 100.00%
#> probability of being negative (< 0), 100.00% of being significant (< -0.30),
#> and 96.75% of being large (< -1.81). The estimation successfully converged
#> (Rhat = 1.001) but the indices are unreliable (ESS = 484)
#> 
#> Following the Sequential Effect eXistence and sIgnificance Testing (SEXIT)
#> framework, we report the median of the posterior distribution and its 95% CI
#> (Highest Density Interval), along the probability of direction (pd), the
#> probability of significance and the probability of being large. The thresholds
#> beyond which the effect is considered as significant (i.e., non-negligible) and
#> large are |0.30| and |1.81| (corresponding respectively to 0.05 and 0.30 of the
#> outcome's SD). Convergence and stability of the Bayesian sampling has been
#> assessed using R-hat, which should be below 1.01 (Vehtari et al., 2019), and
#> Effective Sample Size (ESS), which should be greater than 1000 (Burkner, 2017).
#> and We fitted a Bayesian linear model (estimated using MCMC sampling with 4
#> chains of 600 iterations and a warmup of 300) to predict mpg with cyl and wt
#> (formula: mpg ~ cyl + wt). Priors over parameters were set as normal (mean =
#> 0.00, SD = 15.40) distributions. The model's explanatory power is substantial
#> (R2 = 0.82, 95% CI [0.72, 0.90], adj. R2 = 0.80). The model's intercept,
#> corresponding to cyl = 0 and wt = 0, is at 39.71 (95% CI [36.25, 42.94]).
#> Within this model:
#> 
#>   - The effect of cyl (Median = -1.49, 95% CI [-2.32, -0.69]) has a 100.00%
#> probability of being negative (< 0), 99.75% of being significant (< -0.30), and
#> 23.00% of being large (< -1.81). The estimation successfully converged (Rhat =
#> 1.003) but the indices are unreliable (ESS = 476)
#>   - The effect of wt (Median = -3.21, 95% CI [-4.71, -1.72]) has a 100.00%
#> probability of being negative (< 0), 100.00% of being significant (< -0.30),
#> and 96.75% of being large (< -1.81). The estimation successfully converged
#> (Rhat = 1.001) but the indices are unreliable (ESS = 484)
#> 
#> Following the Sequential Effect eXistence and sIgnificance Testing (SEXIT)
#> framework, we report the median of the posterior distribution and its 95% CI
#> (Highest Density Interval), along the probability of direction (pd), the
#> probability of significance and the probability of being large. The thresholds
#> beyond which the effect is considered as significant (i.e., non-negligible) and
#> large are |0.30| and |1.81| (corresponding respectively to 0.05 and 0.30 of the
#> outcome's SD). Convergence and stability of the Bayesian sampling has been
#> assessed using R-hat, which should be below 1.01 (Vehtari et al., 2019), and
#> Effective Sample Size (ESS), which should be greater than 1000 (Burkner, 2017).
summary(r)
#> We fitted a Bayesian linear model to predict mpg with cyl and wt. Priors over
#> parameters were set as normal (mean = 0.00, SD = 8.44) distributions. The
#> model's explanatory power is substantial (R2 = 0.82, adj. R2 = 0.80). The
#> model's intercept is at 39.71 (95% CI [36.25, 42.94]). Within this model:
#> 
#>   - The effect of cyl (Median = -1.49, 95% CI [-2.32, -0.69]) has 100.00%, 99.75%
#> and 23.00% probability of being negative (< 0), significant (< -0.30) and large
#> (< -1.81). The estimation successfully converged (Rhat = 1.003) but the indices
#> are unreliable (ESS = 476)
#>   - The effect of wt (Median = -3.21, 95% CI [-4.71, -1.72]) has 100.00%, 100.00%
#> and 96.75% probability of being negative (< 0), significant (< -0.30) and large
#> (< -1.81). The estimation successfully converged (Rhat = 1.001) but the indices
#> are unreliable (ESS = 484) and We fitted a Bayesian linear model to predict mpg
#> with cyl and wt. Priors over parameters were set as normal (mean = 0.00, SD =
#> 15.40) distributions. The model's explanatory power is substantial (R2 = 0.82,
#> adj. R2 = 0.80). The model's intercept is at 39.71 (95% CI [36.25, 42.94]).
#> Within this model:
#> 
#>   - The effect of cyl (Median = -1.49, 95% CI [-2.32, -0.69]) has 100.00%, 99.75%
#> and 23.00% probability of being negative (< 0), significant (< -0.30) and large
#> (< -1.81). The estimation successfully converged (Rhat = 1.003) but the indices
#> are unreliable (ESS = 476)
#>   - The effect of wt (Median = -3.21, 95% CI [-4.71, -1.72]) has 100.00%, 100.00%
#> and 96.75% probability of being negative (< 0), significant (< -0.30) and large
#> (< -1.81). The estimation successfully converged (Rhat = 1.001) but the indices
#> are unreliable (ESS = 484)
# }