Learn R Programming

speccurvieR (version 1.0.0)

plot_variance: Plot the variance decomposition of a specification curve

Description

`plot_variance()` visualises [sca_variance()] as a bar chart of the share of the focal coefficient's variance attributable to each control choice (plus a `"Residual"` bar), making it easy to see which modelling choices drive the spread of estimates across the curve.

Usage

plot_variance(
  sca_data,
  estimate = "coef",
  method = c("lmg", "type2"),
  residual = TRUE,
  title = ""
)

Value

A ggplot object.

Arguments

sca_data

A data frame returned by [sca()].

estimate

A string naming the numeric column to decompose. Defaults to `"coef"` (the focal coefficient).

method

One of `"lmg"` (default; LMG/Shapley decomposition of R-squared) or `"type2"` (normalised Type II partial sums of squares). `"shapley"` is an alias for `"lmg"`.

residual

A boolean indicating whether to append a `"Residual"` row for the unexplained (and choice-interaction) variance. Defaults to `TRUE`. When `FALSE`, the control percentages are rescaled to sum to 100.

title

A string used as the plot title. Defaults to `""`.

See Also

[sca_variance()] for the underlying table.

Examples

Run this code
s <- sca(y = "Salnty", x = "T_degC",
         controls = c("ChlorA", "O2Sat", "NO2uM"),
         data = bottles, progress_bar = FALSE, parallel = FALSE)
plot_variance(s)

Run the code above in your browser using DataLab