Description Usage Arguments Value Examples
Bootstrapped distribution of trial means
1 2 3 4 5 6 7 8 9 | boot_tmeans(
formula = NULL,
data,
R = 500,
var.names = c("y", "trial"),
ci.type = "basic",
level = 0.95,
ncpus = 1
)
|
formula |
standard R formula of the form response ~ trial |
data |
data frame |
R |
number of bootstrap samples |
var.names |
alternative to formula |
ci.type |
type of confidence interval (see boot::boot.ci) |
level |
prediction level |
ncpus |
number of cpus to use, passed to boot, negligible benefit for small datasets |
list with 'dat': data frame with the bootstrapped means,
'boot.ci': confidence interval computed by 'boot.ci'
and 'pdi': prediction interval based on quantiles
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | ## Not run:
require(ggplot2)
data(soyrs)
## Simply calculate the trial means
tmns <- aggregate(lrr ~ Trial_ID, data = soyrs, FUN = mean)
## Bootstrapped stratified trial means
btm <- boot_tmeans(lrr ~ Trial_ID, data = soyrs, R = 2e3)
pdi.cf <- pred_int_conformal_df(formula = lrr ~ Trial_ID, x = soyrs)
btmd <- btm$dat
btm.q <- btm$pdi
ggplot() + xlab("lrr") +
geom_density(data = btmd, aes(x = ys)) +
geom_jitter(data = soyrs, aes(x = lrr, y = 2.5)) +
geom_jitter(data = tmns, aes(x = lrr, y = 5), color = "blue", size = 1.2) +
geom_point(aes(x = pdi.cf[1], y = -1), color = "orange", size = 1.2) +
geom_errorbarh(mapping = aes(xmin = pdi.cf[2], xmax = pdi.cf[3],
y = -1), color = "orange", size = 1.2) +
geom_point(aes(x = btm.q[1], y = -2), color = "red", size = 1.2) +
geom_errorbarh(aes(xmin = btm.q[2], xmax = btm.q[3], y = -2),
color = "red", size = 1.2)
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.