Factorial (2 or more Way) ANOVA - A factorial ANOVA is an Analysis of Variance test with more than one independent variable.

The data set from the first class contains another column that includes whether the valuation was made for a product or gamble so we have data that we can analyze using a factorial ANOVA.

For example, if we are interested in the effects of Perspective and Item Type and their potential interaction effects, we would set up our experiment so that each factor is present at each other factors levels TAble- Chooser Buyer Seller Product CP BP SP Gamble CG BG SG

Procedure - 1. Propose a research question(s) based on your questions. 2. Perform a (or more) hypotheses 3. Check the assumptions 4. Perform tests 5. Make conclusions based on the finding.

setwd("E:\\mikhilesh\\HU Sem VI ANLY 510 and 506\\ANLY 510 Kao Principals and Applications\\Lecture and other materials")
library(readxl)
## Warning: package 'readxl' was built under R version 3.6.3
data4 <- read_excel("Lecture 4 ANOVAExample2.xlsx")
names(data4)
## [1] "Valuation"       "ProductorGamble" "Condition"       "Session"
str(data4)
## Classes 'tbl_df', 'tbl' and 'data.frame':    240 obs. of  4 variables:
##  $ Valuation      : num  7 0 2 10 6 5 13 10 4 9 ...
##  $ ProductorGamble: chr  "Product" "Gamble" "Product" "Gamble" ...
##  $ Condition      : chr  "Chooser" "Chooser" "Chooser" "Chooser" ...
##  $ Session        : num  1 2 3 1 2 3 1 2 3 1 ...
summary(data4)
##    Valuation      ProductorGamble     Condition            Session 
##  Min.   : 0.000   Length:240         Length:240         Min.   :1  
##  1st Qu.: 4.000   Class :character   Class :character   1st Qu.:1  
##  Median : 6.000   Mode  :character   Mode  :character   Median :2  
##  Mean   : 6.229                                         Mean   :2  
##  3rd Qu.: 9.000                                         3rd Qu.:3  
##  Max.   :16.000                                         Max.   :3

Assumptions

library(moments)
plot(density(data4$Valuation), main = "Density Plot")

qqnorm(data4$Valuation)

