Packages

library(tidyverse)
library(sjPlot)
library(fBasics)
library(lmtest)
library(car)

Data

An engineer is studying methods for improving the ability to detect targets on a radar scope. Two factors she considers to be important are the amount of background noise, or “ground clutter,” on the scope and the type of filter placed over the screen. An experiment is designed using three levels of ground clutter and two filter types. We will consider these as fixed-type factors. The experiment is performed by randomly selecting a treatment combination (ground clutter level and filter type) and then introducing a signal representing the target into the scope. The intensity of this target is increased until the operator observes it. The intensity level at detection is then measured as the response variable. Because of operator availability,it is convenient to select an operator and keep him or her at the scope until all the necessary runs have been made. Furthermore, operators differ in their skill and ability to use the scope. Consequently, it seems logical to use the operators as blocks. Four operators are randomly selected. Once an operator is chosen, the order in which the six treatment combinations are run is randomly determined. Thus, we have a 3 x 2 factorial experiment run in a randomized complete block. The data are shown below

radar <- read.table(header = T,stringsAsFactors = T,text = 
                        "Operator TipeFilter    GroundClutter   Intensitas
1   1   Low 90
1   1   Medium  102
1   1   High    114
1   2   Low 86
1   2   Medium  87
1   2   High    93
2   1   Low 96
2   1   Medium  106
2   1   High    112
2   2   Low 84
2   2   Medium  90
2   2   High    91
3   1   Low 100
3   1   Medium  105
3   1   High    108
3   2   Low 92
3   2   Medium  97
3   2   High    95
4   1   Low 92
4   1   Medium  96
4   1   High    98
4   2   Low 81
4   2   Medium  80
4   2   High    83

")

Melihat data sekilas

head(radar)
##   Operator TipeFilter GroundClutter Intensitas
## 1        1          1           Low         90
## 2        1          1        Medium        102
## 3        1          1          High        114
## 4        1          2           Low         86
## 5        1          2        Medium         87
## 6        1          2          High         93
str(radar)
## 'data.frame':    24 obs. of  4 variables:
##  $ Operator     : int  1 1 1 1 1 1 2 2 2 2 ...
##  $ TipeFilter   : int  1 1 1 2 2 2 1 1 1 2 ...
##  $ GroundClutter: Factor w/ 3 levels "High","Low","Medium": 2 3 1 2 3 1 2 3 1 2 ...
##  $ Intensitas   : int  90 102 114 86 87 93 96 106 112 84 ...

Mengubah kolom suhu ke bentuk factor

radar$Operator <- as.factor(radar$Operator)
radar$TipeFilter <- as.factor(radar$TipeFilter)
radar$GroundClutter <- as.factor(radar$GroundClutter)

Menampilkan hasil ANOVA

anova_radar <- aov(Intensitas~Operator+TipeFilter+GroundClutter+TipeFilter:GroundClutter,data=radar)
summary(anova_radar)
##                          Df Sum Sq Mean Sq F value   Pr(>F)    
## Operator                  3  402.2   134.1  12.089 0.000277 ***
## TipeFilter                1 1066.7  1066.7  96.192 6.45e-08 ***
## GroundClutter             2  335.6   167.8  15.132 0.000253 ***
## TipeFilter:GroundClutter  2   77.1    38.5   3.476 0.057507 .  
## Residuals                15  166.3    11.1                     
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Plot Interaksi

plot_model(anova_radar,type = "int")+ggplot2::geom_line()

Uji Asumsi ANOVA

Menggunakan Grafik

plot_model(anova_radar,type = "diag")
## [[1]]

## 
## [[2]]
## `geom_smooth()` using formula 'y ~ x'

## 
## [[3]]

## 
## [[4]]
## `geom_smooth()` using formula 'y ~ x'

Plot order vs residual

res <- residuals(anova_radar)
res_order <- data.frame(order=seq_along(res),
                        residual=res
                        )
plot_scatter(res_order,x = order,y=residual)+geom_hline(yintercept = 0)

uji normalitas

ksnormTest(res)
## 
## Title:
##  One-sample Kolmogorov-Smirnov test
## 
## Test Results:
##   STATISTIC:
##     D: 0.2855
##   P VALUE:
##     Alternative Two-Sided: 0.03171 
##     Alternative      Less: 0.01586 
##     Alternative   Greater: 0.03352 
## 
## Description:
##  Mon Dec 07 09:34:40 2020 by user: gtmir
print(adTest(res))
## 
## Title:
##  Anderson - Darling Normality Test
## 
## Test Results:
##   STATISTIC:
##     A: 0.1744
##   P VALUE:
##     0.9153 
## 
## Description:
##  Mon Dec 07 09:34:40 2020 by user: gtmir
shapiroTest(res)
## 
## Title:
##  Shapiro - Wilk Normality Test
## 
## Test Results:
##   STATISTIC:
##     W: 0.9825
##   P VALUE:
##     0.9366 
## 
## Description:
##  Mon Dec 07 09:34:40 2020 by user: gtmir
bptest(Intensitas~Operator+TipeFilter+GroundClutter+TipeFilter:GroundClutter,data=radar,studentize = F)
## 
##  Breusch-Pagan test
## 
## data:  Intensitas ~ Operator + TipeFilter + GroundClutter + TipeFilter:GroundClutter
## BP = 9.1022, df = 8, p-value = 0.3337
leveneTest(Intensitas~TipeFilter*GroundClutter*TipeFilter:GroundClutter,data=radar)
## Levene's Test for Homogeneity of Variance (center = median)
##       Df F value Pr(>F)
## group  5   0.234 0.9425
##       18