plotCurve: Plots a specification curve.

View source: R/functions.R

plotCurveR Documentation

Plots a specification curve.

Description

plotCurve() takes the data frame output of sca() and produces a ggplot of the independent variable's coefficient (as indicated in the call to sca()) across model specifications. By default a panel is added showing which control variables are present in each model. Note that the ggplot output by this function can only be further customized when 'plotVars = FALSE', i.e. when the control variable panel is not included.

Usage

plotCurve(
  sca_data,
  title = "",
  showIndex = TRUE,
  plotVars = TRUE,
  ylab = "Coefficient",
  plotSE = "bar"
)

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, '""'.

showIndex

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

plotVars

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

ylab

A string to be used as the y-axis label. Defaults to '"Coefficient"'.

plotSE

A string indicating whether to display standard errors as bars or plots. For bars 'plotSE = "bar"', for ribbons 'plotSE = "ribbon"'. If any other value is supplied then no standard errors are included. Defaults to '"bar"'.

Value

If 'plotVars = TRUE' returns a grid grob (i.e. the output of a call to 'grid.draw'). If 'plotVars = FALSE' returns a ggplot object.

Examples

plotCurve(sca_data = sca(y="Salnty", x="T_degC", c("ChlorA", "O2Sat"),
                         data=bottles, progressBar=TRUE, parallel=FALSE),
                     title = "Salinity and Temperature Models",
                     showIndex = TRUE, plotVars = TRUE,
                     ylab = "Coefficient value", plotSE = "ribbon");
plotCurve(sca_data = sca(y="Salnty", x="T_degC",
                         c("ChlorA*O2Sat", "ChlorA", "O2Sat"),
                         data=bottles, progressBar=FALSE, parallel=FALSE),
                     showIndex = TRUE, plotVars = TRUE,
                     plotSE = "ribbon");
plotCurve(sca_data = sca(y="Salnty", x="T_degC",
                         c("ChlorA*NO3uM", "O2Sat", "ChlorA", "NO3uM"),
                         data=bottles,
                         progressBar = TRUE, parallel = TRUE, workers=2),
          plotSE="");

speccurvieR documentation built on Oct. 10, 2024, 1:08 a.m.