data(test_market)
str(test_market)
# Reproduce the published ANCOVA (slope 0.4079, error MS 0.01326, df 14).
fit <- lm(brand_movement ~ panel + block + category_movement,
data = test_market)
coef(fit)["category_movement"]
sum(residuals(fit)^2) / fit$df.residual
# Adjusted panel means at the covariate grand mean.
xbar <- mean(test_market$category_movement)
adj <- vapply(levels(test_market$panel), function(p) {
nd <- data.frame(panel = factor(p, levels = levels(test_market$panel)),
block = factor(1:4, levels = levels(test_market$block)),
category_movement = xbar)
mean(predict(fit, nd))
}, numeric(1))
adj # 3.595 3.619 4.102 4.515 4.618 4.876
# Bryant-Paulson simultaneous 95% intervals (s = 4 blocks => n = 4,
# df 14), every one of them the difference plus or minus 0.278.
ci_c_ancova_bp(adj_means = adj, s_ancova = sqrt(0.01326),
n = 4, num_covariates = 1, df = 14)
Run the code above in your browser using DataLab