agostino.test(data4$Valuation) #    D'Agostino skewness test
## 
##  D'Agostino skewness test
## 
## data:  data4$Valuation
## skew = 0.10977, z = 0.71253, p-value = 0.4761
## alternative hypothesis: data have a skewness
shapiro.test(data4$Valuation) # Shapiro-Wilk normality test
## 
##  Shapiro-Wilk normality test
## 
## data:  data4$Valuation
## W = 0.97406, p-value = 0.0002225
anscombe.test(data4$Valuation) #    Anscombe-Glynn kurtosis test
## 
##  Anscombe-Glynn kurtosis test
## 
## data:  data4$Valuation
## kurt = 2.3083, z = -3.2073, p-value = 0.00134
## alternative hypothesis: kurtosis is not equal to 3
#Residual plot (lm - linear model)
valuation.lm <- lm(Valuation ~ Condition, data = data4)
valuation.lm
## 
## Call:
## lm(formula = Valuation ~ Condition, data = data4)
## 
## Coefficients:
##      (Intercept)  ConditionChooser   ConditionSeller  
##            4.400             2.150             3.338
summary(valuation.lm)
## 
## Call:
## lm(formula = Valuation ~ Condition, data = data4)
## 
## Residuals:
##    Min     1Q Median     3Q    Max 
## -7.737 -2.438 -0.400  2.487  8.600 
## 
## Coefficients:
##                  Estimate Std. Error t value Pr(>|t|)    
## (Intercept)        4.4000     0.3820  11.519  < 2e-16 ***
## ConditionChooser   2.1500     0.5402   3.980 9.17e-05 ***
## ConditionSeller    3.3375     0.5402   6.178 2.80e-09 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 3.417 on 237 degrees of freedom
## Multiple R-squared:  0.142,  Adjusted R-squared:  0.1348 
## F-statistic: 19.61 on 2 and 237 DF,  p-value: 1.31e-08
valuation.res <- resid(valuation.lm) #OR valuation.res <- residuals(valuation.lm)
valuation.res
##       1       2       3       4       5       6       7       8       9      10 
##  0.4500 -6.5500 -4.5500  3.4500 -0.5500 -1.5500  6.4500  3.4500 -2.5500  2.4500 
##      11      12      13      14      15      16      17      18      19      20 
##  3.4500  3.4500 -1.5500 -6.5500  4.4500  3.4500 -5.5500  2.4500 -3.5500 -6.5500 
##      21      22      23      24      25      26      27      28      29      30 
## -0.5500 -1.5500 -1.5500 -1.5500 -0.5500 -4.5500  5.4500 -5.5500  1.4500 -1.5500 
##      31      32      33      34      35      36      37      38      39      40 
##  5.4500 -5.5500 -2.5500 -6.5500 -0.5500 -1.5500  4.4500  0.4500 -0.5500  2.4500 
##      41      42      43      44      45      46      47      48      49      50 
##  0.4500 -2.5500  5.4500 -0.5500  5.4500  0.4500  1.4500  0.4500  0.4500 -0.5500 
##      51      52      53      54      55      56      57      58      59      60 
##  3.4500 -0.5500  3.4500  1.4500 -3.5500  4.4500 -0.5500 -0.5500  1.4500  2.4500 
##      61      62      63      64      65      66      67      68      69      70 
## -4.5500 -5.5500  0.4500  3.4500  0.4500  4.4500  1.4500 -2.5500 -1.5500  0.4500 
##      71      72      73      74      75      76      77      78      79      80 
##  0.4500  0.4500 -0.5500  1.4500 -0.5500 -2.5500  5.4500  2.4500  2.4500 -6.5500 
##      81      82      83      84      85      86      87      88      89      90 
## -0.4000 -2.4000 -3.4000 -2.4000  1.6000 -2.4000 -0.4000 -1.4000  1.6000 -4.4000 
##      91      92      93      94      95      96      97      98      99     100 
##  2.6000 -2.4000  1.6000 -2.4000 -2.4000 -2.4000  3.6000 -4.4000 -0.4000 -0.4000 
##     101     102     103     104     105     106     107     108     109     110 
##  3.6000 -2.4000  4.6000 -2.4000  2.6000 -2.4000 -1.4000 -4.4000  5.6000 -4.4000 
##     111     112     113     114     115     116     117     118     119     120 
##  2.6000 -2.4000  5.6000 -4.4000  1.6000  3.6000 -0.4000 -3.4000 -2.4000 -2.4000 
##     121     122     123     124     125     126     127     128     129     130 
##  6.6000 -4.4000 -4.4000  0.6000  1.6000  2.6000 -1.4000 -4.4000  0.6000  2.6000 
##     131     132     133     134     135     136     137     138     139     140 
##  2.6000 -0.4000  5.6000  0.6000  0.6000 -0.4000  5.6000 -4.4000 -4.4000 -2.4000 
##     141     142     143     144     145     146     147     148     149     150 
##  8.6000  3.6000  3.6000 -1.4000 -0.4000  1.6000  4.6000 -3.4000 -0.4000 -2.4000 
##     151     152     153     154     155     156     157     158     159     160 
## -1.4000 -3.4000  5.6000  4.6000  1.6000  0.6000 -3.4000  4.6000  2.6000 -4.4000 
##     161     162     163     164     165     166     167     168     169     170 
##  2.2625 -7.7375  1.2625 -1.7375 -2.7375 -0.7375  1.2625 -5.7375  4.2625 -1.7375 
##     171     172     173     174     175     176     177     178     179     180 
##  3.2625 -5.7375 -3.7375  2.2625 -0.7375 -3.7375  2.2625  2.2625  1.2625  0.2625 
##     181     182     183     184     185     186     187     188     189     190 
##  3.2625 -3.7375  0.2625 -4.7375 -0.7375 -2.7375  2.2625 -2.7375  7.2625 -1.7375 
##     191     192     193     194     195     196     197     198     199     200 
##  3.2625 -1.7375 -2.7375 -3.7375  1.2625  3.2625 -3.7375 -5.7375  2.2625 -4.7375 
##     201     202     203     204     205     206     207     208     209     210 
##  1.2625  0.2625  5.2625 -1.7375  5.2625 -1.7375  1.2625 -1.7375  1.2625 -6.7375 
##     211     212     213     214     215     216     217     218     219     220 
## -1.7375 -6.7375  8.2625  0.2625  2.2625  3.2625  6.2625  2.2625  7.2625  3.2625 
##     221     222     223     224     225     226     227     228     229     230 
## -3.7375  3.2625  5.2625 -2.7375  5.2625 -2.7375 -2.7375 -2.7375  0.2625 -2.7375 
##     231     232     233     234     235     236     237     238     239     240 
##  1.2625  2.2625  3.2625 -3.7375  4.2625  0.2625 -1.7375 -0.7375  3.2625 -2.7375
plot(data4$Valuation, valuation.res, ylab = "Residual", xlab = "Condition", main = "Independence of Observation")
abline(0, 0)

