Biblioteca
e15.1 = rbind( c(42, 37, 41, 39, 43, 41), #Local 1
c(37, 40, 39, 38, 41, 39), #Local 2
c(32, 28, 34, 32, 30, 33) #Local 3
)
e15.1
## [,1] [,2] [,3] [,4] [,5] [,6]
## [1,] 42 37 41 39 43 41
## [2,] 37 40 39 38 41 39
## [3,] 32 28 34 32 30 33
k = nrow(e15.1)
n = ncol(e15.1)
df1 = k - 1
df2 = k*(n-1)
m.grupos = apply(e15.1, 1, mean)
m.geral = mean(e15.1)
ssqt = sum((m.grupos-m.geral)^2*n)
s1.2 = ssqt/df1
x = as.numeric(t(e15.1))
ssqr = sum((x-rep(m.grupos, each = n))^2)
s2.2 = ssqr/df2
F = s1.2/s2.2
p = 1 - pf(q = F, df1 = df1, df2 = df2)
anv = matrix(c(df1, df2, ssqt, ssqr, s1.2, s2.2, F, NA, p, NA), nrow = 2)
row.names(anv) = c("g", "Residuals")
colnames(anv) = c("Df", "Sum Sq", "Mean Sq", "F value", "Pr(>F)")
print(anv, na.print = "")
## Df Sum Sq Mean Sq F value Pr(>F)
## g 2 279 139.5 36.71053 1.665393e-06
## Residuals 15 57 3.8
g = as.factor(rep(c(1:k), each = n)) # define o grupo para cada observação
summary(aov(x~g)) # executa o ANOVA
## Df Sum Sq Mean Sq F value Pr(>F)
## g 2 279 139.5 36.71 1.67e-06 ***
## Residuals 15 57 3.8
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
# Produtor 1: 4.4 0.6 6.4 1.2 2.8 4.4
# Produtor 2: 0.8 2.6 1.9 3.7 5.3 1.5
# Produtor 3: 1.1 3.4 1.6 0.5 4.3 2.5
e15.1 = c(
c(4.4, 0.6, 6.4, 1.2, 2.8, 4.4),
c(0.8, 2.6, 1.9, 3.7, 5.3, 1.3),
c(1.1, 3.4, 1.6, 0.5, 4.3, 2.3)
)
g = as.factor(rep(1:3, each = 6))
summary(aov(e15.1~g))
## Df Sum Sq Mean Sq F value Pr(>F)
## g 2 3.72 1.860 0.579 0.573
## Residuals 15 48.22 3.215
# Fio 1: 18.8 16.4 15.7 19.6 16.5 18.2
# Fio 2: 21.1 17.8 18.6 20.8 17.9 19.0
# Fio 3: 16.5 17.8 16.1
e15.3 = c(180, 164, 157, 196, 165, 182, 211, 178, 186, 208, 179, 190, 165, 178, 161)/10
g = as.factor(c(1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 3, 3, 3))
# OU
g = as.factor(c(rep(1:2, each = 6), rep(3, 3)))
summary(aov(e15.3~g))
## Df Sum Sq Mean Sq F value Pr(>F)
## g 2 15.12 7.560 4.061 0.045 *
## Residuals 12 22.34 1.862
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
# Trajeto 1: 25 26 25 25 28
# Trajeto 2: 27 27 28 26 26
# Trajeto 3: 28 29 33 30 30
# Trajeto 4: 28 29 27 30 27
e15.4 = c(25, 26, 25, 25, 28,
27, 27, 28, 26, 26,
28, 29, 33, 30, 30,
28, 29, 27, 30, 27)
g = as.factor(rep(1:4, each = 5))
a = aov(e15.4~g)
summary(a)
## Df Sum Sq Mean Sq F value Pr(>F)
## g 3 49.8 16.6 8.737 0.00116 **
## Residuals 16 30.4 1.9
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
thsd = TukeyHSD(a, ordered = FALSE)
thsd$g[order(thsd$g[,4]),]
## diff lwr upr p adj
## 3-1 4.2 1.70582074 6.6941793 0.0009798178
## 3-2 3.2 0.70582074 5.6941793 0.0100116683
## 4-1 2.4 -0.09417926 4.8941793 0.0614131338
## 4-3 -1.8 -4.29417926 0.6941793 0.2065277028
## 4-2 1.4 -1.09417926 3.8941793 0.4031260104
## 2-1 1.0 -1.49417926 3.4941793 0.6669778180
# Modelo G 56 61 68 42 82 70
# Modelo H 74 77 92 63 54
# Modelo K 25 36 29 56 44 48 38
# Modelo M 78 105 89 112 61
a = c(56, 61, 68, 42, 82, 70, 74, 77, 92, 63, 54, 25, 36, 29, 56, 44, 48, 38, 78, 105, 89, 112, 61)
g = c(rep(1, 6), rep(2, 5), rep(3, 7), rep(4, 5))
model = aov(a ~ as.factor(g))
summary(model)
## Df Sum Sq Mean Sq F value Pr(>F)
## as.factor(g) 3 7669 2556.4 11.7 0.000144 ***
## Residuals 19 4153 218.6
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
# A 130 98 128 106 139 121
# B 143 132 122 131 132 141
# C 114 141 95 123 118 140
# D 77 99 84 76 70 75
# E 109 86 113 101 103 112
# F 148 143 111 142 131 100
# G 149 129 134 108 119 126
# H 92 129 111 103 107 125
e15.21 = c(130, 98, 128, 106, 139, 121,
143, 132, 122, 131, 132, 141,
114, 141, 95, 123, 118, 140,
77, 99, 84, 76, 70, 75,
109, 86, 113, 101, 103, 112,
148, 143, 111, 142, 131, 100,
149, 129, 134, 108, 119, 126,
92, 129, 111, 103, 107, 125)
g = as.factor(rep(1:8, each = 6))
a = aov(e15.21~g)
summary(a)
## Df Sum Sq Mean Sq F value Pr(>F)
## g 7 12696 1813.8 9.257 9.25e-07 ***
## Residuals 40 7838 195.9
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
thsd = TukeyHSD(a, ordered = FALSE)
round(thsd$g[order(thsd$g[,4]),], 3)
## diff lwr upr p adj
## 4-2 -53.333 -79.167 -27.500 0.000
## 6-4 49.000 23.167 74.833 0.000
## 7-4 47.333 21.500 73.167 0.000
## 4-3 -41.667 -67.500 -15.833 0.000
## 4-1 -40.167 -66.000 -14.333 0.000
## 8-4 31.000 5.167 56.833 0.009
## 5-2 -29.500 -55.333 -3.667 0.016
## 6-5 25.167 -0.667 51.000 0.061
## 5-4 23.833 -2.000 49.667 0.089
## 7-5 23.500 -2.333 49.333 0.098
## 8-2 -22.333 -48.167 3.500 0.134
## 8-6 -18.000 -43.833 7.833 0.358
## 5-3 -17.833 -43.667 8.000 0.370
## 5-1 -16.333 -42.167 9.500 0.481
## 8-7 -16.333 -42.167 9.500 0.481
## 2-1 13.167 -12.667 39.000 0.730
## 3-2 -11.667 -37.500 14.167 0.831
## 8-3 -10.667 -36.500 15.167 0.886
## 8-1 -9.167 -35.000 16.667 0.945
## 6-1 8.833 -17.000 34.667 0.955
## 6-3 7.333 -18.500 33.167 0.984
## 8-5 7.167 -18.667 33.000 0.986
## 7-1 7.167 -18.667 33.000 0.986
## 7-2 -6.000 -31.833 19.833 0.995
## 7-3 5.667 -20.167 31.500 0.996
## 6-2 -4.333 -30.167 21.500 0.999
## 7-6 -1.667 -27.500 24.167 1.000
## 3-1 1.500 -24.333 27.333 1.000
# Baixa Tipica Alta
# Escola A 71 92 89
# Escola B 44 51 85
# Escola C 50 64 72
# Escola D 67 81 86
#
e15.4 = c(71, 92, 89,
44, 51, 85,
50, 64, 72,
67, 81, 86)
g1 = as.factor(rep(1:4, each = 3))
g2 = as.factor(rep(1:3, times = 4))
a = aov(e15.4~g1+g2)
summary(a)
## Df Sum Sq Mean Sq F value Pr(>F)
## g1 3 1260 420.0 6.207 0.0286 *
## g2 2 1256 628.0 9.281 0.0146 *
## Residuals 6 406 67.7
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
thsd = TukeyHSD(a, ordered = FALSE)
round(thsd$g1[order(thsd$g1[,4]),], 3)
## diff lwr upr p adj
## 2-1 -24 -47.251 -0.749 0.044
## 3-1 -22 -45.251 1.251 0.062
## 4-2 18 -5.251 41.251 0.126
## 4-3 16 -7.251 39.251 0.181
## 4-1 -6 -29.251 17.251 0.809
## 3-2 2 -21.251 25.251 0.990
round(thsd$g2[order(thsd$g2[,4]),], 3)
## diff lwr upr p adj
## 3-1 25 7.153 42.847 0.012
## 2-1 14 -3.847 31.847 0.115
## 3-2 11 -6.847 28.847 0.221
# Combustivel 1 Combustivel 2 Combustivel 3 Combustivel 4
# Lancador X 45.9 57.6 52.2 41.7
# Lancador Y 46.0 51.0 50.1 38.8
# Lancador Z 45.7 56.9 55.3 48.1
# Combustivel 1 Combustivel 2 Combustivel 3 Combustivel 4
# Lancador X 46.1 55.9 52.6 44.3
# Lancador Y 46.3 52.1 51.4 39.6
# Lancador Z 45.8 57.9 56.2 47.6
# Combustivel 1 Combustivel 2 Combustivel 3 Combustivel 4
# Lancador X 45.9 46.1 57.6 55.9 52.2 52.6 41.7 44.3
# Lancador Y 46.0 46.3 51.0 52.1 50.1 51.4 38.8 39.6
# Lancador Z 45.7 45.8 56.9 57.9 55.3 56.2 48.1 47.6
p385 = c(459, 461, 576, 559, 522, 526, 417, 443,
460, 463, 510, 521, 501, 514, 388, 396,
457, 458, 569, 579, 553, 562, 481, 476)/10
g1 = as.factor(rep(1:3, each = 8))
g2 = as.factor(rep(1:4, each = 2, times = 3))
a = aov(p385~g1*g2)
summary(a)
## Df Sum Sq Mean Sq F value Pr(>F)
## g1 2 91.5 45.75 70.61 2.31e-07 ***
## g2 3 570.8 190.27 293.67 1.72e-11 ***
## g1:g2 6 50.9 8.49 13.10 0.000119 ***
## Residuals 12 7.8 0.65
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
thsd = TukeyHSD(a, ordered = TRUE)
thsd
## Tukey multiple comparisons of means
## 95% family-wise confidence level
## factor levels have been ordered
##
## Fit: aov(formula = p385 ~ g1 * g2)
##
## $g1
## diff lwr upr p adj
## 1-2 2.625 1.551275 3.698725 7.81e-05
## 3-2 4.775 3.701275 5.848725 2.00e-07
## 3-1 2.150 1.076275 3.223725 4.77e-04
##
## $g2
## diff lwr upr p adj
## 1-4 2.616667 1.2369348 3.996398 0.0005535
## 3-4 9.616667 8.2369348 10.996398 0.0000000
## 2-4 11.883333 10.5036015 13.263065 0.0000000
## 3-1 7.000000 5.6202682 8.379732 0.0000000
## 2-1 9.266667 7.8869348 10.646398 0.0000000
## 2-3 2.266667 0.8869348 3.646398 0.0018598
##
## $`g1:g2`
## diff lwr upr p adj
## 1:4-2:4 3.80 0.60429245 6.995708 0.0152743
## 3:1-2:4 6.55 3.35429245 9.745708 0.0001222
## 1:1-2:4 6.80 3.60429245 9.995708 0.0000837
## 2:1-2:4 6.95 3.75429245 10.145708 0.0000669
## 3:4-2:4 8.65 5.45429245 11.845708 0.0000067
## 2:3-2:4 11.55 8.35429245 14.745708 0.0000003
## 2:2-2:4 12.35 9.15429245 15.545708 0.0000001
## 1:3-2:4 13.20 10.00429245 16.395708 0.0000001
## 3:3-2:4 16.55 13.35429245 19.745708 0.0000000
## 1:2-2:4 17.55 14.35429245 20.745708 0.0000000
## 3:2-2:4 18.20 15.00429245 21.395708 0.0000000
## 3:1-1:4 2.75 -0.44570755 5.945708 0.1180918
## 1:1-1:4 3.00 -0.19570755 6.195708 0.0732143
## 2:1-1:4 3.15 -0.04570755 6.345708 0.0546773
## 3:4-1:4 4.85 1.65429245 8.045708 0.0020996
## 2:3-1:4 7.75 4.55429245 10.945708 0.0000216
## 2:2-1:4 8.55 5.35429245 11.745708 0.0000076
## 1:3-1:4 9.40 6.20429245 12.595708 0.0000027
## 3:3-1:4 12.75 9.55429245 15.945708 0.0000001
## 1:2-1:4 13.75 10.55429245 16.945708 0.0000000
## 3:2-1:4 14.40 11.20429245 17.595708 0.0000000
## 1:1-3:1 0.25 -2.94570755 3.445708 0.9999999
## 2:1-3:1 0.40 -2.79570755 3.595708 0.9999907
## 3:4-3:1 2.10 -1.09570755 5.295708 0.3658067
## 2:3-3:1 5.00 1.80429245 8.195708 0.0016024
## 2:2-3:1 5.80 2.60429245 8.995708 0.0004039
## 1:3-3:1 6.65 3.45429245 9.845708 0.0001049
## 3:3-3:1 10.00 6.80429245 13.195708 0.0000014
## 1:2-3:1 11.00 7.80429245 14.195708 0.0000005
## 3:2-3:1 11.65 8.45429245 14.845708 0.0000002
## 2:1-1:1 0.15 -3.04570755 3.345708 1.0000000
## 3:4-1:1 1.85 -1.34570755 5.045708 0.5218159
## 2:3-1:1 4.75 1.55429245 7.945708 0.0025193
## 2:2-1:1 5.55 2.35429245 8.745708 0.0006142
## 1:3-1:1 6.40 3.20429245 9.595708 0.0001541
## 3:3-1:1 9.75 6.55429245 12.945708 0.0000018
## 1:2-1:1 10.75 7.55429245 13.945708 0.0000006
## 3:2-1:1 11.40 8.20429245 14.595708 0.0000003
## 3:4-2:1 1.70 -1.49570755 4.895708 0.6252355
## 2:3-2:1 4.60 1.40429245 7.795708 0.0033209
## 2:2-2:1 5.40 2.20429245 8.595708 0.0007937
## 1:3-2:1 6.25 3.05429245 9.445708 0.0001950
## 3:3-2:1 9.60 6.40429245 12.795708 0.0000021
## 1:2-2:1 10.60 7.40429245 13.795708 0.0000007
## 3:2-2:1 11.25 8.05429245 14.445708 0.0000004
## 2:3-3:4 2.90 -0.29570755 6.095708 0.0887829
## 2:2-3:4 3.70 0.50429245 6.895708 0.0185723
## 1:3-3:4 4.55 1.35429245 7.745708 0.0036441
## 3:3-3:4 7.90 4.70429245 11.095708 0.0000176
## 1:2-3:4 8.90 5.70429245 12.095708 0.0000049
## 3:2-3:4 9.55 6.35429245 12.745708 0.0000023
## 2:2-2:3 0.80 -2.39570755 3.995708 0.9947014
## 1:3-2:3 1.65 -1.54570755 4.845708 0.6599667
## 3:3-2:3 5.00 1.80429245 8.195708 0.0016024
## 1:2-2:3 6.00 2.80429245 9.195708 0.0002910
## 3:2-2:3 6.65 3.45429245 9.845708 0.0001049
## 1:3-2:2 0.85 -2.34570755 4.045708 0.9915306
## 3:3-2:2 4.20 1.00429245 7.395708 0.0070516
## 1:2-2:2 5.20 2.00429245 8.395708 0.0011240
## 3:2-2:2 5.85 2.65429245 9.045708 0.0003719
## 3:3-1:3 3.35 0.15429245 6.545708 0.0369367
## 1:2-1:3 4.35 1.15429245 7.545708 0.0053028
## 3:2-1:3 5.00 1.80429245 8.195708 0.0016024
## 1:2-3:3 1.00 -2.19570755 4.195708 0.9729553
## 3:2-3:3 1.65 -1.54570755 4.845708 0.6599667
## 3:2-1:2 0.65 -2.54570755 3.845708 0.9990637
round(thsd$g1[order(thsd$g1[,4]),], 3)
## diff lwr upr p adj
## 3-2 4.775 3.701 5.849 0
## 1-2 2.625 1.551 3.699 0
## 3-1 2.150 1.076 3.224 0
round(thsd$g2[order(thsd$g2[,4]),], 3)
## diff lwr upr p adj
## 2-4 11.883 10.504 13.263 0.000
## 3-4 9.617 8.237 10.996 0.000
## 2-1 9.267 7.887 10.646 0.000
## 3-1 7.000 5.620 8.380 0.000
## 1-4 2.617 1.237 3.996 0.001
## 2-3 2.267 0.887 3.646 0.002
round(thsd$`g1:g2`[order(thsd$`g1:g2`[,4]),], 3)
## diff lwr upr p adj
## 3:2-2:4 18.20 15.004 21.396 0.000
## 1:2-2:4 17.55 14.354 20.746 0.000
## 3:3-2:4 16.55 13.354 19.746 0.000
## 3:2-1:4 14.40 11.204 17.596 0.000
## 1:2-1:4 13.75 10.554 16.946 0.000
## 1:3-2:4 13.20 10.004 16.396 0.000
## 3:3-1:4 12.75 9.554 15.946 0.000
## 2:2-2:4 12.35 9.154 15.546 0.000
## 3:2-3:1 11.65 8.454 14.846 0.000
## 2:3-2:4 11.55 8.354 14.746 0.000
## 3:2-1:1 11.40 8.204 14.596 0.000
## 3:2-2:1 11.25 8.054 14.446 0.000
## 1:2-3:1 11.00 7.804 14.196 0.000
## 1:2-1:1 10.75 7.554 13.946 0.000
## 1:2-2:1 10.60 7.404 13.796 0.000
## 3:3-3:1 10.00 6.804 13.196 0.000
## 3:3-1:1 9.75 6.554 12.946 0.000
## 3:3-2:1 9.60 6.404 12.796 0.000
## 3:2-3:4 9.55 6.354 12.746 0.000
## 1:3-1:4 9.40 6.204 12.596 0.000
## 1:2-3:4 8.90 5.704 12.096 0.000
## 3:4-2:4 8.65 5.454 11.846 0.000
## 2:2-1:4 8.55 5.354 11.746 0.000
## 3:3-3:4 7.90 4.704 11.096 0.000
## 2:3-1:4 7.75 4.554 10.946 0.000
## 2:1-2:4 6.95 3.754 10.146 0.000
## 1:1-2:4 6.80 3.604 9.996 0.000
## 1:3-3:1 6.65 3.454 9.846 0.000
## 3:2-2:3 6.65 3.454 9.846 0.000
## 3:1-2:4 6.55 3.354 9.746 0.000
## 1:3-1:1 6.40 3.204 9.596 0.000
## 1:3-2:1 6.25 3.054 9.446 0.000
## 1:2-2:3 6.00 2.804 9.196 0.000
## 3:2-2:2 5.85 2.654 9.046 0.000
## 2:2-3:1 5.80 2.604 8.996 0.000
## 2:2-1:1 5.55 2.354 8.746 0.001
## 2:2-2:1 5.40 2.204 8.596 0.001
## 1:2-2:2 5.20 2.004 8.396 0.001
## 2:3-3:1 5.00 1.804 8.196 0.002
## 3:3-2:3 5.00 1.804 8.196 0.002
## 3:2-1:3 5.00 1.804 8.196 0.002
## 3:4-1:4 4.85 1.654 8.046 0.002
## 2:3-1:1 4.75 1.554 7.946 0.003
## 2:3-2:1 4.60 1.404 7.796 0.003
## 1:3-3:4 4.55 1.354 7.746 0.004
## 1:2-1:3 4.35 1.154 7.546 0.005
## 3:3-2:2 4.20 1.004 7.396 0.007
## 1:4-2:4 3.80 0.604 6.996 0.015
## 2:2-3:4 3.70 0.504 6.896 0.019
## 3:3-1:3 3.35 0.154 6.546 0.037
## 2:1-1:4 3.15 -0.046 6.346 0.055
## 1:1-1:4 3.00 -0.196 6.196 0.073
## 2:3-3:4 2.90 -0.296 6.096 0.089
## 3:1-1:4 2.75 -0.446 5.946 0.118
## 3:4-3:1 2.10 -1.096 5.296 0.366
## 3:4-1:1 1.85 -1.346 5.046 0.522
## 3:4-2:1 1.70 -1.496 4.896 0.625
## 1:3-2:3 1.65 -1.546 4.846 0.660
## 3:2-3:3 1.65 -1.546 4.846 0.660
## 1:2-3:3 1.00 -2.196 4.196 0.973
## 1:3-2:2 0.85 -2.346 4.046 0.992
## 2:2-2:3 0.80 -2.396 3.996 0.995
## 3:2-1:2 0.65 -2.546 3.846 0.999
## 2:1-3:1 0.40 -2.796 3.596 1.000
## 1:1-3:1 0.25 -2.946 3.446 1.000
## 2:1-1:1 0.15 -3.046 3.346 1.000
# 1 2 3 4 5 6
# gr1 16 12 14 15
# gr2 12 11 13 18
# gr3 16 19 18 19 17 19
# gr4 20 21 18
dados = c(16, 12, 14, 15, 12, 11, 13, 18, 16, 19, 18, 19, 17, 19, 20, 21, 18)
g = c(rep(1, 4), rep(2, 4), rep(3, 6), rep(4, 3))
model = aov(dados ~ as.factor(g))
summary(model)
## Df Sum Sq Mean Sq F value Pr(>F)
## as.factor(g) 3 99.47 33.16 8.549 0.00215 **
## Residuals 13 50.42 3.88
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
TukeyHSD(model)
## Tukey multiple comparisons of means
## 95% family-wise confidence level
##
## Fit: aov(formula = dados ~ as.factor(g))
##
## $`as.factor(g)`
## diff lwr upr p adj
## 2-1 -0.750000 -4.837184 3.337184 0.9479794
## 3-1 3.750000 0.018929 7.481071 0.0486895
## 4-1 5.416667 1.002004 9.831329 0.0149391
## 3-2 4.500000 0.768929 8.231071 0.0167106
## 4-2 6.166667 1.752004 10.581329 0.0060170
## 4-3 1.666667 -2.420517 5.753850 0.6393345
Resposta (a) - A média do grupo gr4 não é significativamente maior do que a média do grupo gr3.
# t1 t2 t3 t4 t5 t6
# gr1 16 12 14 15 19 20
# gr2 12 11 13 18 17 21
# gr3 16 19 18 19 17 19
# gr4 20 21 18 20 21 23
dados = c(16, 12, 14, 15, 19, 20,
12, 11, 13, 18, 17, 21,
16, 19, 18, 19, 17, 19,
20, 21, 18, 20, 21, 23)
g1 = as.factor(rep(1:4, each = 6))
g2 = as.factor(rep(1:6, times = 4))
a = aov(dados~g1+g2)
summary(a)
## Df Sum Sq Mean Sq F value Pr(>F)
## g1 3 97.13 32.38 7.573 0.00259 **
## g2 5 80.71 16.14 3.776 0.02057 *
## Residuals 15 64.13 4.28
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
thsd = TukeyHSD(a, ordered = FALSE)
thsd
## Tukey multiple comparisons of means
## 95% family-wise confidence level
##
## Fit: aov(formula = dados ~ g1 + g2)
##
## $g1
## diff lwr upr p adj
## 2-1 -0.6666667 -4.1071845 2.773851 0.9427715
## 3-1 2.0000000 -1.4405178 5.440518 0.3696429
## 4-1 4.5000000 1.0594822 7.940518 0.0089545
## 3-2 2.6666667 -0.7738511 6.107184 0.1589008
## 4-2 5.1666667 1.7261489 8.607184 0.0029866
## 4-3 2.5000000 -0.9405178 5.940518 0.1995226
##
## $g2
## diff lwr upr p adj
## 2-1 -2.500000e-01 -5.000054e+00 4.500054 0.9999748
## 3-1 -2.500000e-01 -5.000054e+00 4.500054 0.9999748
## 4-1 2.000000e+00 -2.750054e+00 6.750054 0.7443654
## 5-1 2.500000e+00 -2.250054e+00 7.250054 0.5459628
## 6-1 4.750000e+00 -5.366828e-05 9.500054 0.0500034
## 3-2 1.776357e-15 -4.750054e+00 4.750054 1.0000000
## 4-2 2.250000e+00 -2.500054e+00 7.000054 0.6466577
## 5-2 2.750000e+00 -2.000054e+00 7.500054 0.4489559
## 6-2 5.000000e+00 2.499463e-01 9.750054 0.0363675
## 4-3 2.250000e+00 -2.500054e+00 7.000054 0.6466577
## 5-3 2.750000e+00 -2.000054e+00 7.500054 0.4489559
## 6-3 5.000000e+00 2.499463e-01 9.750054 0.0363675
## 5-4 5.000000e-01 -4.250054e+00 5.250054 0.9992431
## 6-4 2.750000e+00 -2.000054e+00 7.500054 0.4489559
## 6-5 2.250000e+00 -2.500054e+00 7.000054 0.6466577
Resposta (c) - A média do grupo t5 não é significativamente maior do que a média do grupo t1
# b1 b1 b1 b2 b2 b2 b3 b3 b3 b4 b4 b4
#a1 15.1 14.3 15.3 10.8 12.7 11.3 14.7 11.6 13.0 12.5 10.8 11.4
#a2 13.1 10.0 12.8 8.2 11.5 9.6 12.4 10.5 11.0 7.6 9.7 8.6
#a3 12.1 13.4 11.4 10.1 11.6 10.9 11.3 9.8 8.8 10.5 10.9 10.3
dados = c (15.1, 14.3, 15.3, 10.8, 12.7, 11.3, 14.7, 11.6, 13.0, 12.5, 10.8, 11.4,
13.1, 10.0, 12.8, 8.2, 11.5, 9.6, 12.4, 10.5, 11.0, 7.6, 9.7, 8.6,
12.1, 13.4, 11.4, 10.1, 11.6, 10.9, 11.3, 9.8, 8.8, 10.5, 10.9, 10.3)
g1 = as.factor(rep(1:3, each = 12))
g2 = as.factor(rep(1:4, each = 3, times = 3))
a = aov(dados~g1*g2)
options(scipen = 999)
summary(a)
## Df Sum Sq Mean Sq F value Pr(>F)
## g1 2 37.53 18.767 14.611 0.0000707 ***
## g2 3 40.33 13.444 10.467 0.000136 ***
## g1:g2 6 11.23 1.871 1.457 0.234930
## Residuals 24 30.83 1.284
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
TukeyHSD(a)
## Tukey multiple comparisons of means
## 95% family-wise confidence level
##
## Fit: aov(formula = dados ~ g1 * g2)
##
## $g1
## diff lwr upr p adj
## 2-1 -2.3750000 -3.530448 -1.2195517 0.0000854
## 3-1 -1.8666667 -3.022115 -0.7112184 0.0013536
## 3-2 0.5083333 -0.647115 1.6637816 0.5241007
##
## $g2
## diff lwr upr p adj
## 2-1 -2.3111111 -3.784921 -0.8373010 0.0012365
## 3-1 -1.6000000 -3.073810 -0.1261899 0.0298630
## 4-1 -2.8000000 -4.273810 -1.3261899 0.0001256
## 3-2 0.7111111 -0.762699 2.1849212 0.5529608
## 4-2 -0.4888889 -1.962699 0.9849212 0.7970518
## 4-3 -1.2000000 -2.673810 0.2738101 0.1395579
##
## $`g1:g2`
## diff lwr upr p adj
## 2:1-1:1 -2.93333333 -6.269848482 0.403181816 0.1224953
## 3:1-1:1 -2.60000000 -5.936515149 0.736515149 0.2367088
## 1:2-1:1 -3.30000000 -6.636515149 0.036515149 0.0544189
## 2:2-1:1 -5.13333333 -8.469848482 -1.796818184 0.0005241
## 3:2-1:1 -4.03333333 -7.369848482 -0.696818184 0.0090730
## 1:3-1:1 -1.80000000 -5.136515149 1.536515149 0.7221860
## 2:3-1:1 -3.60000000 -6.936515149 -0.263484851 0.0266962
## 3:3-1:1 -4.93333333 -8.269848482 -1.596818184 0.0008829
## 1:4-1:1 -3.33333333 -6.669848482 0.003181816 0.0503716
## 2:4-1:1 -6.26666667 -9.603181816 -2.930151518 0.0000285
## 3:4-1:1 -4.33333333 -7.669848482 -0.996818184 0.0042053
## 3:1-2:1 0.33333333 -3.003181816 3.669848482 0.9999998
## 1:2-2:1 -0.36666667 -3.703181816 2.969848482 0.9999995
## 2:2-2:1 -2.20000000 -5.536515149 1.136515149 0.4552456
## 3:2-2:1 -1.10000000 -4.436515149 2.236515149 0.9849391
## 1:3-2:1 1.13333333 -2.203181816 4.469848482 0.9811990
## 2:3-2:1 -0.66666667 -4.003181816 2.669848482 0.9998008
## 3:3-2:1 -2.00000000 -5.336515149 1.336515149 0.5888315
## 1:4-2:1 -0.40000000 -3.736515149 2.936515149 0.9999988
## 2:4-2:1 -3.33333333 -6.669848482 0.003181816 0.0503716
## 3:4-2:1 -1.40000000 -4.736515149 1.936515149 0.9225925
## 1:2-3:1 -0.70000000 -4.036515149 2.636515149 0.9996840
## 2:2-3:1 -2.53333333 -5.869848482 0.803181816 0.2670079
## 3:2-3:1 -1.43333333 -4.769848482 1.903181816 0.9110184
## 1:3-3:1 0.80000000 -2.536515149 4.136515149 0.9989235
## 2:3-3:1 -1.00000000 -4.336515149 2.336515149 0.9928157
## 3:3-3:1 -2.33333333 -5.669848482 1.003181816 0.3731764
## 1:4-3:1 -0.73333333 -4.069848482 2.603181816 0.9995125
## 2:4-3:1 -3.66666667 -7.003181816 -0.330151518 0.0226869
## 3:4-3:1 -1.73333333 -5.069848482 1.603181816 0.7635953
## 2:2-1:2 -1.83333333 -5.169848482 1.503181816 0.7007046
## 3:2-1:2 -0.73333333 -4.069848482 2.603181816 0.9995125
## 1:3-1:2 1.50000000 -1.836515149 4.836515149 0.8848185
## 2:3-1:2 -0.30000000 -3.636515149 3.036515149 0.9999999
## 3:3-1:2 -1.63333333 -4.969848482 1.703181816 0.8206848
## 1:4-1:2 -0.03333333 -3.369848482 3.303181816 1.0000000
## 2:4-1:2 -2.96666667 -6.303181816 0.369848482 0.1141640
## 3:4-1:2 -1.03333333 -4.369848482 2.303181816 0.9906828
## 3:2-2:2 1.10000000 -2.236515149 4.436515149 0.9849391
## 1:3-2:2 3.33333333 -0.003181816 6.669848482 0.0503716
## 2:3-2:2 1.53333333 -1.803181816 4.869848482 0.8702114
## 3:3-2:2 0.20000000 -3.136515149 3.536515149 1.0000000
## 1:4-2:2 1.80000000 -1.536515149 5.136515149 0.7221860
## 2:4-2:2 -1.13333333 -4.469848482 2.203181816 0.9811990
## 3:4-2:2 0.80000000 -2.536515149 4.136515149 0.9989235
## 1:3-3:2 2.23333333 -1.103181816 5.569848482 0.4340220
## 2:3-3:2 0.43333333 -2.903181816 3.769848482 0.9999973
## 3:3-3:2 -0.90000000 -4.236515149 2.436515149 0.9969900
## 1:4-3:2 0.70000000 -2.636515149 4.036515149 0.9996840
## 2:4-3:2 -2.23333333 -5.569848482 1.103181816 0.4340220
## 3:4-3:2 -0.30000000 -3.636515149 3.036515149 0.9999999
## 2:3-1:3 -1.80000000 -5.136515149 1.536515149 0.7221860
## 3:3-1:3 -3.13333333 -6.469848482 0.203181816 0.0794350
## 1:4-1:3 -1.53333333 -4.869848482 1.803181816 0.8702114
## 2:4-1:3 -4.46666667 -7.803181816 -1.130151518 0.0029778
## 3:4-1:3 -2.53333333 -5.869848482 0.803181816 0.2670079
## 3:3-2:3 -1.33333333 -4.669848482 2.003181816 0.9427194
## 1:4-2:3 0.26666667 -3.069848482 3.603181816 1.0000000
## 2:4-2:3 -2.66666667 -6.003181816 0.669848482 0.2089988
## 3:4-2:3 -0.73333333 -4.069848482 2.603181816 0.9995125
## 1:4-3:3 1.60000000 -1.736515149 4.936515149 0.8381056
## 2:4-3:3 -1.33333333 -4.669848482 2.003181816 0.9427194
## 3:4-3:3 0.60000000 -2.736515149 3.936515149 0.9999280
## 2:4-1:4 -2.93333333 -6.269848482 0.403181816 0.1224953
## 3:4-1:4 -1.00000000 -4.336515149 2.336515149 0.9928157
## 3:4-2:4 1.93333333 -1.403181816 5.269848482 0.6341406
thsd = TukeyHSD(a)[[3]]
options(scipen = 999)
round(thsd[order(rownames(thsd)),],3)
## diff lwr upr p adj
## 1:2-1:1 -3.300 -6.637 0.037 0.054
## 1:2-2:1 -0.367 -3.703 2.970 1.000
## 1:2-3:1 -0.700 -4.037 2.637 1.000
## 1:3-1:1 -1.800 -5.137 1.537 0.722
## 1:3-1:2 1.500 -1.837 4.837 0.885
## 1:3-2:1 1.133 -2.203 4.470 0.981
## 1:3-2:2 3.333 -0.003 6.670 0.050
## 1:3-3:1 0.800 -2.537 4.137 0.999
## 1:3-3:2 2.233 -1.103 5.570 0.434
## 1:4-1:1 -3.333 -6.670 0.003 0.050
## 1:4-1:2 -0.033 -3.370 3.303 1.000
## 1:4-1:3 -1.533 -4.870 1.803 0.870
## 1:4-2:1 -0.400 -3.737 2.937 1.000
## 1:4-2:2 1.800 -1.537 5.137 0.722
## 1:4-2:3 0.267 -3.070 3.603 1.000
## 1:4-3:1 -0.733 -4.070 2.603 1.000
## 1:4-3:2 0.700 -2.637 4.037 1.000
## 1:4-3:3 1.600 -1.737 4.937 0.838
## 2:1-1:1 -2.933 -6.270 0.403 0.122
## 2:2-1:1 -5.133 -8.470 -1.797 0.001
## 2:2-1:2 -1.833 -5.170 1.503 0.701
## 2:2-2:1 -2.200 -5.537 1.137 0.455
## 2:2-3:1 -2.533 -5.870 0.803 0.267
## 2:3-1:1 -3.600 -6.937 -0.263 0.027
## 2:3-1:2 -0.300 -3.637 3.037 1.000
## 2:3-1:3 -1.800 -5.137 1.537 0.722
## 2:3-2:1 -0.667 -4.003 2.670 1.000
## 2:3-2:2 1.533 -1.803 4.870 0.870
## 2:3-3:1 -1.000 -4.337 2.337 0.993
## 2:3-3:2 0.433 -2.903 3.770 1.000
## 2:4-1:1 -6.267 -9.603 -2.930 0.000
## 2:4-1:2 -2.967 -6.303 0.370 0.114
## 2:4-1:3 -4.467 -7.803 -1.130 0.003
## 2:4-1:4 -2.933 -6.270 0.403 0.122
## 2:4-2:1 -3.333 -6.670 0.003 0.050
## 2:4-2:2 -1.133 -4.470 2.203 0.981
## 2:4-2:3 -2.667 -6.003 0.670 0.209
## 2:4-3:1 -3.667 -7.003 -0.330 0.023
## 2:4-3:2 -2.233 -5.570 1.103 0.434
## 2:4-3:3 -1.333 -4.670 2.003 0.943
## 3:1-1:1 -2.600 -5.937 0.737 0.237
## 3:1-2:1 0.333 -3.003 3.670 1.000
## 3:2-1:1 -4.033 -7.370 -0.697 0.009
## 3:2-1:2 -0.733 -4.070 2.603 1.000
## 3:2-2:1 -1.100 -4.437 2.237 0.985
## 3:2-2:2 1.100 -2.237 4.437 0.985
## 3:2-3:1 -1.433 -4.770 1.903 0.911
## 3:3-1:1 -4.933 -8.270 -1.597 0.001
## 3:3-1:2 -1.633 -4.970 1.703 0.821
## 3:3-1:3 -3.133 -6.470 0.203 0.079
## 3:3-2:1 -2.000 -5.337 1.337 0.589
## 3:3-2:2 0.200 -3.137 3.537 1.000
## 3:3-2:3 -1.333 -4.670 2.003 0.943
## 3:3-3:1 -2.333 -5.670 1.003 0.373
## 3:3-3:2 -0.900 -4.237 2.437 0.997
## 3:4-1:1 -4.333 -7.670 -0.997 0.004
## 3:4-1:2 -1.033 -4.370 2.303 0.991
## 3:4-1:3 -2.533 -5.870 0.803 0.267
## 3:4-1:4 -1.000 -4.337 2.337 0.993
## 3:4-2:1 -1.400 -4.737 1.937 0.923
## 3:4-2:2 0.800 -2.537 4.137 0.999
## 3:4-2:3 -0.733 -4.070 2.603 1.000
## 3:4-2:4 1.933 -1.403 5.270 0.634
## 3:4-3:1 -1.733 -5.070 1.603 0.764
## 3:4-3:2 -0.300 -3.637 3.037 1.000
## 3:4-3:3 0.600 -2.737 3.937 1.000
Resposta (a) - A média do grupo a3:b4 não é significativamente menor do que a média do grupo a3:b1.
# x y
# 1 6.1 23.7
# 2 3.7 17.8
# 3 6.5 22.4
# 4 5.8 18.9
# 5 5.1 17.4
# 6 4.6 19.2
# 7 9.1 29.2
# 8 6.5 18.2
# 9 7.5 24.7
# 10 5.5 21.3
x = c(6.1, 3.7, 6.5, 5.8, 5.1, 4.6, 9.1, 6.5, 7.5, 5.5)
y = c(23.7, 17.8, 22.4, 18.9, 17.4, 19.2, 29.2, 18.2, 24.7, 21.3)
cbind(x,y)
## x y
## [1,] 6.1 23.7
## [2,] 3.7 17.8
## [3,] 6.5 22.4
## [4,] 5.8 18.9
## [5,] 5.1 17.4
## [6,] 4.6 19.2
## [7,] 9.1 29.2
## [8,] 6.5 18.2
## [9,] 7.5 24.7
## [10,] 5.5 21.3
m = lm(y~x)
s = summary(lm(y~x))
plot(x, y)
abline(m)
s
##
## Call:
## lm(formula = y ~ x)
##
## Residuals:
## Min 1Q Median 3Q Max
## -4.0535 -1.3674 0.6488 1.3736 2.2930
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 8.4969 2.8721 2.958 0.01819 *
## x 2.1164 0.4626 4.575 0.00181 **
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 2.105 on 8 degrees of freedom
## Multiple R-squared: 0.7235, Adjusted R-squared: 0.6889
## F-statistic: 20.93 on 1 and 8 DF, p-value: 0.001813
shapiro.test(m$res)
##
## Shapiro-Wilk normality test
##
## data: m$res
## W = 0.88759, p-value = 0.1593
library(lmtest)
## Loading required package: zoo
##
## Attaching package: 'zoo'
## The following objects are masked from 'package:base':
##
## as.Date, as.Date.numeric
library(zoo)
resettest(m)
##
## RESET test
##
## data: m
## RESET = 0.68732, df1 = 2, df2 = 6, p-value = 0.5386
lmtest::bptest(m)
##
## studentized Breusch-Pagan test
##
## data: m
## BP = 0.021785, df = 1, p-value = 0.8827
Resposta (a) - A hipótese Ho : a=0 é aceita.
# x y
# 1 10 104
# 2 12 58
# 3 13 67
# 4 22 111
# 5 14 73
# 6 18 87
# 7 8 86
# 8 9 46
# 9 17 176
# 10 7 34
# 11 10 53
# 12 12 57
x = c(10,12,13,22,14,18,8,9,17,7,10,12)
y = c(104,58,67,111,73,87,86,46,176,34,53,57)
cbind(x,y)
## x y
## [1,] 10 104
## [2,] 12 58
## [3,] 13 67
## [4,] 22 111
## [5,] 14 73
## [6,] 18 87
## [7,] 8 86
## [8,] 9 46
## [9,] 17 176
## [10,] 7 34
## [11,] 10 53
## [12,] 12 57
m = lm(y~x)
s = summary(lm(y~x))
plot(x, y)
abline(m)
s
##
## Call:
## lm(formula = y ~ x)
##
## Residuals:
## Min 1Q Median 3Q Max
## -19.756 -16.719 -14.264 -1.801 74.386
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 14.204 28.987 0.490 0.6347
## x 5.142 2.169 2.371 0.0392 *
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 32.07 on 10 degrees of freedom
## Multiple R-squared: 0.3599, Adjusted R-squared: 0.2958
## F-statistic: 5.622 on 1 and 10 DF, p-value: 0.03921
shapiro.test(m$res)
##
## Shapiro-Wilk normality test
##
## data: m$res
## W = 0.66761, p-value = 0.0004181
library(lmtest)
library(zoo)
resettest(m)
##
## RESET test
##
## data: m
## RESET = 0.35393, df1 = 2, df2 = 8, p-value = 0.7124
lmtest::bptest(m)
##
## studentized Breusch-Pagan test
##
## data: m
## BP = 0.65082, df = 1, p-value = 0.4198
Resposta (d) - A hipótese de que existe regressão é rejeitada.
# x y
# 1 16 44
# 2 18 67
# 3 15 32
# 4 12 18
# 5 14 7
# 6 11 1
# 7 15 18
# 8 12 -9
# 9 11 21
# 10 16 58
# 11 13 25
# 12 19 71
x = c(16,18,15,12,14,11,15,12,11,16,13,19)
y = c(44,67,32,18,7,1,18,-9,21,58,25,71)
cbind(x,y)
## x y
## [1,] 16 44
## [2,] 18 67
## [3,] 15 32
## [4,] 12 18
## [5,] 14 7
## [6,] 11 1
## [7,] 15 18
## [8,] 12 -9
## [9,] 11 21
## [10,] 16 58
## [11,] 13 25
## [12,] 19 71
m = lm(y~x)
s = summary(lm(y~x))
plot(x, y)
abline(m)
s
##
## Call:
## lm(formula = y ~ x)
##
## Residuals:
## Min 1Q Median 3Q Max
## -19.589 -6.572 1.222 7.264 19.859
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -92.167 22.291 -4.135 0.002029 **
## x 8.483 1.532 5.538 0.000248 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 13.41 on 10 degrees of freedom
## Multiple R-squared: 0.7541, Adjusted R-squared: 0.7296
## F-statistic: 30.67 on 1 and 10 DF, p-value: 0.0002481
shapiro.test(m$res)
##
## Shapiro-Wilk normality test
##
## data: m$res
## W = 0.92581, p-value = 0.3378
library(lmtest)
library(zoo)
resettest(m)
##
## RESET test
##
## data: m
## RESET = 1.5936, df1 = 2, df2 = 8, p-value = 0.2615
lmtest::bptest(m)
##
## studentized Breusch-Pagan test
##
## data: m
## BP = 1.661, df = 1, p-value = 0.1975
(e) A hipótese de que o modelo y = a + bx é correta é rejeitada.
# x y
# 1 7 338
# 2 10 204
# 3 11 208
# 4 11 210
# 5 12 222
# 6 13 229
# 7 14 235
# 8 15 247
# 9 15 259
# 10 17 266
# 11 17 270
# 12 17 550
x = c(7,10,11,11,12,13,14,15,15,17,17,17)
y = c(338,204,208,210,222,229,235,247,259,266,270,550)
cbind(x,y)
## x y
## [1,] 7 338
## [2,] 10 204
## [3,] 11 208
## [4,] 11 210
## [5,] 12 222
## [6,] 13 229
## [7,] 14 235
## [8,] 15 247
## [9,] 15 259
## [10,] 17 266
## [11,] 17 270
## [12,] 17 550
m = lm(y~x)
s = summary(lm(y~x))
plot(x, y)
abline(m)
s
##
## Call:
## lm(formula = y ~ x)
##
## Residuals:
## Min 1Q Median 3Q Max
## -42.20 -39.80 -37.20 -32.43 243.31
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 139.617 122.842 1.137 0.282
## x 9.828 9.038 1.087 0.302
##
## Residual standard error: 94.9 on 10 degrees of freedom
## Multiple R-squared: 0.1057, Adjusted R-squared: 0.01632
## F-statistic: 1.182 on 1 and 10 DF, p-value: 0.3024
shapiro.test(m$res)
##
## Shapiro-Wilk normality test
##
## data: m$res
## W = 0.52274, p-value = 0.00002612
library(lmtest)
library(zoo)
resettest(m)
##
## RESET test
##
## data: m
## RESET = 2.6408, df1 = 2, df2 = 8, p-value = 0.1316
lmtest::bptest(m)
##
## studentized Breusch-Pagan test
##
## data: m
## BP = 0.51211, df = 1, p-value = 0.4742
(a) A hipótese de que os resíduos são normais é aceita.
# x y
# 1 7.2 26.8
# 2 5.3 18.4
# 3 5.4 17.9
# 4 6.3 23.9
# 5 9.7 27.4
# 6 7.3 25.1
# 7 5.0 18.3
# 8 6.0 21.0
# 9 5.0 18.2
# 10 6.6 20.8
x = c(7.2,5.3,5.4,6.3,9.7,7.3,5.0,6.0,6.0,6.6)
y = c(26.8,18.4,17.9,23.9,27.4,25.1,18.3,21.0,18.2,20.8)
cbind(x,y)
## x y
## [1,] 7.2 26.8
## [2,] 5.3 18.4
## [3,] 5.4 17.9
## [4,] 6.3 23.9
## [5,] 9.7 27.4
## [6,] 7.3 25.1
## [7,] 5.0 18.3
## [8,] 6.0 21.0
## [9,] 6.0 18.2
## [10,] 6.6 20.8
m = lm(y~x)
s = summary(lm(y~x))
plot(x, y)
abline(m)
s
##
## Call:
## lm(formula = y ~ x)
##
## Residuals:
## Min 1Q Median 3Q Max
## -2.4566 -1.3295 -0.3173 1.1365 3.3349
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 6.6143 3.2813 2.016 0.07858 .
## x 2.3404 0.4965 4.713 0.00151 **
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 2.036 on 8 degrees of freedom
## Multiple R-squared: 0.7352, Adjusted R-squared: 0.7021
## F-statistic: 22.22 on 1 and 8 DF, p-value: 0.001515
shapiro.test(m$res)
##
## Shapiro-Wilk normality test
##
## data: m$res
## W = 0.9456, p-value = 0.6168
library(lmtest)
library(zoo)
resettest(m)
##
## RESET test
##
## data: m
## RESET = 2.7326, df1 = 2, df2 = 6, p-value = 0.1433
lmtest::bptest(m)
##
## studentized Breusch-Pagan test
##
## data: m
## BP = 1.1752, df = 1, p-value = 0.2783
(a) A hipótese de que os resíduos são normais é rejeitada.
# x y
# 1 18 180
# 2 16 84
# 3 14 76
# 4 18 89
# 5 10 56
# 6 10 52
# 7 13 126
# 8 15 73
# 9 12 120
# 10 17 87
# 11 13 68
# 12 10 48
x = c(18,16,14,18,10,10,13,15,12,17,13,10)
y = c(180,84,76,89,56,52,126,73,120,87,68,48)
cbind(x,y)
## x y
## [1,] 18 180
## [2,] 16 84
## [3,] 14 76
## [4,] 18 89
## [5,] 10 56
## [6,] 10 52
## [7,] 13 126
## [8,] 15 73
## [9,] 12 120
## [10,] 17 87
## [11,] 13 68
## [12,] 10 48
m = lm(y~x)
s = summary(lm(y~x))
plot(x, y)
abline(m)
s
##
## Call:
## lm(formula = y ~ x)
##
## Residuals:
## Min 1Q Median 3Q Max
## -28.368 -20.388 -13.438 6.797 62.632
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -8.421 46.452 -0.181 0.8598
## x 6.988 3.287 2.126 0.0594 .
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 32.82 on 10 degrees of freedom
## Multiple R-squared: 0.3112, Adjusted R-squared: 0.2424
## F-statistic: 4.519 on 1 and 10 DF, p-value: 0.05944
shapiro.test(m$res)
##
## Shapiro-Wilk normality test
##
## data: m$res
## W = 0.7654, p-value = 0.003888
library(lmtest)
library(zoo)
resettest(m)
##
## RESET test
##
## data: m
## RESET = 2.771, df1 = 2, df2 = 8, p-value = 0.1218
lmtest::bptest(m)
##
## studentized Breusch-Pagan test
##
## data: m
## BP = 2.1824, df = 1, p-value = 0.1396
(e) A hipótese de que os resíduos são normais é aceita.
# x y
# 1 15 37
# 2 21 143
# 3 17 64
# 4 18 68
# 5 17 54
# 6 17 48
# 7 13 13
# 8 19 100
# 9 10 25
# 10 15 24
# 11 14 28
# 12 14 19
x = c(15,21,17,18,17,17,13,19,10,15,14,14)
y = c(37,143,64,68,54,48,13,100,25,24,28,19)
cbind(x,y)
## x y
## [1,] 15 37
## [2,] 21 143
## [3,] 17 64
## [4,] 18 68
## [5,] 17 54
## [6,] 17 48
## [7,] 13 13
## [8,] 19 100
## [9,] 10 25
## [10,] 15 24
## [11,] 14 28
## [12,] 14 19
m = lm(y~x)
s = summary(lm(y~x))
plot(x, y)
abline(m)
s
##
## Call:
## lm(formula = y ~ x)
##
## Residuals:
## Min 1Q Median 3Q Max
## -18.537 -11.357 -6.280 2.323 38.744
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -126.305 32.088 -3.936 0.002792 **
## x 11.256 1.995 5.642 0.000215 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 19.51 on 10 degrees of freedom
## Multiple R-squared: 0.7609, Adjusted R-squared: 0.737
## F-statistic: 31.83 on 1 and 10 DF, p-value: 0.0002149
shapiro.test(m$res)
##
## Shapiro-Wilk normality test
##
## data: m$res
## W = 0.81983, p-value = 0.01589
library(lmtest)
library(zoo)
resettest(m)
##
## RESET test
##
## data: m
## RESET = 40.128, df1 = 2, df2 = 8, p-value = 0.00006751
lmtest::bptest(m)
##
## studentized Breusch-Pagan test
##
## data: m
## BP = 0.38903, df = 1, p-value = 0.5328
# Jogo 1 Jogo 2
# ______________ ______________
# R1 R2 R3 R1 R2 R3
# Pessoa 1 6.20 6.44 5.07 5.34 5.99 4.89
# Pessoa 2 6.36 8.76 6.82 5.48 4.27 4.40
# Pessoa 3 6.57 8.31 8.31 5.55 4.99 6.10
dados = c(6.20,6.44,5.07,5.34,5.99,4.89,
6.36,8.76,6.82,5.48,4.27,4.40,
6.57,8.31,8.31,5.55,4.99,6.1)
g1 = as.factor(rep(1:3, each = 6))
g2 = as.factor(rep(1:2, each = 3, times = 3))
a = aov(dados~g1*g2)
summary(a)
## Df Sum Sq Mean Sq F value Pr(>F)
## g1 2 2.970 1.485 2.110 0.163920
## g2 1 13.922 13.922 19.784 0.000796 ***
## g1:g2 2 3.713 1.856 2.638 0.112299
## Residuals 12 8.444 0.704
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Como há mais de uma resposta por célula, pode-se testar cada um dos efeitos, bem como a sua interação. Percebe-se que apenas o p-valor relativo ao fator jogo é significante, portanto pode-se dizer que um jogo é significativamente diferente do outro, considerado um α = 0.05.
Para demonstrar que algumas combinações de disciplinas com salas funcionam melhor que outras, deve-se buscar a significãncia para a interação dos fatores disciplina e sala (disciplina:sala). Assim sendo, são necessárias ao menos duas observações por célula.Como são propostas 4 disciplinas e 4 salas, o desenho de pesquisa deve contemplar ao menos 32 observações (4 × 4 × 2).
# x1 x2 x3 x4 x5 y
# 1 4 3 5 5 2 5
# 2 3 3 1 5 5 5
# 3 3 2 3 3 4 4
# 4 1 5 2 1 2 4
# 5 4 5 2 2 4 4
# 6 2 3 2 1 3 2
# 7 1 2 1 3 1 1
# 8 4 1 2 4 4 3
# 9 5 3 3 1 1 3
# 10 4 3 1 3 5 5
# 11 4 1 2 2 4 3
# 12 3 1 4 1 3 3
x1 = c(4,3,3,1,4,2,1,4,5,4,4,3)
x2 = c(3,3,2,5,5,3,2,1,3,3,1,1)
x3 = c(5,1,3,2,2,2,1,2,3,1,2,4)
x4 = c(5,5,3,1,2,1,3,4,1,3,2,1)
x5 = c(2,5,4,2,4,3,1,4,1,5,4,3)
y = c(5,5,4,4,4,2,1,3,3,5,3,3)
m = lm(y ~ x1 + x2 + x3 + x4 + x5, data.frame(x))
s = summary(m)
s
##
## Call:
## lm(formula = y ~ x1 + x2 + x3 + x4 + x5, data = data.frame(x))
##
## Residuals:
## Min 1Q Median 3Q Max
## -0.9596 -0.3186 0.0908 0.3106 0.7664
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -1.6924 1.0889 -1.554 0.1711
## x1 0.1404 0.2072 0.678 0.5233
## x2 0.5245 0.1679 3.123 0.0205 *
## x3 0.4292 0.2202 1.950 0.0991 .
## x4 0.2818 0.1592 1.770 0.1271
## x5 0.5115 0.1994 2.565 0.0426 *
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.7378 on 6 degrees of freedom
## Multiple R-squared: 0.8079, Adjusted R-squared: 0.6478
## F-statistic: 5.046 on 5 and 6 DF, p-value: 0.03688
shapiro.test(m$res)
##
## Shapiro-Wilk normality test
##
## data: m$res
## W = 0.94874, p-value = 0.6186
library(lmtest)
bptest(m)
##
## studentized Breusch-Pagan test
##
## data: m
## BP = 9.1864, df = 5, p-value = 0.1019
resettest(m)
##
## RESET test
##
## data: m
## RESET = 0.81719, df1 = 2, df2 = 4, p-value = 0.504
O p-value do teste RESET de Ramsey acima de 0.05 indica a correta forma funcional do modelo. Pode-se estimar que y é causado por x2 e x3 e que aproximadamente 64.8% da sua variação é explicada por essas duas variáveis.
# irrit horas
# 1 9 5
# 2 6 6
# 3 9 4
# 4 2 9
# 5 10 5
# 6 4 7
# 7 4 8
# 8 5 9
# 9 6 3
# 10 10 4
# 11 2 6
# 12 2 8
# 13 4 5
# 14 9 3
# 15 5 6
# 16 4 8
# 17 2 8
# 18 3 7
irrit = c(9,6,9,2,10,4,4,5,6,10,2,2,4,9,5,4,2,3)
horas = c(5,6,4,9,5,7,8,9,3,4,6,8,5,3,6,8,8,7)
m = lm(irrit ~ horas)
s = summary(m)
s
##
## Call:
## lm(formula = irrit ~ horas)
##
## Residuals:
## Min 1Q Median 3Q Max
## -3.5142 -1.3437 -0.0142 1.1505 3.4005
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 12.0258 1.6317 7.37 0.00000158 ***
## horas -1.0853 0.2529 -4.29 0.000562 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 2.031 on 16 degrees of freedom
## Multiple R-squared: 0.535, Adjusted R-squared: 0.5059
## F-statistic: 18.41 on 1 and 16 DF, p-value: 0.0005617
plot(horas, irrit, xlim = c(0, max(horas)))
abline(m)
shapiro.test(m$res)
##
## Shapiro-Wilk normality test
##
## data: m$res
## W = 0.97374, p-value = 0.8644
bptest(m)
##
## studentized Breusch-Pagan test
##
## data: m
## BP = 1.4731, df = 1, p-value = 0.2249
reset(m)
##
## RESET test
##
## data: m
## RESET = 2.3335, df1 = 2, df2 = 14, p-value = 0.1335
Observa-se uma estatística F significante, indicando a presença de regressão. Os testes de adequação não revelaram anormalidades. Como esperado, o sinal do coeficiente da variável horas é negativo, indicando que quanto mais horas de sono, menor a irritabilidade. Para zero horas de sono, tem-se uma irritablidade máxima em torno de 12.Observa-se um r^2 ajustado de 0.506, indicando que aproximadamente 51% da variância da irritabilidade é explicada pelas horas de sono.
# 1 2 3 4 5 6
# gr1 16 22 24 15
# gr2 12 11 13 18 18
# gr3 16 19 18 19 17 19
# gr4 20 21 18 19
dados = c(16, 22, 24, 15, 12, 11, 13, 18, 13, 16, 19, 18, 19, 17, 19, 20, 21, 18, 19)
g = c(rep(1, 4), rep(2, 5), rep(3, 6), rep(4, 4))
model = aov(dados ~ as.factor(g))
summary(model)
## Df Sum Sq Mean Sq F value Pr(>F)
## as.factor(g) 3 113.5 37.82 5.62 0.00871 **
## Residuals 15 101.0 6.73
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
TukeyHSD(model)
## Tukey multiple comparisons of means
## 95% family-wise confidence level
##
## Fit: aov(formula = dados ~ as.factor(g))
##
## $`as.factor(g)`
## diff lwr upr p adj
## 2-1 -5.85 -10.86568399 -0.834316 0.0199378
## 3-1 -1.25 -6.07634417 3.576344 0.8767443
## 4-1 0.25 -5.03699515 5.536995 0.9990542
## 3-2 4.60 0.07248784 9.127512 0.0458412
## 4-2 6.10 1.08431601 11.115684 0.0150575
## 4-3 1.50 -3.32634417 6.326344 0.8071663
A média do grupo gr3 é significativamente maior que a média do grupo gr2
# t1 t2 t3 t4 t5 t6
# gr1 16 12 14 15 19 20
# gr2 12 11 13 18 17 21
# gr3 16 19 18 19 17 19
# gr4 20 21 18 20 21 23
dados = c(16, 12, 14, 15, 19, 20,
12, 11, 13, 18, 17, 21,
16, 19, 18, 19, 17, 19,
20, 21, 18, 20, 21, 23)
g1 = as.factor(rep(1:4, each = 6))
g2 = as.factor(rep(1:6, times = 4))
a = aov(dados~g1+g2)
summary(a)
## Df Sum Sq Mean Sq F value Pr(>F)
## g1 3 97.13 32.38 7.573 0.00259 **
## g2 5 80.71 16.14 3.776 0.02057 *
## Residuals 15 64.13 4.28
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
thsd = TukeyHSD(a, ordered = FALSE)
thsd
## Tukey multiple comparisons of means
## 95% family-wise confidence level
##
## Fit: aov(formula = dados ~ g1 + g2)
##
## $g1
## diff lwr upr p adj
## 2-1 -0.6666667 -4.1071845 2.773851 0.9427715
## 3-1 2.0000000 -1.4405178 5.440518 0.3696429
## 4-1 4.5000000 1.0594822 7.940518 0.0089545
## 3-2 2.6666667 -0.7738511 6.107184 0.1589008
## 4-2 5.1666667 1.7261489 8.607184 0.0029866
## 4-3 2.5000000 -0.9405178 5.940518 0.1995226
##
## $g2
## diff lwr upr p adj
## 2-1 -0.250000000000001776357 -5.00005366828 4.500054 0.9999748
## 3-1 -0.250000000000000000000 -5.00005366828 4.500054 0.9999748
## 4-1 1.999999999999996447286 -2.75005366828 6.750054 0.7443654
## 5-1 2.500000000000000000000 -2.25005366828 7.250054 0.5459628
## 6-1 4.750000000000000000000 -0.00005366828 9.500054 0.0500034
## 3-2 0.000000000000001776357 -4.75005366828 4.750054 1.0000000
## 4-2 2.249999999999998223643 -2.50005366828 7.000054 0.6466577
## 5-2 2.750000000000001776357 -2.00005366828 7.500054 0.4489559
## 6-2 5.000000000000001776357 0.24994633172 9.750054 0.0363675
## 4-3 2.249999999999996447286 -2.50005366828 7.000054 0.6466577
## 5-3 2.750000000000000000000 -2.00005366828 7.500054 0.4489559
## 6-3 5.000000000000000000000 0.24994633172 9.750054 0.0363675
## 5-4 0.500000000000003552714 -4.25005366828 5.250054 0.9992431
## 6-4 2.750000000000003552714 -2.00005366828 7.500054 0.4489559
## 6-5 2.250000000000000000000 -2.50005366828 7.000054 0.6466577
A média do grupo t6 é significativamente maior que a média do grupo t3
# ____________________________________ ______________________________________
# b1 b1 b1 b2 b2 b2 b3 b3 b3 b4 b4 b4
#a1 13.9 14.7 12.5 13.9 13.3 12.7 14.1 12.3 13.8 14.0 10.9 13.0
#a2 11.9 12.9 14.4 12.3 11.8 11.9 11.6 13.3 13.1 12.2 10.3 10.5
#a3 12.9 14.6 12.9 11.8 9.6 11.7 12.2 13.5 10.4 12.6 10.1 12.4
dados = c(13.9,14.7,12.5,13.9,13.3,12.7,14.1,12.3,13.8,14.0,10.9,13.0,
11.9,12.9,14.4,12.3,11.8,11.9,11.6,13.3,13.1,12.2,10.3,10.5,
12.9,14.6,12.9,11.8,9.6,11.7,12.2,13.5,10.4,12.6,10.1,12.4)
g1 = as.factor(rep(1:3, each = 12))
g2 = as.factor(rep(1:4, each = 3, times = 3))
a = aov(dados~g1*g2)
summary(a)
## Df Sum Sq Mean Sq F value Pr(>F)
## g1 2 10.445 5.222 4.043 0.0307 *
## g2 3 13.887 4.629 3.584 0.0285 *
## g1:g2 6 4.768 0.795 0.615 0.7160
## Residuals 24 31.000 1.292
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
TukeyHSD(a)
## Tukey multiple comparisons of means
## 95% family-wise confidence level
##
## Fit: aov(formula = dados ~ g1 * g2)
##
## $g1
## diff lwr upr p adj
## 2-1 -1.075 -2.233692 0.08369219 0.0725588
## 3-1 -1.200 -2.358692 -0.04130781 0.0413740
## 3-2 -0.125 -1.283692 1.03369219 0.9608446
##
## $g2
## diff lwr upr p adj
## 2-1 -1.3000000 -2.7779478 0.1779478 0.0988577
## 3-1 -0.7111111 -2.1890589 0.7668367 0.5552192
## 4-1 -1.6333333 -3.1112811 -0.1553856 0.0264734
## 3-2 0.5888889 -0.8890589 2.0668367 0.6934278
## 4-2 -0.3333333 -1.8112811 1.1446144 0.9239589
## 4-3 -0.9222222 -2.4001700 0.5557255 0.3350388
##
## $`g1:g2`
## diff lwr upr p adj
## 2:1-1:1 -0.63333333 -3.9792157 2.7125490 0.9998815
## 3:1-1:1 -0.23333333 -3.5792157 3.1125490 1.0000000
## 1:2-1:1 -0.40000000 -3.7458823 2.9458823 0.9999989
## 2:2-1:1 -1.70000000 -5.0458823 1.6458823 0.7861326
## 3:2-1:1 -2.66666667 -6.0125490 0.6792157 0.2119744
## 1:3-1:1 -0.30000000 -3.6458823 3.0458823 0.9999999
## 2:3-1:1 -1.03333333 -4.3792157 2.3125490 0.9908857
## 3:3-1:1 -1.66666667 -5.0125490 1.6792157 0.8050243
## 1:4-1:1 -1.06666667 -4.4125490 2.2792157 0.9883328
## 2:4-1:1 -2.70000000 -6.0458823 0.6458823 0.1989700
## 3:4-1:1 -2.00000000 -5.3458823 1.3458823 0.5926454
## 3:1-2:1 0.40000000 -2.9458823 3.7458823 0.9999989
## 1:2-2:1 0.23333333 -3.1125490 3.5792157 1.0000000
## 2:2-2:1 -1.06666667 -4.4125490 2.2792157 0.9883328
## 3:2-2:1 -2.03333333 -5.3792157 1.3125490 0.5700123
## 1:3-2:1 0.33333333 -3.0125490 3.6792157 0.9999998
## 2:3-2:1 -0.40000000 -3.7458823 2.9458823 0.9999989
## 3:3-2:1 -1.03333333 -4.3792157 2.3125490 0.9908857
## 1:4-2:1 -0.43333333 -3.7792157 2.9125490 0.9999974
## 2:4-2:1 -2.06666667 -5.4125490 1.2792157 0.5474444
## 3:4-2:1 -1.36666667 -4.7125490 1.9792157 0.9343023
## 1:2-3:1 -0.16666667 -3.5125490 3.1792157 1.0000000
## 2:2-3:1 -1.46666667 -4.8125490 1.8792157 0.9000319
## 3:2-3:1 -2.43333333 -5.7792157 0.9125490 0.3209375
## 1:3-3:1 -0.06666667 -3.4125490 3.2792157 1.0000000
## 2:3-3:1 -0.80000000 -4.1458823 2.5458823 0.9989503
## 3:3-3:1 -1.43333333 -4.7792157 1.9125490 0.9124657
## 1:4-3:1 -0.83333333 -4.1792157 2.5125490 0.9984910
## 2:4-3:1 -2.46666667 -5.8125490 0.8792157 0.3034535
## 3:4-3:1 -1.76666667 -5.1125490 1.5792157 0.7462440
## 2:2-1:2 -1.30000000 -4.6458823 2.0458823 0.9521951
## 3:2-1:2 -2.26666667 -5.6125490 1.0792157 0.4171614
## 1:3-1:2 0.10000000 -3.2458823 3.4458823 1.0000000
## 2:3-1:2 -0.63333333 -3.9792157 2.7125490 0.9998815
## 3:3-1:2 -1.26666667 -4.6125490 2.0792157 0.9597342
## 1:4-1:2 -0.66666667 -4.0125490 2.6792157 0.9998060
## 2:4-1:2 -2.30000000 -5.6458823 1.0458823 0.3968278
## 3:4-1:2 -1.60000000 -4.9458823 1.7458823 0.8403792
## 3:2-2:2 -0.96666667 -4.3125490 2.3792157 0.9946632
## 1:3-2:2 1.40000000 -1.9458823 4.7458823 0.9238867
## 2:3-2:2 0.66666667 -2.6792157 4.0125490 0.9998060
## 3:3-2:2 0.03333333 -3.3125490 3.3792157 1.0000000
## 1:4-2:2 0.63333333 -2.7125490 3.9792157 0.9998815
## 2:4-2:2 -1.00000000 -4.3458823 2.3458823 0.9929754
## 3:4-2:2 -0.30000000 -3.6458823 3.0458823 0.9999999
## 1:3-3:2 2.36666667 -0.9792157 5.7125490 0.3577354
## 2:3-3:2 1.63333333 -1.7125490 4.9792157 0.8231259
## 3:3-3:2 1.00000000 -2.3458823 4.3458823 0.9929754
## 1:4-3:2 1.60000000 -1.7458823 4.9458823 0.8403792
## 2:4-3:2 -0.03333333 -3.3792157 3.3125490 1.0000000
## 3:4-3:2 0.66666667 -2.6792157 4.0125490 0.9998060
## 2:3-1:3 -0.73333333 -4.0792157 2.6125490 0.9995250
## 3:3-1:3 -1.36666667 -4.7125490 1.9792157 0.9343023
## 1:4-1:3 -0.76666667 -4.1125490 2.5792157 0.9992855
## 2:4-1:3 -2.40000000 -5.7458823 0.9458823 0.3390375
## 3:4-1:3 -1.70000000 -5.0458823 1.6458823 0.7861326
## 3:3-2:3 -0.63333333 -3.9792157 2.7125490 0.9998815
## 1:4-2:3 -0.03333333 -3.3792157 3.3125490 1.0000000
## 2:4-2:3 -1.66666667 -5.0125490 1.6792157 0.8050243
## 3:4-2:3 -0.96666667 -4.3125490 2.3792157 0.9946632
## 1:4-3:3 0.60000000 -2.7458823 3.9458823 0.9999299
## 2:4-3:3 -1.03333333 -4.3792157 2.3125490 0.9908857
## 3:4-3:3 -0.33333333 -3.6792157 3.0125490 0.9999998
## 2:4-1:4 -1.63333333 -4.9792157 1.7125490 0.8231259
## 3:4-1:4 -0.93333333 -4.2792157 2.4125490 0.9960070
## 3:4-2:4 0.70000000 -2.6458823 4.0458823 0.9996922
thsd = TukeyHSD(a)[[3]]
options(scipen = 999)
round(thsd[order(rownames(thsd)),],3)
## diff lwr upr p adj
## 1:2-1:1 -0.400 -3.746 2.946 1.000
## 1:2-2:1 0.233 -3.113 3.579 1.000
## 1:2-3:1 -0.167 -3.513 3.179 1.000
## 1:3-1:1 -0.300 -3.646 3.046 1.000
## 1:3-1:2 0.100 -3.246 3.446 1.000
## 1:3-2:1 0.333 -3.013 3.679 1.000
## 1:3-2:2 1.400 -1.946 4.746 0.924
## 1:3-3:1 -0.067 -3.413 3.279 1.000
## 1:3-3:2 2.367 -0.979 5.713 0.358
## 1:4-1:1 -1.067 -4.413 2.279 0.988
## 1:4-1:2 -0.667 -4.013 2.679 1.000
## 1:4-1:3 -0.767 -4.113 2.579 0.999
## 1:4-2:1 -0.433 -3.779 2.913 1.000
## 1:4-2:2 0.633 -2.713 3.979 1.000
## 1:4-2:3 -0.033 -3.379 3.313 1.000
## 1:4-3:1 -0.833 -4.179 2.513 0.998
## 1:4-3:2 1.600 -1.746 4.946 0.840
## 1:4-3:3 0.600 -2.746 3.946 1.000
## 2:1-1:1 -0.633 -3.979 2.713 1.000
## 2:2-1:1 -1.700 -5.046 1.646 0.786
## 2:2-1:2 -1.300 -4.646 2.046 0.952
## 2:2-2:1 -1.067 -4.413 2.279 0.988
## 2:2-3:1 -1.467 -4.813 1.879 0.900
## 2:3-1:1 -1.033 -4.379 2.313 0.991
## 2:3-1:2 -0.633 -3.979 2.713 1.000
## 2:3-1:3 -0.733 -4.079 2.613 1.000
## 2:3-2:1 -0.400 -3.746 2.946 1.000
## 2:3-2:2 0.667 -2.679 4.013 1.000
## 2:3-3:1 -0.800 -4.146 2.546 0.999
## 2:3-3:2 1.633 -1.713 4.979 0.823
## 2:4-1:1 -2.700 -6.046 0.646 0.199
## 2:4-1:2 -2.300 -5.646 1.046 0.397
## 2:4-1:3 -2.400 -5.746 0.946 0.339
## 2:4-1:4 -1.633 -4.979 1.713 0.823
## 2:4-2:1 -2.067 -5.413 1.279 0.547
## 2:4-2:2 -1.000 -4.346 2.346 0.993
## 2:4-2:3 -1.667 -5.013 1.679 0.805
## 2:4-3:1 -2.467 -5.813 0.879 0.303
## 2:4-3:2 -0.033 -3.379 3.313 1.000
## 2:4-3:3 -1.033 -4.379 2.313 0.991
## 3:1-1:1 -0.233 -3.579 3.113 1.000
## 3:1-2:1 0.400 -2.946 3.746 1.000
## 3:2-1:1 -2.667 -6.013 0.679 0.212
## 3:2-1:2 -2.267 -5.613 1.079 0.417
## 3:2-2:1 -2.033 -5.379 1.313 0.570
## 3:2-2:2 -0.967 -4.313 2.379 0.995
## 3:2-3:1 -2.433 -5.779 0.913 0.321
## 3:3-1:1 -1.667 -5.013 1.679 0.805
## 3:3-1:2 -1.267 -4.613 2.079 0.960
## 3:3-1:3 -1.367 -4.713 1.979 0.934
## 3:3-2:1 -1.033 -4.379 2.313 0.991
## 3:3-2:2 0.033 -3.313 3.379 1.000
## 3:3-2:3 -0.633 -3.979 2.713 1.000
## 3:3-3:1 -1.433 -4.779 1.913 0.912
## 3:3-3:2 1.000 -2.346 4.346 0.993
## 3:4-1:1 -2.000 -5.346 1.346 0.593
## 3:4-1:2 -1.600 -4.946 1.746 0.840
## 3:4-1:3 -1.700 -5.046 1.646 0.786
## 3:4-1:4 -0.933 -4.279 2.413 0.996
## 3:4-2:1 -1.367 -4.713 1.979 0.934
## 3:4-2:2 -0.300 -3.646 3.046 1.000
## 3:4-2:3 -0.967 -4.313 2.379 0.995
## 3:4-2:4 0.700 -2.646 4.046 1.000
## 3:4-3:1 -1.767 -5.113 1.579 0.746
## 3:4-3:2 0.667 -2.679 4.013 1.000
## 3:4-3:3 -0.333 -3.679 3.013 1.000
A média do grupo a3:b2 é significativamente menor que a média do grupo a1:b1
# x y
# 1 7.7 -29.5
# 2 6.0 -23.7
# 3 5.6 -19.7
# 4 5.2 -19.0
# 5 3.7 -14.2
# 6 6.4 -22.7
# 7 4.2 -16.4
# 8 4.7 -14.9
# 9 6.7 -24.9
# 10 3.4 -14.3
x = c(7.7,6.0,5.6,5.2,3.7,6.4,4.2,4.7,6.7,3.4)
y = c(-29.5,-23.7,-19.7,-19.0,-14.2,-22.7,-16.4,-14.9,-24.9,-14.3)
cbind(x,y)
## x y
## [1,] 7.7 -29.5
## [2,] 6.0 -23.7
## [3,] 5.6 -19.7
## [4,] 5.2 -19.0
## [5,] 3.7 -14.2
## [6,] 6.4 -22.7
## [7,] 4.2 -16.4
## [8,] 4.7 -14.9
## [9,] 6.7 -24.9
## [10,] 3.4 -14.3
m = lm(y~x)
s = summary(lm(y~x))
plot(x, y)
abline(m)
s
##
## Call:
## lm(formula = y ~ x)
##
## Residuals:
## Min 1Q Median 3Q Max
## -1.4710 -0.9873 -0.1997 0.8360 2.6388
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -0.5109 1.8389 -0.278 0.788
## x -3.6230 0.3332 -10.872 0.00000453 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 1.383 on 8 degrees of freedom
## Multiple R-squared: 0.9366, Adjusted R-squared: 0.9287
## F-statistic: 118.2 on 1 and 8 DF, p-value: 0.000004531
shapiro.test(m$res)
##
## Shapiro-Wilk normality test
##
## data: m$res
## W = 0.93258, p-value = 0.4737
library(lmtest)
library(zoo)
resettest(m)
##
## RESET test
##
## data: m
## RESET = 1.9528, df1 = 2, df2 = 6, p-value = 0.2222
lmtest::bptest(m)
##
## studentized Breusch-Pagan test
##
## data: m
## BP = 0.24648, df = 1, p-value = 0.6196
A hipótese de que o modelo y = a + bx é correta é rejeitada
# x y
# 1 13 -460
# 2 13 -468
# 3 15 251
# 4 15 251
# 5 15 251
# 6 16 253
# 7 15 256
# 8 16 261
# 9 17 271
# 10 17 271
# 11 18 574
# 12 20 602
x = c(13,13,15,15,15,16,15,16,17,17,18,20)
y = c(-460,-468,251,251,251,253,256,261,271,271,574,602)
cbind(x,y)
## x y
## [1,] 13 -460
## [2,] 13 -468
## [3,] 15 251
## [4,] 15 251
## [5,] 15 251
## [6,] 16 253
## [7,] 15 256
## [8,] 16 261
## [9,] 17 271
## [10,] 17 271
## [11,] 18 574
## [12,] 20 602
m = lm(y~x)
s = summary(lm(y~x))
plot(x, y)
abline(m)
s
##
## Call:
## lm(formula = y ~ x)
##
## Residuals:
## Min 1Q Median 3Q Max
## -254.66 -113.70 40.36 177.69 182.69
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -2076.55 427.13 -4.862 0.000660 ***
## x 143.32 26.78 5.351 0.000323 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 177 on 10 degrees of freedom
## Multiple R-squared: 0.7412, Adjusted R-squared: 0.7153
## F-statistic: 28.64 on 1 and 10 DF, p-value: 0.000323
shapiro.test(m$res)
##
## Shapiro-Wilk normality test
##
## data: m$res
## W = 0.87547, p-value = 0.07671
library(lmtest)
library(zoo)
resettest(m)
##
## RESET test
##
## data: m
## RESET = 14.632, df1 = 2, df2 = 8, p-value = 0.002124
lmtest::bptest(m)
##
## studentized Breusch-Pagan test
##
## data: m
## BP = 4.2862, df = 1, p-value = 0.03842
A hipótese de que os resíduos são normais é rejeitada
x = c(14,12,15,12,23,12,15,18,17,17,15,12)
y = c(29,12,53,8,163,21,26,84,52,64,26,14)
cbind(x,y)
## x y
## [1,] 14 29
## [2,] 12 12
## [3,] 15 53
## [4,] 12 8
## [5,] 23 163
## [6,] 12 21
## [7,] 15 26
## [8,] 18 84
## [9,] 17 52
## [10,] 17 64
## [11,] 15 26
## [12,] 12 14
m = lm(y~x)
s = summary(lm(y~x))
plot(x, y)
abline(m)
s
##
## Call:
## lm(formula = y ~ x)
##
## Residuals:
## Min 1Q Median 3Q Max
## -17.872 -8.402 2.127 8.598 17.009
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -147.601 18.654 -7.913 0.000012962 ***
## x 12.765 1.205 10.598 0.000000931 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 13.07 on 10 degrees of freedom
## Multiple R-squared: 0.9182, Adjusted R-squared: 0.9101
## F-statistic: 112.3 on 1 and 10 DF, p-value: 0.0000009315
shapiro.test(m$res)
##
## Shapiro-Wilk normality test
##
## data: m$res
## W = 0.90899, p-value = 0.2071
library(lmtest)
library(zoo)
resettest(m)
##
## RESET test
##
## data: m
## RESET = 5.3289, df1 = 2, df2 = 8, p-value = 0.0338
lmtest::bptest(m)
##
## studentized Breusch-Pagan test
##
## data: m
## BP = 1.3071, df = 1, p-value = 0.2529
A hipótese de que o modelo y = a + bx é correta é aceita
x = c(21,28,26,28,19,25,23,26,19,23,20,17,19,20)
y = c(80,81,82,93,94,99,103,107,110,114,117,124,125,149)
cbind(x,y)
## x y
## [1,] 21 80
## [2,] 28 81
## [3,] 26 82
## [4,] 28 93
## [5,] 19 94
## [6,] 25 99
## [7,] 23 103
## [8,] 26 107
## [9,] 19 110
## [10,] 23 114
## [11,] 20 117
## [12,] 17 124
## [13,] 19 125
## [14,] 20 149
m = lm(y~x)
s = summary(lm(y~x))
plot(x, y)
abline(m)
s
##
## Call:
## lm(formula = y ~ x)
##
## Residuals:
## Min 1Q Median 3Q Max
## -30.007 -7.010 1.493 7.770 35.889
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 175.203 28.631 6.119 0.0000518 ***
## x -3.105 1.261 -2.462 0.0299 *
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 16.61 on 12 degrees of freedom
## Multiple R-squared: 0.3356, Adjusted R-squared: 0.2802
## F-statistic: 6.061 on 1 and 12 DF, p-value: 0.02994
shapiro.test(m$res)
##
## Shapiro-Wilk normality test
##
## data: m$res
## W = 0.95761, p-value = 0.6836
library(lmtest)
library(zoo)
resettest(m)
##
## RESET test
##
## data: m
## RESET = 0.015172, df1 = 2, df2 = 10, p-value = 0.985
lmtest::bptest(m)
##
## studentized Breusch-Pagan test
##
## data: m
## BP = 0.98963, df = 1, p-value = 0.3198
A hipótese Ho : b = −5 é rejeitada