set.seed(1234)
# Generate data for 4 groups with different group sizes
group1 <- rnorm(10, mean = 5, sd = 0.1)
group2 <- rnorm(20, mean = 5.5, sd = 1)
group3 <- rnorm(30, mean = 6, sd = 0.5)
group4 <- rnorm(40, mean = 6.5, sd = 0.8)
# Combine data into a data frame
data <- data.frame(
value = c(group1, group2, group3, group4),
group = factor(rep(1:4, times = c(10,20,30,40)))
)
# Perform ANOVA
anova_result <- aov(value ~ -1 + group, data = data)
# model/hypothesis
h1 <- 'group1 < group2 < group3 < group4'
h2 <- 'group1 > group2 < group3 < group4'
# fit h1 and h2 model against the unconstrained model (i.e., failsafe to avoid
# selecting a weak hypothesis)
fit_goric <- goric(anova_result, hypotheses = list(H1 = h1, H2 = h2),
comparison = "unconstrained", type = "goric")
# by default: ES = 0 \& ES = observed ES
# In practice you want to increase the number of iterations (default = 1000).
# \donttest{
# multisession supports windows machines
# future::plan(future::multisession, workers = ncpus)
benchmark_results_mean <- benchmark(fit_goric, iter = 10, model_type = "means")
print(benchmark_results_mean)
# }
# by default the ratio of GORIC weights for the preferred hypothesis (here h1) is
# plotted against its competitors (i.e., h2 and the unconstrained). To improve
# the readability of the plot, the argument hypothesis_comparison can be used to
# focus on a specif competitor. Further readability can be achieved by setting
# the x_lim option.
plot(benchmark_results_mean, output_type = "rgw")
# specify custom effect-sizes
# \donttest{
benchmark_results_mean_es <- benchmark(fit_goric, iter = 10,
pop_es = c(0, 0.1),
model_type = "means")
print(benchmark_results_mean_es)
# }
# Benchmark asymptotic estimates
# \donttest{
fit_gorica <- goric(anova_result, hypotheses = list(h1=h1),
comparison = "complement", type = "gorica")
# by default: no-effect \& estimates from the sample are used
benchmark_results_asymp <- benchmark(fit_gorica, sample_size = 30, iter = 5,
model_type = "asymp")
print(benchmark_results_asymp)
# }
# \donttest{
# specify custom population estimates
my_pop_est <- rbind("no" = c(0,0,0,0), "observed"= coef(anova_result))
benchmark_results_asymp <- benchmark(fit_gorica, sample_size = 30,
iter = 5, pop_est = my_pop_est,
model_type = "asymp")
print(benchmark_results_asymp)
plot(benchmark_results_asymp, x_lim = c(0, 75))
# }
Run the code above in your browser using DataLab