Learn R Programming

speccurvieR (version 1.0.0)

plot_r2_adj: Plots the adj. R-squared across model specifications.

Description

plot_r2_adj() plots the adjusted R-squared across model specifications. Only available for linear regression models. Note when fixed effects are are specified the within adjusted R-squared is used (i.e. `fixest::r2()` with `type="war2"`).

Usage

plot_r2_adj(sca_data, title = "", show_index = TRUE, plot_vars = TRUE)

Value

If `plot_vars = TRUE` a `patchwork` object combining the plot and the variable panel; if `plot_vars = FALSE` a ggplot object.

Arguments

sca_data

A data frame returned by `sca()` containing model estimates from the specification curve analysis.

title

A string to use as the plot title. Defaults to an empty string, `""`.

show_index

A boolean indicating whether to label the model index on the the x-axis. Defaults to `TRUE`.

plot_vars

A boolean indicating whether to include a panel on the plot showing which variables are present in each model. Defaults to `TRUE`.

Examples

Run this code
plot_r2_adj(sca_data = sca(y = "Salnty", x = "T_degC",
                         controls = c("ChlorA", "O2Sat"),
                         data = bottles, progress_bar = TRUE,
                         parallel = FALSE),
                     title = "Adjusted R^2");
plot_r2_adj(sca_data = sca(y="Salnty", x="T_degC",
                         controls = c("ChlorA*O2Sat"),
                         data = bottles, progress_bar = FALSE,
                         parallel = FALSE),
                     show_index = FALSE, plot_vars = FALSE);
# \donttest{
plot_r2_adj(sca_data = sca(y = "Salnty", x = "T_degC",
                         controls = c("ChlorA*NO3uM", "O2Sat*NO3uM"),
                         data = bottles,
                         progress_bar = TRUE, parallel = TRUE, workers = 2));
# }

Run the code above in your browser using DataLab