bartlett.test(data4$Valuation , data4$Condition)
## 
##  Bartlett test of homogeneity of variances
## 
## data:  data4$Valuation and data4$Condition
## Bartlett's K-squared = 0.57097, df = 2, p-value = 0.7516
# Variance are equal. p-value = 0.7516 failed to reject the null hypothesis

#Checking variance among groups
tapply(data4$Valuation , data4$Condition, var)
##    Buyer  Chooser   Seller 
## 10.87595 11.33924 12.80364
#ratio of largest variance to smallest variance 12.80/10.87 = 1.17 - is way less than 3 (signifies that there is no issue with failing to reject null hypothesis)

#After checking all the assumptions fulfill our criteria, now we will perform ANOVA with Blocking Design

#IV - ProductorGamble Condition Session (predictor) categorical
#DV - valuation (outcome) continuous

#Testing Additivity of Interactions - To check there is no interaction between predictor/IV - conditions and block - age (Interaction variable - factor(Condition)*factor(Age))
#Perform the linear model: 
model1 <- aov(Valuation ~ Condition*ProductorGamble, data = data4) #we use first predictor*second predictor to test (add) the most important interaction effect. If we have significant interaction effect, we consider the interaction effect and go back to check the main effect.
model1
## Call:
##    aov(formula = Valuation ~ Condition * ProductorGamble, data = data4)
## 
## Terms:
##                 Condition ProductorGamble Condition:ProductorGamble Residuals
## Sum of Squares   457.9083        429.3375                   52.6750 2284.4750
## Deg. of Freedom         2               1                         2       234
## 
## Residual standard error: 3.124534
## Estimated effects may be unbalanced
summary(model1) 
##                            Df Sum Sq Mean Sq F value   Pr(>F)    
## Condition                   2  457.9   229.0  23.452 5.21e-10 ***
## ProductorGamble             1  429.3   429.3  43.977 2.28e-10 ***
## Condition:ProductorGamble   2   52.7    26.3   2.698   0.0695 .  
## Residuals                 234 2284.5     9.8                     
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
#Interaction effect - looks almost significant at p-value < 0.1 level but not at < 0.05 level

#lets check the main effects - condition and productorgamble
model2 <- aov(Valuation ~ Condition, data = data4)
model2
## Call:
##    aov(formula = Valuation ~ Condition, data = data4)
## 
## Terms:
##                 Condition Residuals
## Sum of Squares   457.9083 2766.4875
## Deg. of Freedom         2       237
## 
## Residual standard error: 3.416569
## Estimated effects may be unbalanced
summary(model2)
##              Df Sum Sq Mean Sq F value   Pr(>F)    
## Condition     2  457.9  228.95   19.61 1.31e-08 ***
## Residuals   237 2766.5   11.67                     
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
#Effect of Condition is signifiacnt

