plot.replext_gls: Plot Results from Replications and Extension of GLS...

View source: R/replext_gls.R

plot.replext_glsR Documentation

Plot Results from Replications and Extension of GLS Simulation

Description

This method creates a ggplot2 visualization of results from a replext_gls object. It allows for flexible plotting of different metrics across various conditions.

Usage

## S3 method for class 'replext_gls'
plot(
  x,
  term,
  metric = "rejection_rates",
  x_axis = "tppp",
  color = "rho",
  title = NULL,
  x_label = NULL,
  y_label = NULL,
  ...
)

Arguments

x

An object of class "replext_gls", typically the output from replext_gls().

term

Character. The name of the model term to plot.

metric

Character. The metric to plot on the y-axis. Default is "rejection_rates". Other options include "mean_estimates", "mean_bias", etc.

x_axis

Character. The variable to plot on the x-axis. Default is "tppp" (time points per phase).

color

Character. The variable to use for color grouping. Default is "rho" (autocorrelation parameter).

title

Character. The plot title. If NULL, a default title is generated.

x_label

Character. The x-axis label. If NULL, a default label is generated.

y_label

Character. The y-axis label. If NULL, a default label is generated.

...

Pass extra arguments to ggplot.

Details

This method creates a line plot with points, where each line represents a different level of the color variable (default is rho). If the metric is "rejection_rates", error bars are added to represent the standard error of the rejection rates.

Value

A ggplot2 object representing the plot.

Examples

results <- replext_gls(
  n_timepoints_list = c(10),
  rho_list = c(0.2),
  iterations = 10,
  betas = c("(Intercept)" = 0, "phase1" = 1),
  formula = y ~ phase
)
plot(results, term = "phase1", metric = "rejection_rates")


scdtb documentation built on Sept. 30, 2024, 9:35 a.m.