Learn R Programming

regtomean (version 1.2)

plot_t: Plot Results for p-values and t-values

Description

This function plots the t-statistics and p-values for a range of \(\mu\) values, based on the provided data and regression models. It helps visualize whether the intervention has a significant impact on the measurements, accounting for regression to the mean.

Usage

plot_t(
  mu_start,
  mu_end,
  n,
  y1_mean,
  y2_mean,
  y1_std,
  y2_std,
  cov,
  lower = F,
  alpha = 0.05,
  r_insteadof_cov = F
)

Value

A ggplot2 plot with two y-axes: one showing p-values and the other showing t-statistics. The function also prints key values including the most significant \(\mu\), the minimal p-value, and the range of \(\mu\) where the treatment effect is significant.

Arguments

mu_start

Numeric. The starting value of \(\mu\) for the range of values to be plotted.

mu_end

Numeric. The ending value of \(\mu\) for the range of values to be plotted.

n

Numeric. The original sample size (number of observations) of the data.

y1_mean

Numeric. The mean of the first measurement.

y2_mean

Numeric. The mean of the second measurement.

y1_std

Numeric. The standard deviation of the first measurement.

y2_std

Numeric. The standard deviation of the second measurement.

cov

Numeric. The covariance between the two measurements, or if r_insteadof_cov is TRUE, the correlation coefficient.

lower

Logical. If TRUE, the function tests whether the second measurements are lower than expected. If FALSE (the default), it tests whether the intervention is increasing the measurements.

alpha

Numeric. The significance threshold for the p-values of the one-sided tests. The default is 0.05.

r_insteadof_cov

Logical. If TRUE, cov is interpreted as the correlation coefficient instead of the covariance. Default is FALSE.

Author

Julian Stein

References

Ostermann, T., Willich, S. N., & Luedtke, R. (2008). Regression toward the mean - a detection method for unknown population mean based on Mee and Chua's algorithm. BMC Medical Research Methodology.

Examples

Run this code
# Example usage of the plot_t function
plot_t(
  mu_start = 0, mu_end = 10, n = 50, y1_mean = 5, 
  y2_mean = 5, y1_std = 2, y2_std = 2, cov = 0.5
)

plot_t(
  mu_start = 0, mu_end = 10, n = 50, y1_mean = 5, 
  y2_mean = 5, y1_std = 2, y2_std = 2, cov = 0.5, 
  lower = TRUE, alpha = 0.1
)

Run the code above in your browser using DataLab