Simulação e aleatorizações baseadas em dados ou distribuições teóricas buscando soluções numéricas.
Reamostragem com reposição
Reamostragem de subconjunto
Não assumem a distribuição de probabilidade teórica
'data.frame': 200 obs. of 2 variables:
$ local: chr "PECB" "PECB" "PECB" "PECB" ...
$ pap : num 46 29 48 42 21 25 49 41 26 47 ...
PEIC PECB
25.495 35.640
PECB
10.145
par(mar= c(4,4,2,2),las=1, cex =1.5,cex.axis = 1.2, cex.lab= 1.2)
boxplot(amospalm$pap ~ local, col="gray", xlab = "Local",
ylab = "PAP (cm)", outline=FALSE)
points(x= jitter(rep(1,100), factor=2), y = amospalm$pap[local=="PEIC"],
pch=16, col=rgb(1,0,0, alpha=0.3) )
points(x= jitter(rep(2,100), factor=2), y = amospalm$pap[local=="PECB"],
pch=16, col=rgb(0,0,1, alpha=0.3))
mtext(at=1.5, side=3, line=0.5, text =paste("diferença =",
round(difpalm,1)), cex = 2)
PEIC PECB
31.465 29.670
PECB
-1.795
PECB
2.425
PECB
-2.245
[1] 1
[1] 0.001
[1] 1
[1] 0.001
p-valor
Plantas estão distribuídas aleatoriamente em uma parcela?
xp yp
1 8 3
2 6 14
3 5 29
1 2 3
1 0.00000 11.18034 26.1725
2 11.18034 0.00000 15.0333
3 26.17250 15.03330 0.0000
95 96 97 98 99 100
2.000000 6.324555 6.708204 2.828427 5.099020 4.000000
[1] 4.403911
rdistmat <- as.matrix(dist(rxy, diag = FALSE, upper=TRUE))
diag(rdistmat) <- NA
rnnd <- apply(rdistmat, 1, min, na.rm=TRUE)
mean(rnnd)
[1] 5.938513
[1] 4.403911 NA NA NA NA
[1] 4.403911 5.356657 5.147929 5.214187 4.814227 5.571546 5.211867
[8] 5.604144 5.046847 5.423152
[1] 7
[1] 0.007
are=c(6,10,8,6,14,17,9,11,7,11)
arg=c(17,15,3,11,14,12,12,8,10,13)
hum=c(13,16,9,12,15,16,17,13,18,14)
crop <- data.frame(solo = rep(c("are", "arg", "hum"), each=10), colhe = c(are, arg, hum))
head(crop)
solo colhe
1 are 6
2 are 10
3 are 8
4 are 6
5 are 14
6 are 17
\[F=\frac{\sigma_{entre}^2}{\sigma_{intra}^2}\]
are arg hum
9.9 11.5 14.3
[1] 11.9
are arg hum
-2.0 -0.4 2.4
[1] 0
[1] 4.8
[1] 4.8 NA NA NA NA
[1] 4.8 0.8 1.6 3.0 3.0 5.4 3.0 0.4 2.4 3.4
[1] 27
[1] 0.027
Davis (1990). Appetite (15)13-21
sex weight height repwt repht
F:112 Min. : 39.0 Min. : 57.0 Min. : 41.00 Min. :148.0
M: 88 1st Qu.: 55.0 1st Qu.:164.0 1st Qu.: 55.00 1st Qu.:160.5
Median : 63.0 Median :169.5 Median : 63.00 Median :168.0
Mean : 65.8 Mean :170.0 Mean : 65.62 Mean :168.5
3rd Qu.: 74.0 3rd Qu.:177.2 3rd Qu.: 73.50 3rd Qu.:175.0
Max. :166.0 Max. :197.0 Max. :124.00 Max. :200.0
NA's :17 NA's :17
Davis (1990). Appetite (15)13-21
sex weight height repwt repht
12 F 166 57 56 163
'data.frame': 199 obs. of 3 variables:
$ sex : Factor w/ 2 levels "F","M": 2 1 1 2 1 2 2 2 2 2 ...
$ weight: int 77 58 53 68 59 76 76 69 71 65 ...
$ height: int 182 161 161 177 157 170 167 186 178 171 ...
(Intercept) height
-130.746984 1.149222
\[ \hat{\beta} =\frac{ \sum_{i=1}^{n}(x_i - \bar{x})(y_i - \bar{y})}{ \sum_{i=1}^{n}(x_i - \bar{x})^2}\]
[1] 182 161 161 177 157
[1] 175 173 157 175 179
sex | weight | height | simh |
---|---|---|---|
M | 77 | 182 | 172 |
F | 58 | 161 | 173 |
F | 53 | 161 | 162 |
M | 68 | 177 | 164 |
F | 59 | 157 | 183 |
M | 76 | 170 | 183 |
(Intercept) height
-130.746984 1.149222
bobs <- round(coef(lmdavis)[2],3)
lmsim <- lm(weight ~ simh, data = Davis)
(bsim <- round(coef(lmsim)[2], 3))
simh
-0.136
slope simulado = -0.136
[1] 0.001
\[ \hat{\alpha}_m \neq \hat{\alpha}_f\]
Os sexos apresentam relações diferentes:
\[ \hat{\beta}_m \neq \hat{\beta}_f\]
[1] "a" "e" "d" "c" "b"
[1] "d" "b" "b" "a" "d"
[1] "a" "e" "d" "b" "b" "c" "a" "a" "c" "d"
[1] 113.4
[1] 120 107 110 116 114 111 113 117 114 112
[1] 114 116 107 117 110 112 120 112 117 111
[1] 112 117 116 116 111 107 114 116 107 117
[1] 113.4
[1] 112.2
[1] 111.3
[1] 115.6
https://github.com/lageIBUSP/Rsampling-shiny