poisson.test:
Hipotesis 1: \[H0:λi≤10 \frac{casos}{día}\\Ha:λi>10\frac{casos}{día}\]
# El muestreo se hizo en un lapso de 15 días
# Se encontraron 162 casos nuevos en los 15 días
# Incidencia estimada 162/15 = 10.8
poisson.test(x = 162, T = 15, r = 10, alternative = 'g')##
## Exact Poisson test
##
## data: 162 time base: 15
## number of events = 162, time base = 15, p-value = 0.1734
## alternative hypothesis: true event rate is greater than 10
## 95 percent confidence interval:
## 9.443211 Inf
## sample estimates:
## event rate
## 10.8
Hipotesis 2: \[H_{0}:λ_{Lote_{1}}=λ_{Lote_{2}}\\H_{a}:λ_{Lote_{1}}≠λ_{Lote_{2}}\]
# El muestreo en 2 LOTES se hizo en un lapso de 15 días
# Lote 1: 54 casos nuevos en los 15 días
# Lote 2: 62 casos nuevos en los 15 días
# La hipotesis es r = 1 por lambda_lote1/lambda_lot2 = 1
# ratio muestra: (54/15)/(62/15) = 0.871
poisson.test(x = c(54, 62), T = 15, r = 1, alternative = 't')##
## Comparison of Poisson rates
##
## data: c(54, 62) time base: 15
## count1 = 54, expected count1 = 58, p-value = 0.5159
## alternative hypothesis: true rate ratio is not equal to 1
## 95 percent confidence interval:
## 0.5933221 1.2750906
## sample estimates:
## rate ratio
## 0.8709677
Pruebas paramétricas: Media
Datos: 1 muestra
Condiciones de validez: n > 30 o normalidad (Prueba de normalidad de Shapiro-Wilk y gráfico de normalidad)
Función R: t.test(x,…)
\(\mu\) = media poblacional
\(\bar{x}\) = media muestral
\[\bar{x} \rightarrow \mu\] Hipótesis :
\[H0:μ_{pH}≥5\\Ha:μ_{pH}<5\]
set.seed(123)
pH = runif(n = 40, min = 4, max = 5.3)
mean(pH)## [1] 4.732894
hist(pH,border = 4,col = "white" )set.seed(49)
pH_sim = replicate(n = 100,
runif(n = 40, min = 4, max = 5.3))
dim(pH_sim)## [1] 40 100
media_sim = colMeans(pH_sim)
hist(media_sim,border = 4,col = "white")
abline(v=mean(pH), col='blue', lty = 2)res_tt = t.test(x = pH, mu = 5, alternative = 'l')
ifelse(res_tt$p.value<0.05, 'Rechazo Ho', 'No rechazo Ho')## [1] "Rechazo Ho"
\[H0:μ_{NDVI_{Directa}}≥μ_{NDVI_{Indirecto}}\\Ha:μ_{NDVI_{Directa}}<μ_{NDVI_{Indirecto}}\]
set.seed(123)
ndvi_directo = runif(n = 60, min = 0.1, max = 0.35)
ndvi_indirecto = runif(n = 60, min = 0.3, max = 0.70)
mean(ndvi_directo)## [1] 0.2263801
mean(ndvi_indirecto)## [1] 0.5063734
boxplot(cbind(
ndvi_directo,
ndvi_indirecto
),
col = "white",
border = 4
)\[H0:σ^2_{NDVI_{Directa}}=σ^2_{NDVI_{Indirecto}}\\Ha:σ^2_{NDVI_{Directa}}≠σ^2_{NDVI_{Indirecto}}\]
var(ndvi_indirecto)/var(ndvi_directo)## [1] 2.275008
var.test(x = ndvi_directo, y = ndvi_indirecto, ratio = 1,
alternative = 't')##
## F test to compare two variances
##
## data: ndvi_directo and ndvi_indirecto
## F = 0.43956, num df = 59, denom df = 59, p-value = 0.001928
## alternative hypothesis: true ratio of variances is not equal to 1
## 95 percent confidence interval:
## 0.2625593 0.7358798
## sample estimates:
## ratio of variances
## 0.439559
t.test(x = ndvi_directo, y = ndvi_indirecto,
mu = 0, paired = FALSE, var.equal = FALSE,
alternative = 'l')##
## Welch Two Sample t-test
##
## data: ndvi_directo and ndvi_indirecto
## t = -16.196, df = 102.47, p-value < 2.2e-16
## alternative hypothesis: true difference in means is less than 0
## 95 percent confidence interval:
## -Inf -0.2512988
## sample estimates:
## mean of x mean of y
## 0.2263801 0.5063734
ndvi_directo_2 = sort.int(ndvi_directo, 30)
ndvi_indirecto_2 = sort.int(ndvi_indirecto, 20)plot(ndvi_indirecto_2, type = 'l', ylim = c(0,0.7))
points(ndvi_directo_2, type = 'l', col = 4)
abline(h = mean(ndvi_indirecto_2))
abline(h = mean(ndvi_directo_2), col = 4)d_ndvi_d_2 = diff(ndvi_directo_2)
d_ndvi_i_2 = diff(ndvi_indirecto_2)
plot(d_ndvi_d_2, type = 'l', ylim = c(-0.2,0.2))
points(d_ndvi_i_2, type = 'l', col = 4)
abline(h = mean(d_ndvi_d_2))
abline(h = mean(d_ndvi_i_2), col=4)var.test(d_ndvi_d_2, d_ndvi_i_2,
ratio = 1, alternative = 't')##
## F test to compare two variances
##
## data: d_ndvi_d_2 and d_ndvi_i_2
## F = 0.19702, num df = 58, denom df = 58, p-value = 4.507e-09
## alternative hypothesis: true ratio of variances is not equal to 1
## 95 percent confidence interval:
## 0.1171544 0.3313260
## sample estimates:
## ratio of variances
## 0.1970185
t.test(d_ndvi_d_2, d_ndvi_i_2,
mu = 0, alternative = 't', var.equal = FALSE)##
## Welch Two Sample t-test
##
## data: d_ndvi_d_2 and d_ndvi_i_2
## t = -0.1834, df = 80, p-value = 0.8549
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
## -0.01892964 0.01573499
## sample estimates:
## mean of x mean of y
## 0.003513990 0.005111318
Pruebas paramétricas: Media
Datos: 2 muestras
Condiciones de validez: n > 30 o normalidad (Prueba de normalidad de Shapiro-Wilk y gráfico de normalidad)
Función R: t.test(x,y,paired=T)
Hipotesis 1: \[H0:μ_{AE_{corte 1}}=μ_{AE_{corte 2}}\\Ha:μ_{AE_{corte 1}}≠_{AE_{corte 2}}\]
set.seed(123)
AE_c1 = rnorm(30, 7, 0.5)
AE_c2 = rnorm(30, 6.5, 0.45)
t.test(x = AE_c1, y = AE_c2,
mu = 0, paired = TRUE,
alternative = 't')##
## Paired t-test
##
## data: AE_c1 and AE_c2
## t = 3.2719, df = 29, p-value = 0.00276
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
## 0.1485385 0.6438532
## sample estimates:
## mean of the differences
## 0.3961959
boxplot(cbind(AE_c1, AE_c2),
col = "white",
border = 4)
points(1:2, c(mean(AE_c1), mean(AE_c2)), pch=16, col='blue')