# Your turn 25. Do some stores charge higher prices than others for the same items? To study this, the prices of 10 items were found at 4 different stores. Conduct an AxS ANOVA to determine if mean prices differ across stores. To do this, do the following:

**(a)** Load the data and summarize it graphically and numerically.

**(b)** Run a one-way ANOVA (ignoring the fact that we have repeated measures) and state your conclusion.

**(c)** Sketch a profile plot of the prices across stores for each item.

**(d)** Run the AxS ANOVA and state your conclusions.

**(a)** Load the data and summarize it graphically and numerically. ```{r} # Let's save the data in a data.frame called "groceries" groceries <- read.csv("http://www.bradthiessen.com/html5/data/groceries.csv") # Look at the first several rows to see the variables head(groceries) # Calculate summary statistics by store favstats(price ~ store, data=groceries) # Calculate summary statistics by item # Replace the XXXXX values favstats(XXXXX ~ XXXXX, data=XXXXX) # Create side-by-side density plots of the price for each store # Replace the XXXXX values with the appropriate variable names densityplot(~XXXXX | XXXXX, data=groceries, lwd=2, main="Price by store", layout=c(1,4)) ```

**(b)** Run a one-way ANOVA (ignoring the fact that we have repeated measures) and state your conclusion. ```{r} # Our model will be price ~ store # First, run a leveneTest to check for equal variances # Now, run the one way anova with the "aov" command # Store your result in a data.frame called "aov.out" # Summarize the analysis of variance with the "anova" command # Plot the model (assuming it's called "aov.out") plotModel(aov.out) ``` **Write your conclusions here**

**(c)** Sketch a profile plot of the prices across stores for each item. ```{r} # We could do this the ugly way interaction.plot(x.factor=groceries$store, trace.factor=groceries$item, response=groceries$price, fun=mean, type="l", legend=F, xlab = "Grocery Store", ylab = "Average price") # Or with ggplot ggplot(data = groceries, aes(x = store, y = price, group = item)) + ggtitle("Price by store") + ylab("Price") + geom_line() ```

**(d)** Run the AxS ANOVA and state your conclusions. ```{r} # Run the AxS ANOVA # Specifying the error as items nested within store categories # Type the model below by replacing the XXXXX values axs <- aov(XXXXX ~ XXXXX + Error(XXXXX/XXXXX), data=groceries) summary(axs) ``` **Write your conclusions here**