#OTHER MOdels FOR COmparison
model3 <- aov(Valuation ~ ProductorGamble, data = data4)
model3
## Call:
##    aov(formula = Valuation ~ ProductorGamble, data = data4)
## 
## Terms:
##                 ProductorGamble Residuals
## Sum of Squares         429.3375 2795.0583
## Deg. of Freedom               1       238
## 
## Residual standard error: 3.426944
## Estimated effects may be unbalanced
summary(model3)
##                  Df Sum Sq Mean Sq F value   Pr(>F)    
## ProductorGamble   1  429.3   429.3   36.56 5.69e-09 ***
## Residuals       238 2795.1    11.7                     
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
#Effect of ProductorGamble is also signifiacnt

#Now that we know both of our predictors are significant, we put them together in our final model
model4 <- aov(Valuation ~ ProductorGamble + Condition, data = data4)
model4
## Call:
##    aov(formula = Valuation ~ ProductorGamble + Condition, data = data4)
## 
## Terms:
##                 ProductorGamble Condition Residuals
## Sum of Squares         429.3375  457.9083 2337.1500
## Deg. of Freedom               1         2       236
## 
## Residual standard error: 3.146932
## Estimated effects may be unbalanced
summary(model4)
##                  Df Sum Sq Mean Sq F value   Pr(>F)    
## ProductorGamble   1  429.3   429.3   43.35 2.93e-10 ***
## Condition         2  457.9   229.0   23.12 6.77e-10 ***
## Residuals       236 2337.1     9.9                     
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
#Using Chi Sq Test to check the difference between each model and we use the residual part to decide which model is better
comparison1 <- anova(model2, model3)
comparison1 #no significant difference (p-value > 0.05)
## Analysis of Variance Table
## 
## Model 1: Valuation ~ Condition
## Model 2: Valuation ~ ProductorGamble
##   Res.Df    RSS Df Sum of Sq      F Pr(>F)
## 1    237 2766.5                           
## 2    238 2795.1 -1   -28.571 2.4476  0.119
#results suggest no significant differenc between model 2 and 3
comparison2 <- anova(model3, model4)
comparison2 #significant difference nted (p-value < 0.05)
## Analysis of Variance Table
## 
## Model 1: Valuation ~ ProductorGamble
## Model 2: Valuation ~ ProductorGamble + Condition
##   Res.Df    RSS Df Sum of Sq      F    Pr(>F)    
## 1    238 2795.1                                  
## 2    236 2337.2  2    457.91 23.119 6.775e-10 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
#results suggest significant differenc between model 3 and 4

#SO we should include both the predictors productorgamble and conditions in out model
graph <- interaction.plot(data4$Condition, data4$ProductorGamble, data4$Valuation)

