library(readr)
data <- read_csv("D:/UMP/Sem 5/EDA/Lab Report/Lab Report 4.csv")
## 
## -- Column specification --------------------------------------------------------
## cols(
##   manufacturer = col_character(),
##   process = col_character(),
##   brightness = col_double()
## )
data
## # A tibble: 45 x 3
##    manufacturer process brightness
##    <chr>        <chr>        <dbl>
##  1 Kodak        A               32
##  2 Kodak        B               26
##  3 Kodak        C               28
##  4 Kodak        A               34
##  5 Kodak        B               29
##  6 Kodak        C               28
##  7 Kodak        A               31
##  8 Kodak        B               27
##  9 Kodak        C               27
## 10 Kodak        A               30
## # ... with 35 more rows

(i) What is the independent and dependent variable?

(ii) Identify the number of treatments and list all the treatment

(iii) Write down the model for the experiment

knitr::include_graphics("D:/UMP/Sem 5/EDA/Lab Report/model of two factor factorial.PNG")

(iv) Perform the statistical analysis for the experiment.

A=as.factor(data$manufacturer)
B=as.factor(data$process)
results=aov(brightness ~ A * B, data = data)
summary(results)
##             Df Sum Sq Mean Sq F value   Pr(>F)    
## A            2 1363.4   681.7  117.31  < 2e-16 ***
## B            2  165.6    82.8   14.25 2.76e-05 ***
## A:B          4  247.0    61.8   10.63 8.63e-06 ***
## Residuals   36  209.2     5.8                     
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
knitr::include_graphics("D:/UMP/Sem 5/EDA/Lab Report/anova lab report 4.png")

(v) Conduct and comment on the model adequacy checking

residuals <- resid(results)
residuals
##            1            2            3            4            5            6 
## -8.00000e-01 -2.60000e+00 -1.00000e+00  1.20000e+00  4.00000e-01 -1.00000e+00 
##            7            8            9           10           11           12 
## -1.80000e+00 -1.60000e+00 -2.00000e+00 -2.80000e+00  1.40000e+00  1.00000e+00 
##           13           14           15           16           17           18 
##  4.20000e+00  2.40000e+00  3.00000e+00 -2.00000e+00 -4.80000e+00 -1.80000e+00 
##           19           20           21           22           23           24 
## -4.00000e+00  1.20000e+00 -1.80000e+00 -1.00000e+00  1.20000e+00  2.20000e+00 
##           25           26           27           28           29           30 
##  5.00000e+00  3.20000e+00  1.20000e+00  2.00000e+00 -8.00000e-01  2.00000e-01 
##           31           32           33           34           35           36 
## -8.00000e-01  2.00000e-01 -7.21645e-16  2.00000e-01  3.20000e+00  2.00000e+00 
##           37           38           39           40           41           42 
##  1.20000e+00 -1.80000e+00  1.00000e+00 -2.80000e+00 -1.80000e+00 -3.00000e+00 
##           43           44           45 
##  2.20000e+00  2.00000e-01 -7.21645e-16
predicted <- predict(results)
predicted
##    1    2    3    4    5    6    7    8    9   10   11   12   13   14   15   16 
## 32.8 28.6 29.0 32.8 28.6 29.0 32.8 28.6 29.0 32.8 28.6 29.0 32.8 28.6 29.0 45.0 
##   17   18   19   20   21   22   23   24   25   26   27   28   29   30   31   32 
## 36.8 33.8 45.0 36.8 33.8 45.0 36.8 33.8 45.0 36.8 33.8 45.0 36.8 33.8 23.8 26.8 
##   33   34   35   36   37   38   39   40   41   42   43   44   45 
## 25.0 23.8 26.8 25.0 23.8 26.8 25.0 23.8 26.8 25.0 23.8 26.8 25.0
library(ggpubr)
## Warning: package 'ggpubr' was built under R version 4.0.5
## Loading required package: ggplot2
## Warning: package 'ggplot2' was built under R version 4.0.5
shapiro.test(residuals)
## 
##  Shapiro-Wilk normality test
## 
## data:  residuals
## W = 0.98732, p-value = 0.8981
knitr::include_graphics("D:/UMP/Sem 5/EDA/Lab Report/shapiro wilk test.PNG")

plot(predicted, residuals)

plot(lm(residuals~predicted))

- The model is good for constant variance because the points is scattered randomly above and below the reference line.

library(car)
## Warning: package 'car' was built under R version 4.0.5
## Loading required package: carData
durbinWatsonTest(results)
##  lag Autocorrelation D-W Statistic p-value
##    1       0.4294455       1.13805   0.008
##  Alternative hypothesis: rho != 0
knitr::include_graphics("D:/UMP/Sem 5/EDA/Lab Report/Independent test.PNG")

knitr::include_graphics("D:/UMP/Sem 5/EDA/Lab Report/Marking Files.png")

knitr::include_graphics("D:/UMP/Sem 5/EDA/Lab Report/Rubrics.PNG")