Answer To: STAT XXXXXXXXXXHW#7 Due Date: 4/01/2021 (Thursday) Homework must be submitted to Assignment #7 on...
Sanchi answered on Apr 01 2021
Hypothetical Chemical Experiment
· Preparation of dataset
acid <- factor(rep(c("1", "2"), each = 4))
time <- factor(rep(c("1", "2"), times = 4))
temp <- factor(rep(c("1", "2"), times = 4))
y<- c(7.3, 9.5, 13.8, 15.4, 16, 18.7, 11.3, 14.5,
8.8, 11.3, 15.3, 17.7, 17.9, 20.8, 12, 15.4,
11.7, 14.1, 17.2, 22.3, 22.6, 24.8, 16.9, 18.5,
6.2, 8.3, 11.2, 15.4, 16.8, 17.4, 8.2, 12.5)
results <- data.frame(y, acid, time,temp)
f = c("111", "112", "121","122","211","212","221","222") # treatment levels
k = 8 # number of treatment levels
n = 4 # number of control blocks
tm = gl(k, 1, n*k, factor(f)) # matching treatment
tm
blk = gl(n, k, k*n)
blk
results <- data.frame( blk,tm, y)
· Question 1 Plot the data and comment on your chosen plots.
library(ggplot2)
ggplot(data = results, mapping = aes(x = tm, y = y,group=1)) +
geom_line(aes(color = blk))
· Question2 Fit a block–treatment model to these data and show that the assumptions on the model are approximately satisfied.
Input-
fit.lm = lm(y ~ tm + blk, data = results)
fit.lm
Output-
Call:
lm(formula = y ~ tm + blk, data = results)
Coefficients:
(Intercept) tm112 tm121 tm122 tm211 tm212 tm221
7.131 2.300 5.875 9.200 9.825 11.925 3.600
tm222 blk2 blk3 blk4
6.725 1.588 5.200 -1.312
· Question 3 Suppose that the pre-plan was to calculate a 99% set of pairwise comparisons between the treatment combinations using Tukey’s method, to calculate 99.5% intervals for the comparisons between the levels of A, B and C if these were not involved in interactions and a set of 99% intervals using Scheffé’s method for any other contrasts that look interesting. The overall confidence level would then be at least 96.5%. List any contrasts that you would like to examine further after looking at the plots in part (a).
Input
pairwise$tm
pairwise$blk
Output
> pairwise$tm
diff ...