graph #demonstrate not significant interaction effect
## NULL
#To find out what group differs from the others
library(pgirmess)
## Warning: package 'pgirmess' was built under R version 3.6.3
#Tukey’s Test: compare all the potential combination chooser at gamble level with buyer at gamble level
TukeyHSD(model2) #for two way/factorial anova (predictors - Condition and ProductorGamble)
##   Tukey multiple comparisons of means
##     95% family-wise confidence level
## 
## Fit: aov(formula = Valuation ~ Condition, data = data4)
## 
## $Condition
##                  diff         lwr      upr     p adj
## Chooser-Buyer  2.1500  0.87590343 3.424097 0.0002695
## Seller-Buyer   3.3375  2.06340343 4.611597 0.0000000
## Seller-Chooser 1.1875 -0.08659657 2.461597 0.0735348
TukeyHSD(model1) #for one way anova (predictor - Condition)
##   Tukey multiple comparisons of means
##     95% family-wise confidence level
## 
## Fit: aov(formula = Valuation ~ Condition * ProductorGamble, data = data4)
## 
## $Condition
##                  diff       lwr      upr     p adj
## Chooser-Buyer  2.1500 0.9847137 3.315286 0.0000598
## Seller-Buyer   3.3375 2.1722137 4.502786 0.0000000
## Seller-Chooser 1.1875 0.0222137 2.352786 0.0446738
## 
## $ProductorGamble
##                 diff      lwr      upr p adj
## Product-Gamble 2.675 1.880288 3.469712     0
## 
## $`Condition:ProductorGamble`
##                                  diff        lwr      upr     p adj
## Chooser:Gamble-Buyer:Gamble     2.950  0.9423887 4.957611 0.0004916
## Seller:Gamble-Buyer:Gamble      3.025  1.0173887 5.032611 0.0003167
## Buyer:Product-Buyer:Gamble      3.000  0.9923887 5.007611 0.0003671
## Chooser:Product-Buyer:Gamble    4.350  2.3423887 6.357611 0.0000000
## Seller:Product-Buyer:Gamble     6.650  4.6423887 8.657611 0.0000000
## Seller:Gamble-Chooser:Gamble    0.075 -1.9326113 2.082611 0.9999980
## Buyer:Product-Chooser:Gamble    0.050 -1.9576113 2.057611 0.9999997
## Chooser:Product-Chooser:Gamble  1.400 -0.6076113 3.407611 0.3432708
## Seller:Product-Chooser:Gamble   3.700  1.6923887 5.707611 0.0000040
## Buyer:Product-Seller:Gamble    -0.025 -2.0326113 1.982611 1.0000000
## Chooser:Product-Seller:Gamble   1.325 -0.6826113 3.332611 0.4069019
## Seller:Product-Seller:Gamble    3.625  1.6173887 5.632611 0.0000068
## Chooser:Product-Buyer:Product   1.350 -0.6576113 3.357611 0.3851503
## Seller:Product-Buyer:Product    3.650  1.6423887 5.657611 0.0000057
## Seller:Product-Chooser:Product  2.300  0.2923887 4.307611 0.0144395
library(pastecs)
## Warning: package 'pastecs' was built under R version 3.6.3
library(compute.es)
## Warning: package 'compute.es' was built under R version 3.6.3
#First get the relevant stats for each factor level (only relevant output pasted below):
by(data4$Valuation, data4$Condition, stat.desc)
## data4$Condition: Buyer
##      nbr.val     nbr.null       nbr.na          min          max        range 
##   80.0000000   11.0000000    0.0000000    0.0000000   13.0000000   13.0000000 
##          sum       median         mean      SE.mean CI.mean.0.95          var 
##  352.0000000    4.0000000    4.4000000    0.3687131    0.7339051   10.8759494 
##      std.dev     coef.var 
##    3.2978704    0.7495160 
## ------------------------------------------------------------ 
## data4$Condition: Chooser
##      nbr.val     nbr.null       nbr.na          min          max        range 
##   80.0000000    5.0000000    0.0000000    0.0000000   13.0000000   13.0000000 
##          sum       median         mean      SE.mean CI.mean.0.95          var 
##  524.0000000    7.0000000    6.5500000    0.3764844    0.7493735   11.3392405 
##      std.dev     coef.var 
##    3.3673789    0.5141036 
## ------------------------------------------------------------ 
## data4$Condition: Seller
##      nbr.val     nbr.null       nbr.na          min          max        range 
##   80.0000000    1.0000000    0.0000000    0.0000000   16.0000000   16.0000000 
##          sum       median         mean      SE.mean CI.mean.0.95          var 
##  619.0000000    8.0000000    7.7375000    0.4000569    0.7962933   12.8036392 
##      std.dev     coef.var 
##    3.5782173    0.4624514
#n - sample size, M - mean, SD - standard deviation 
#Buyer (n = 80, M = 4.40 , SD = 3.29) 
#Chooser (n = 80, M = 6.55, SD = 3.36)
#Seller (n = 80, M = 7.73, SD = 3.57)

