Learn R Programming

regtomean (version 1.2)

plot_mu: Plot t-Statistics and p-Values for Intervention Impact

Description

Based on the data before and after the intervention and the regression models from the function meechua_reg, this function plots the t-statistics and p-values for a given range of \(\mu\) to assess whether the intervention has a significant impact on the measurements, accounting for regression to the mean.

Usage

plot_mu(x, n, se_after, lower = F, alpha = 0.05)

Value

A list containing the most significant \(\mu\), t-statistic, p-value, and the range of \(\mu\) for which the treatment impact is significant.

Arguments

x

A data frame containing the results from meechua_reg. Specifically, this should be the mod_coef data frame obtained from meechua_reg.

n

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

se_after

The estimated standard error from meechua_reg. This should be the se_after vector obtained from meechua_reg.

lower

A boolean value specifying the direction of the one-sided tests. For lower = FALSE (the default), it tests whether the intervention is increasing the measurements. For lower = TRUE, it tests whether the second measurements are lower than expected.

alpha

Specifies the significance threshold for the p-values of the corresponding one-sided tests. The default is alpha = 0.05.

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
# Generate example data
language_test <- data.frame(
  Before = rnorm(100, mean = 50, sd = 10),
  After = rnorm(100, mean = 55, sd = 10)
)

mee_chua <- replicate_data(0, 1, "Before", "After", data = language_test)
mee_chua <- mee_chua[order(mee_chua$mu), ]  # Sortieren nach 'mu'

# Regression ausführen und Ergebnisse erhalten
reg_results <- meechua_reg(mee_chua)

# Zugriff auf Ergebnisse
mod_coef <- reg_results$mod_coef
se_after <- reg_results$se_after

# mod_coef and se_after are stored in the environment.
plot_mu(mod_coef, 8, se_after)

Run the code above in your browser using DataLab