Q1

Data Import

t7q1 <- read.table("C:/Users/Wei Hao/Desktop/ST2137/Tutorials/Data/locate.txt", header=T)
attach(t7q1)

Model

model1 <- aov(sales~location)

Computing LSD

group.1 <- sales[location=="F"]
group.2 <- sales[location=="M"]
group.3 <- sales[location=="R"]
group.means <- tapply(sales,location,mean)
treat.group <- cbind(group.1,group.2,group.3)
mse <- sum(model1$res^2)/15
lsd <- qt(0.975,15)*sqrt(mse*2/6)

Function to check if the difference of 2 means is greater than LSD

check.lsd<-function(obj,i,j,lsd){
  mx <- mean(obj[,i])
  my <- mean(obj[,j])
  d <- mx - my
  if(abs(d)>lsd)
    cat("There is siginificant difference between groups",i,"&",j, "\n",
    "Means =",mx,",",my," Diff =", d," > LSD =",lsd,"\n")
  else
    cat("There is no siginificant difference between groups",i,"&",j,"\n",
    "Means =",mx,",",my," Diff =", d," < LSD =",lsd,"\n")
}

Checking For Significant Differences Between Groups

Let \(\mu_1, \mu_2m, \mu_3\) be the average sales for stores with front, middle and rear aisle locations respectively. We are interested to test \(H_0: \mu_1 = \mu_2 = \mu_3\) against \(H_1: \mu_i \neq \mu_j\), for some \(i \neq j\).

check.lsd(treat.group,1,2,lsd)
## There is siginificant difference between groups 1 & 2 
##  Means = 6.066667 , 2.266667  Diff = 3.8  > LSD = 1.600086
check.lsd(treat.group,1,3,lsd)
## There is siginificant difference between groups 1 & 3 
##  Means = 6.066667 , 3.733333  Diff = 2.333333  > LSD = 1.600086
check.lsd(treat.group,2,3,lsd)
## There is no siginificant difference between groups 2 & 3 
##  Means = 2.266667 , 3.733333  Diff = -1.466667  < LSD = 1.600086
contrasts(location) <- matrix(c(0,-1,1,2,-1,-1), nrow=3)
contrasts(location)
##   [,1] [,2]
## F    0    2
## M   -1   -1
## R    1   -1
modelc<-aov(sales~location)
summary.lm(modelc)
## 
## Call:
## aov(formula = sales ~ location)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -2.06667 -0.86667 -0.06667  0.73333  2.53333 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept)   4.0222     0.3065  13.124 1.26e-09 ***
## location1     0.7333     0.3754   1.954 0.069643 .  
## location2     1.0222     0.2167   4.717 0.000275 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 1.3 on 15 degrees of freedom
## Multiple R-squared:  0.6347, Adjusted R-squared:  0.586 
## F-statistic: 13.03 on 2 and 15 DF,  p-value: 0.0005242

Q1(a)

Test statistic \(F = 13.03\), p-value \(= 0.0005\). Since \(F_{obs} = 13.03\) is above the critical bound of \(F = 3.68\), reject \(H_0\). Alternatively, the p-value is smaller than \(0.05\), so we reject \(H_0\). There is enough evidence to conclude that the average sales volumes in thousands of dollars are different across the three store aisle locations.

Q1(b)

We see that \(|\bar{x_1 } - \bar{x_2 } | > LSD\) and \(|\bar{x_1 } - \bar{x_3 } | > LSD\) so the front aisle location is different from the other two locations while the middle and rear locations are not different in terms of the average sales volumes.

Other Sub-Questions

See SAS code outputs and solutions.