#Use these values to compute a few standard Measures of Effect Size (MES or mes) for any pair of interest 

#OPtion 1 will compare buyer vs chooser ~ valuation vs Condition
mes(6.55, 4.40, 3.36, 3.29, 80, 80)
## Mean Differences ES: 
##  
##  d [ 95 %CI] = 0.65 [ 0.33 , 0.96 ] 
##   var(d) = 0.03 
##   p-value(d) = 0 
##   U3(d) = 74.1 % 
##   CLES(d) = 67.62 % 
##   Cliff's Delta = 0.35 
##  
##  g [ 95 %CI] = 0.64 [ 0.33 , 0.96 ] 
##   var(g) = 0.03 
##   p-value(g) = 0 
##   U3(g) = 74.01 % 
##   CLES(g) = 67.55 % 
##  
##  Correlation ES: 
##  
##  r [ 95 %CI] = 0.31 [ 0.16 , 0.44 ] 
##   var(r) = 0 
##   p-value(r) = 0 
##  
##  z [ 95 %CI] = 0.32 [ 0.16 , 0.48 ] 
##   var(z) = 0.01 
##   p-value(z) = 0 
##  
##  Odds Ratio ES: 
##  
##  OR [ 95 %CI] = 3.23 [ 1.82 , 5.75 ] 
##   p-value(OR) = 0 
##  
##  Log OR [ 95 %CI] = 1.17 [ 0.6 , 1.75 ] 
##   var(lOR) = 0.09 
##   p-value(Log OR) = 0 
##  
##  Other: 
##  
##  NNT = 4.49 
##  Total N = 160
#OPtion 2 will compare choser vs seller ~ valuation vs Condition
mes(7.73, 6.55, 3.57, 3.36, 80, 80)
## Mean Differences ES: 
##  
##  d [ 95 %CI] = 0.34 [ 0.03 , 0.65 ] 
##   var(d) = 0.03 
##   p-value(d) = 0.03 
##   U3(d) = 63.32 % 
##   CLES(d) = 59.51 % 
##   Cliff's Delta = 0.19 
##  
##  g [ 95 %CI] = 0.34 [ 0.03 , 0.65 ] 
##   var(g) = 0.03 
##   p-value(g) = 0.03 
##   U3(g) = 63.26 % 
##   CLES(g) = 59.47 % 
##  
##  Correlation ES: 
##  
##  r [ 95 %CI] = 0.17 [ 0.01 , 0.32 ] 
##   var(r) = 0.01 
##   p-value(r) = 0.03 
##  
##  z [ 95 %CI] = 0.17 [ 0.01 , 0.33 ] 
##   var(z) = 0.01 
##   p-value(z) = 0.03 
##  
##  Odds Ratio ES: 
##  
##  OR [ 95 %CI] = 1.85 [ 1.05 , 3.27 ] 
##   p-value(OR) = 0.03 
##  
##  Log OR [ 95 %CI] = 0.62 [ 0.05 , 1.18 ] 
##   var(lOR) = 0.08 
##   p-value(Log OR) = 0.03 
##  
##  Other: 
##  
##  NNT = 9.25 
##  Total N = 160
#OPtion 3 will compare buyer vs seller ~ valuation vs Condition
mes(7.73, 4.40, 3.57, 3.29, 80, 80)
## Mean Differences ES: 
##  
##  d [ 95 %CI] = 0.97 [ 0.64 , 1.3 ] 
##   var(d) = 0.03 
##   p-value(d) = 0 
##   U3(d) = 83.4 % 
##   CLES(d) = 75.36 % 
##   Cliff's Delta = 0.51 
##  
##  g [ 95 %CI] = 0.97 [ 0.64 , 1.29 ] 
##   var(g) = 0.03 
##   p-value(g) = 0 
##   U3(g) = 83.28 % 
##   CLES(g) = 75.26 % 
##  
##  Correlation ES: 
##  
##  r [ 95 %CI] = 0.44 [ 0.3 , 0.56 ] 
##   var(r) = 0 
##   p-value(r) = 0 
##  
##  z [ 95 %CI] = 0.47 [ 0.31 , 0.63 ] 
##   var(z) = 0.01 
##   p-value(z) = 0 
##  
##  Odds Ratio ES: 
##  
##  OR [ 95 %CI] = 5.81 [ 3.21 , 10.52 ] 
##   p-value(OR) = 0 
##  
##  Log OR [ 95 %CI] = 1.76 [ 1.17 , 2.35 ] 
##   var(lOR) = 0.09 
##   p-value(Log OR) = 0 
##  
##  Other: 
##  
##  NNT = 2.85 
##  Total N = 160
#Effect size  (more than or equal to) < = 0.1 is small, 0.25 is medium, 0.4 is large (Cohen, 1988)
#To check if different session (eg- Mon, Tue, Wed, etc or am, pm or weekday, weekend) acts as a confounding factor and ALSO do we need to BLOCK for the INTERACTION EFFECT - 
#Test Additivity of Interaction - check if the block (session) has any interaction with our predictors (productorgamble and condition)
model5 <- aov(Valuation ~ Condition*ProductorGamble*factor(Session), data = data4)
model5
## Call:
##    aov(formula = Valuation ~ Condition * ProductorGamble * factor(Session), 
##     data = data4)
## 
## Terms:
##                 Condition ProductorGamble factor(Session)
## Sum of Squares   457.9083        429.3375         63.1434
## Deg. of Freedom         2               1               2
##                 Condition:ProductorGamble Condition:factor(Session)
## Sum of Squares                    55.2222                   23.6435
## Deg. of Freedom                         2                         4
##                 ProductorGamble:factor(Session)
## Sum of Squares                          12.0510
## Deg. of Freedom                               2
##                 Condition:ProductorGamble:factor(Session) Residuals
## Sum of Squares                                    56.1998 2126.8901
## Deg. of Freedom                                         4       222
## 
## Residual standard error: 3.095252
## Estimated effects may be unbalanced
summary(model5)
##                                            Df Sum Sq Mean Sq F value   Pr(>F)
## Condition                                   2  457.9   229.0  23.898 3.98e-10
## ProductorGamble                             1  429.3   429.3  44.813 1.75e-10
## factor(Session)                             2   63.1    31.6   3.295   0.0389
## Condition:ProductorGamble                   2   55.2    27.6   2.882   0.0581
## Condition:factor(Session)                   4   23.6     5.9   0.617   0.6509
## ProductorGamble:factor(Session)             2   12.1     6.0   0.629   0.5341
## Condition:ProductorGamble:factor(Session)   4   56.2    14.0   1.467   0.2133
## Residuals                                 222 2126.9     9.6                 
##                                              
## Condition                                 ***
## ProductorGamble                           ***
## factor(Session)                           *  
## Condition:ProductorGamble                 .  
## Condition:factor(Session)                    
## ProductorGamble:factor(Session)              
## Condition:ProductorGamble:factor(Session)    
## Residuals                                    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
#results suggest there is no significant interactin effect (Condition:ProductorGamble:factor(Session) p-value > 0.05)
#So, Session can be treated as a BLOCK

