# Part I Select two explanatory independent variables

### Part I Select two explanatory independent variables

Part I

1. Select two explanatory (independent) variables (factors) from your dataset that comprise no more than eight different treatment combinations (if you need to collapse a variable to achieve the maximum of eight treatment combinations - ask your tutor for assistance).

The selected explanatory (independent) variables are;

• Day of the Week (7 factors)

• Store (4 factors)

1. Select a response (dependent) variable (a continuous variable) you find interesting.

The selected response (dependent) variable is;

• Price (cents)

1. For each treatment combination, randomly pick five replicates from your dataset (there will be a total of 40 observations if you have eight treatment combinations, for example)

For the day of the week we have;

 Monday Tuesday Wednesday Thursday Friday Saturday Sunday 152.9 145.8 149.7 139.9 159.9 159.9 141.3 157.9 157.9 150.9 159.9 151.9 159.9 151.4 157.9 152.9 149.9 159.9 159.9 159 151.4 159.9 150.9 153.7 159.9 141.9 158.8 155 155.1 157.9 151.9 149.7 151.9 159.9 159.9

For the Store we have;

 BP 7-Eleven Caltex Shell 141.3 152.9 159.9 159.9 157.9 149.7 151.9 159 139.9 151.4 159.9 159.9 151.4 159.9 155 159.9 145.8 152.9 159.9 151.9

1. In Part I of your report clearly state and describe/explain the two explanatory variables and the response variable you have selected. Present the observations (data) you randomly selected (there must be no more than forty observations in total.)

Results shown above

Part II

Corresponding to the variables you have selected in Part I:

Clearly state:

1. The research question you will answer;

Is there a statistically significant difference on price by day of the week and store?

1. The statistical hypotheses you will be testing (list all hypotheses - interaction hypothesis and the main effects hypotheses).

H10: There is no statistically significant difference on price by day of the week

H1A: There is a statistically significant difference on price by day of the week

H20: There is no statistically significant difference on price by store

H2A: There is a statistically significant difference on price by store

H30: There is no statistically significant difference on price by interaction between day of the week and store

H3A: There is a statistically significant difference on price by interaction between day of the week and store

1. The preliminary and factorial models for your selected variables. Describe in full detail all components of the preliminary and factorial models;

The components of the factorial model are;

Day of the week; this is a main effect treatment and the model will seek to determine whether the 6 factors vary in terms of their average price.

Store; this is another main effect treatment and the model will seek to determine whether the 4 factors vary in terms of their average price.

The other component that is within this factorial model is the interaction between day of the week and the store. How does the interaction of the two variables influence the price?

1. The preliminary and factorial projected ANOVAs

The preliminary and factorial projected ANOVAs include;

 Source of variance DF Sum Square Mean Square F-Value Day of the week 7-1 = 6 SSD Store 4-1 = 3 SSS Day of the week * Store 6*3 = 18 SSDS Residuals 142 SSR

Part III

Carry out the analysis using R.

Clearly present:

1. the relevant R code and output (i.e the aov (and LSD if appropriate) code from the script file and the ANOVA (and LSD if appropriate) results from the output);

> model = aov(Price..cents.~ Day.of.the.Week*Store, data=data)

> summary(model)

Df Sum Sq Mean Sq F value Pr(>F)

Day.of.the.Week 6 316.7 52.79 2.510 0.0244 *

Store 3 94.8 31.61 1.503 0.2163

Day.of.the.Week:Store 14 180.9 12.92 0.614 0.8498

Residuals 142 2986.5 21.03

---

Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

2 observations deleted due to missingness

1. The results of your hypothesis testing;

Results of the factorial test above showed that there is a statistically significant difference on price by day of the week (p < 0.05). However, there was no statistically significant difference on price by store neither was there statistically significant difference on price by interaction between day of the week and store (p > 0.05).

1. An interpretation of the results. [If you find a significant interaction, present and interpret an interaction plot. If there is no interaction but one or both of the main effects are significant, determine which means differ using LSD in R and discuss. If you find no significant results, discuss why this may be so.]

>out=LSD.test(model, "Day.of.the.Week")

>out

\$statistics

Mean CV MSerror

155.203 2.954862 21.03172

\$parameters

Df ntr t.value alpha test name.t

142 7 1.976811 0.05 Fisher-LSD Day.of.the.Week

\$means

Price..cents. std r LCL UCL Min Max

Friday 155.9958 4.848799 24 154.1453 157.8464 141.9 159.9

Monday 156.6292 3.910241 24 154.7786 158.4797 143.9 159.9

Saturday 156.7913 3.997148 23 154.9010 158.6816 151.4 159.9

Sunday 154.4391 4.793911 23 152.5488 156.3295 141.3 159.9

Thursday 153.2542 6.586744 24 151.4036 155.1047 138.7 159.9

Tuesday 155.9375 3.544599 24 154.0870 157.7880 145.8 159.9

Wednesday 153.4083 3.134093 24 151.5578 155.2589 149.7 159.9

\$comparison

NULL

\$groups

trt means M

1 Saturday 156.7913 a

2 Monday 156.6292 a

3 Friday 155.9958 ab

4 Tuesday 155.9375 ab

5 Sunday 154.4391 abc

6 Wednesday 153.4083 bc

7 Thursday 153.2542 c

The post-hoc analysis using LSD showed that there is significant difference in the average price for the different days of the week. For instance, there is significant difference in the mean between Saturday and Sunday, Saturday and Thursday and also between Saturday and Wednesday.

Rcodes

str(data)

attach(data)

install.packages("agricolae")

library(agricolae)

model = aov(Price..cents.~ Day.of.the.Week*Store, data=data)

summary(model)

ut=LSD.test(model, "Day.of.the.Week")

out