# normal data
set.seed(2025)
n <- 100
mu.ind <- rnorm(n, 0, 7)
epsA1 <- rnorm(n, 0, 3)
epsA2 <- rnorm(n, 0, 3)
epsB1 <- rnorm(n, 0, 3)
epsB2 <- rnorm(n, 0, 3)
y_A1 <- 50 + mu.ind + epsA1 # rater A, replicate 1
y_A2 <- 50 + mu.ind + epsA2 # rater A, replicate 2
y_B1 <- 40 + mu.ind + epsB1 # rater B, replicate 1
y_B2 <- 40 + mu.ind + epsB2 # rater B, replicate 2
ex_data <- data.frame(y = c(y_A1, y_A2, y_B1, y_B2),
rater = factor(rep(c("A", "B"), each = 2*n)),
replicate = factor(rep(rep(1:2, each = n), 2)),
subj = factor(rep(1:n, 4)))
descriptive.plots(ex_data, y, subj, rater, replicate, plots = "scatterplot")
descriptive.plots(ex_data, y, subj, rater, replicate, plots = "boxplot",
rater.col = c("blue", "red"), names = rep(c("1st rep.", "2nd rep."), 2),
xlab = "", main = "Boxplots per rater and replicate")
legend("topright", legend = c("A", "B"), fill = c("blue", "red"))
# non-normal data
# involving the measurements
def.par <- par(no.readonly = TRUE)
par(mfcol = c(4, 2), las = 1)
descriptive.plots(AMLad, mrd, id, met, rep, plots = "histogram.y",
ylim = c(0, 120), xlim = c(0, 100),
breaks = seq(from = 0, to = 100, by = 2.5))
descriptive.plots(AMLad, mrd, id, met, rep, plots = "qqplot.y",
ylim = c(0, 8), xlim = c(-3, 3))
par(def.par)
# inolving the paired-differences
def.par <- par(no.readonly = TRUE)
par(mfrow = c(1, 2), las = 1)
descriptive.plots(AMLad, mrd, id, met, rep, plots = "histogram.d",
histogram.d.bw = 2,
ylim = c(0, 0.15), breaks = seq(-20, 100, 5),
xlab = "Paired-differences", main = "",
line.col = "darkred", density.col = "darkred")
descriptive.plots(AMLad, mrd, id, met, rep, plots = "qqplot.d",
ylim = c(-2, 8), xlim = c(-4, 4), main = "")
par(def.par)
Run the code above in your browser using DataLab