#Testing if predictors (condition and productorgamble) has an interaction effect with session added as a Block
model6 <- aov(Valuation ~ Condition*ProductorGamble + factor(Session), data = data4)
model6
## Call:
##    aov(formula = Valuation ~ Condition * ProductorGamble + factor(Session), 
##     data = data4)
## 
## Terms:
##                 Condition ProductorGamble factor(Session)
## Sum of Squares   457.9083        429.3375         63.1434
## Deg. of Freedom         2               1               2
##                 Condition:ProductorGamble Residuals
## Sum of Squares                    55.2222 2218.7844
## Deg. of Freedom                         2       232
## 
## Residual standard error: 3.092527
## Estimated effects may be unbalanced
summary(model6)
##                            Df Sum Sq Mean Sq F value   Pr(>F)    
## Condition                   2  457.9   229.0  23.940 3.53e-10 ***
## ProductorGamble             1  429.3   429.3  44.892 1.56e-10 ***
## factor(Session)             2   63.1    31.6   3.301   0.0386 *  
## Condition:ProductorGamble   2   55.2    27.6   2.887   0.0577 .  
## Residuals                 232 2218.8     9.6                     
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
#Not significant result noted
#To find out what group differs from the others
library(pgirmess)

#Tukey’s Test: compare all the potential combination chooser at gamble level with buyer at gamble level
TukeyHSD(model6) #for two way/factorial anova (predictors - Condition and ProductorGamble with session as a block)
##   Tukey multiple comparisons of means
##     95% family-wise confidence level
## 
## Fit: aov(formula = Valuation ~ Condition * ProductorGamble + factor(Session), data = data4)
## 
## $Condition
##                  diff        lwr      upr     p adj
## Chooser-Buyer  2.1500 0.99658685 3.303413 0.0000496
## Seller-Buyer   3.3375 2.18408685 4.490913 0.0000000
## Seller-Chooser 1.1875 0.03408685 2.340913 0.0419550
## 
## $ProductorGamble
##                 diff      lwr      upr p adj
## Product-Gamble 2.675 1.888394 3.461606     0
## 
## $`factor(Session)`
##           diff        lwr        upr     p adj
## 2-1 -1.2292188 -2.3826319 -0.0758056 0.0336355
## 3-1 -0.3898438 -1.5432569  0.7635694 0.7050740
## 3-2  0.8393750 -0.3140381  1.9927881 0.2011292
## 
## $`Condition:ProductorGamble`
##                                        diff        lwr      upr     p adj
## Chooser:Gamble-Buyer:Gamble     2.970241444  0.9830530 4.957430 0.0003661
## Seller:Gamble-Buyer:Gamble      3.019379981  1.0321915 5.006568 0.0002729
## Buyer:Product-Buyer:Gamble      3.009747617  1.0225591 4.996936 0.0002891
## Chooser:Product-Buyer:Gamble    4.339506173  2.3523177 6.326695 0.0000000
## Seller:Product-Buyer:Gamble     6.665367636  4.6781792 8.652556 0.0000000
## Seller:Gamble-Chooser:Gamble    0.049138537 -1.9380499 2.036327 0.9999997
## Buyer:Product-Chooser:Gamble    0.039506173 -1.9476823 2.026695 0.9999999
## Chooser:Product-Chooser:Gamble  1.369264729 -0.6179237 3.356453 0.3569160
## Seller:Product-Chooser:Gamble   3.695126192  1.7079377 5.682315 0.0000032
## Buyer:Product-Seller:Gamble    -0.009632364 -1.9968208 1.977556 1.0000000
## Chooser:Product-Seller:Gamble   1.320126192 -0.6670623 3.307315 0.3992214
## Seller:Product-Seller:Gamble    3.645987654  1.6587992 5.633176 0.0000046
## Chooser:Product-Buyer:Product   1.329758556 -0.6574299 3.316947 0.3907629
## Seller:Product-Buyer:Product    3.655620019  1.6684315 5.642808 0.0000043
## Seller:Product-Chooser:Product  2.325861463  0.3386730 4.313050 0.0114799

Summary Write Up

A study was conducted to investigate whether, taken together, a person’s status and product gamble form affected individuals’ valuation of the product. Observations from the study were analyzed by conducting a two-way analysis of variance with the two independent variables (condition and product or gamble) and the dependent variable (valuation) using R version 3.61. First, all assumptions are met and there is no adjustment made. ANOVA analysis revealed there is no statistically significant interaction effect (F(2, 234) = 2.698, p = .070). Results also suggest that the valuations of an item’s worth was affected by the status of (as buyers, sellers, or choosers) the participants (F(2, 234) = 23.45, p < .001) and product or gamble (F(1, 234) = 43.98, p < .001).