-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclase1.R
96 lines (56 loc) · 1.51 KB
/
clase1.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
x <- rnorm(100, 10, 1)
mean(x)
sd(x)
median(x)
mad(x)
# Cálculo de intervalo de confianza para la media
icsup <- mean(x) + abs(qt(0.975, 99))*sd(x)/sqrt(100)
icinf <- mean(x) - abs(qt(0.025, 99))*sd(x)/sqrt(100)
# concatenar ambos intervaloes
c(icinf, icsup)
# Pruebas de hipótesis paramétricas
# comparar dos metodologías
icp <- rnorm(10,100, 5)
faas <- rnorm(10, 100, 5)
# Test de normalidad de Shapiro-Wilk
shapiro.test(icp)
shapiro.test(faas)
# test de precisión o varianzas
var.test(icp, faas)
# test T para varianzas distintas
t.test(icp, faas, var.equal = F)
# Estimar intervalo de confianza mediante bootstrap
Cu <- rt(100, 3)
qqnorm(Cu)
qqline(Cu)
# Creamos la funcion bootstrap de medias
cv <- function(x){
sd(x)/mean(x)*100
}
set.seed(123)
t <- rnorm(10, 100, 1)
cv(t)
boot.media <- function(x, i){
mean(x[i])
}
library(boot)
promedios <- boot(Cu, boot.media, 1000)
boot.ci(promedios)
# ANOVA
aov.precision <- aov(Concentracion ~ Analista, data = datos)
boxplot(Concentracion ~ Analista, data = datos)
summary(aov.precision)
# Prueba de linealidad de carencia de ajuste
# usando la librería alr3
# Primero instalamos la librería
install.packages('alr3')
# Ajustamos un modelo lineal
modelo.lineal <- lm(y ~ x, data = lof)
# Cargamos la librería alr3
library(alr3)
# Usamos el comando pureErrorAnova
pureErrorAnova(modelo.lineal)
# test de mMandel
mandel.lineal <- lm(y ~ x, data = mandel)
mandel.nolineal <- lm(y ~ x + I(x^2), data = mandel)
anova(mandel.lineal, mandel.nolineal)