Main Effect
Main effects of all four factors are shown in a boxplot fashion. There are no significant main effect for Country and Type. However, for quantitative factors such as Mileage andWeight, we can conclude that the longer the Mileage, the lower the Price, and the larger the Weight is, the higher the Price gets.

According to the boxplots, there is no linear effect of categorical data such as Country and Type on the response Price, because these variables are not ordinal. Therefore, the main effects of these factors are not so meaningful. Here we show the means of each level of such factors, and the main effct of the ordinal factors (Mileage and Weight).
Country
France 1.59310^{4}
Germany: 1.4447510^{4}
Japan: 1.393805310^{4}
Japan/USA: 1.006757110^{4}
Korea: 7857.3333333
Mexico: 8672
Sweden: 1.84510^{4}
USA: 1.254326910^{4}
Mileage
“20”: “25” 2611.5326087
“20”: “30” 6229.9492754
“20”: “35” 7795.7826087
“25”: “30” 3618.4166667
“25”: “35” 5184.25
“30”: “35” 1565.8333333
Type
Compact: 1.285313310^{4}
Large: 1.597566710^{4}
Medium: 1.620110^{4}
Small: 7682.3846154
Sporty: 1.171711110^{4}
Van: 1.432542910^{4}
Weight
“2000”: “2500” -3315.1973684
“2000”: “3000” -6053.0681818
“2000”: “3500” -9369.0961538
“2000”: “4000” -8870.25
“2500”: “3000” -2737.8708134
“2500”: “3500” -6053.8987854
“2500”: “4000” -5555.0526316
“3000”: “3500” -3316.027972
“3000”: “4000” -2817.1818182
“3500”: “4000” 498.8461538
Analysis of Variance
After computing the main effect and interaction effect, we have to perform analysis of variance test to determine if these effects are significant. If interaction effects are significant, then we cannot draw conclusion between factors and response without considering them. Since there are both fixed and random effects in this experiment, corresponding ANOVA tests are performed:
##Fixed Effect ANOVA
aov(Y ~ A, data=d)
##Random Effect ANOVA
A <- aov(Y ~ Error(A), data=d)
summary(A)
ANOVA on Main Effect:
Country Fixed effect
## Df Sum Sq Mean Sq F value Pr(>F)
## Country 7 214024382 30574912 2.066 0.064 .
## Residuals 52 769527115 14798598
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Mileage Random effect
## Df Sum Sq Mean Sq F value Pr(>F)
## Mileage 3 423484060 141161353 14.11 5.77e-07 ***
## Residuals 56 560067437 10001204
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Type Fixed effect
## Df Sum Sq Mean Sq F value Pr(>F)
## Type 5 545938805 109187761 13.47 1.56e-08 ***
## Residuals 54 437612692 8103939
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Weight Random effect
## Df Sum Sq Mean Sq F value Pr(>F)
## Weight 4 435208731 108802183 10.91 1.39e-06 ***
## Residuals 55 548342767 9969868
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
ANOVA on 2-Way Interaction Effect:
Since the 2 factors involved in the 2-way interaction effect can be of different effect models, some 2-way interactions are mixed effect models, and the corresponding ANOVA test is performed.
library(lme4)
library(lmerTest)
AB <- lmer(Y ~ B + (1 | A), data=d)
anova(AB)
Country: Mileage This is an mixed effect model
## fixed-effect model matrix is rank deficient so dropping 14 columns / coefficients
## fixed-effect model matrix is rank deficient so dropping 14 columns / coefficients
## fixed-effect model matrix is rank deficient so dropping 14 columns / coefficients
## Error in calculation of the Satterthwaite's approximation. The output of lme4 package is returned
## anova from lme4 is returned
## some computational error has occurred in lmerTest
## Analysis of Variance Table
## Df Sum Sq Mean Sq F value
## Country 7 138423397 19774771 2.1151
## Mileage 3 29684772 9894924 1.0584
## Country:Mileage 7 30783830 4397690 0.4704
Country: Type This is a fixed effect model
## Df Sum Sq Mean Sq F value Pr(>F)
## Country 7 214024382 30574912 11.407 7.50e-08 ***
## Type 5 528026061 105605212 39.399 1.99e-14 ***
## Country:Type 7 134286165 19183738 7.157 1.49e-05 ***
## Residuals 40 107214889 2680372
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Country: Weight mixed effect model
## fixed-effect model matrix is rank deficient so dropping 23 columns / coefficients
## fixed-effect model matrix is rank deficient so dropping 23 columns / coefficients
## fixed-effect model matrix is rank deficient so dropping 23 columns / coefficients
## Error in calculation of the Satterthwaite's approximation. The output of lme4 package is returned
## anova from lme4 is returned
## some computational error has occurred in lmerTest
## Analysis of Variance Table
## Df Sum Sq Mean Sq F value
## Country 7 203387636 29055377 4.1474
## Weight 4 56146585 14036646 2.0036
## Country:Weight 5 32716838 6543368 0.9340
Mileage: Type mixed effect model
## fixed-effect model matrix is rank deficient so dropping 10 columns / coefficients
## fixed-effect model matrix is rank deficient so dropping 10 columns / coefficients
## fixed-effect model matrix is rank deficient so dropping 10 columns / coefficients
## Error in calculation of the Satterthwaite's approximation. The output of lme4 package is returned
## anova from lme4 is returned
## some computational error has occurred in lmerTest
## Analysis of Variance Table
## Df Sum Sq Mean Sq F value
## Type 5 178943159 35788632 4.0247
## Mileage 3 4043200 1347733 0.1516
## Type:Mileage 5 11876859 2375372 0.2671
Mileage: Weight random effect model
## Df Sum Sq Mean Sq F value Pr(>F)
## Mileage 3 423484060 141161353 15.745 2.25e-07 ***
## Weight 4 77698788 19424697 2.167 0.086 .
## Mileage:Weight 1 25132453 25132453 2.803 0.100
## Residuals 51 457236196 8965416
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Type: Weight mixed effect model
## fixed-effect model matrix is rank deficient so dropping 16 columns / coefficients
## fixed-effect model matrix is rank deficient so dropping 16 columns / coefficients
## fixed-effect model matrix is rank deficient so dropping 16 columns / coefficients
## Error in calculation of the Satterthwaite's approximation. The output of lme4 package is returned
## anova from lme4 is returned
## some computational error has occurred in lmerTest
## Analysis of Variance Table
## Df Sum Sq Mean Sq F value
## Type 5 245119800 49023960 7.7530
## Weight 4 13198935 3299734 0.5218
## Type:Weight 4 60118414 15029603 2.3769
As we can see in the ANOVA test results, main effects of all for factors except Country are significant (p-values < 0.05), indicating that these factors have significant individual effects of the Price of a car. In the ANOVA tests for 2-way interactions, the code did not provide P values of each interaction effect with mixed models. However, we can tell from the F values, that the interactions between Type:Weight is larger than 2, which suggests that it can be significant. According to the P-value, Country:Type interaction effect is also significant.