```{r}
#| label: fig-criterios
#| fig-cap: "Tipos de corridas en los diagramas de control"
#| fig-subcap:
#| - "Ejemplo del criterio de decisión i"
#| - "Ejemplo del criterio de decisión ii"
#| - "Ejemplo del criterio de decisión iii"
#| - "Ejemplo del criterio de decisión iv"
#| - "Ejemplo del criterio de decisión v"
#| - "Ejemplo del criterio de decisión vi"
#| - "Ejemplo del criterio de decisión vii"
#| - "Ejemplo del criterio de decisión viii"
#| - "Ejemplo del criterio de decisión ix"
#| - "Ejemplo del criterio de decisión x"
#| layout-ncol: 2
#| layout-nrow: 5
criterio <- do.call(cbind, lapply(1:15, function(x){
set.seed(5555 + x)
data.frame(
c(
rnorm(n = 15, mean = 100, sd = 5)
)
)
}
)
)
colnames(criterio) <- c(paste("criterio", 1:15, sep = "_"))
criterio$subgrupo <- 1:15
criterio <- criterio[, c(16, 1:15)]
# criterio de decisión i
criterio$criterio_1[sample(x = 1:15, size = 3)] <-
c(
mayor_lsigma(n = 2, L = 3, mean = 100, sd = 5),
menor_lsigma(n = 1, L = -3, mean = 100, sd = 5)
)
violacion <- factor(
ifelse(
abs(criterio$criterio_1 - 100) > 3 * 5, "Si", "No"
)
)
ggplot(
data = criterio,
mapping = aes(x = subgrupo, y = criterio_1),
show.legend = FALSE
) +
geom_step(
mapping = aes(x = subgrupo, y = 100 - 3 * 5),
direction = "hv", color = "red", lty = "dashed"
) +
geom_step(
mapping = aes(x = subgrupo, y = 100),
direction = "hv", color = "blue"
) +
geom_step(
mapping = aes(x = subgrupo, y = 100 + 3 * 5),
direction = "hv", color = "red", lty = "dashed"
) +
geom_step(
mapping = aes(x = subgrupo, y = 100 + 2 * 5),
direction = "hv", color = "#000080", lty = "dashed"
) +
geom_step(
mapping = aes(x = subgrupo, y = 100 - 2 * 5),
direction = "hv", color = "#000080", lty = "dashed"
) +
geom_step(
mapping = aes(x = subgrupo, y = 100 + 5),
direction = "hv", color = "blue", lty = "dashed"
) +
geom_step(
mapping = aes(x = subgrupo, y = 100 - 5),
direction = "hv", color = "blue", lty = "dashed"
) +
geom_point(
mapping = aes(
x = subgrupo, y = criterio_1, color = violacion,
shape = violacion
)
) +
scale_color_manual(
values = c(
"No" = "blue", "Si" = "red", show.legend = FALSE
)
) +
scale_shape_manual(values = c(16, 8)) +
geom_line(
mapping = aes(x = subgrupo, y = criterio_1),
color = "black"
) +
pammtools::geom_stepribbon(
aes(ymin = 100 - 3 * 5, ymax = 100 + 3 * 5),
fill = "green", alpha = 0.2, direction = "hv"
) +
pammtools::geom_stepribbon(
aes(ymin = 100 - 2 * 5, ymax = 100 + 2 * 5),
fill = "#00FF00", alpha = 0.2, direction = "hv"
) +
pammtools::geom_stepribbon(
aes(ymin = 100 - 5, ymax = 100 + 5),
fill = "#00FFFF", alpha = 0.2, direction = "hv"
) +
pammtools::geom_stepribbon(
aes(ymin = 100 + 3 * 5, ymax = Inf),
fill = "#FF0000", alpha = 0.2, direction = "hv"
) +
pammtools::geom_stepribbon(
aes(ymin = 100 - 3 * 5, ymax = -Inf),
fill = "#FF0000", alpha = 0.2, direction = "hv"
) +
# annotate(
# "text",
# x = 9.5, y = 118.5,
# label = latex2exp::TeX(
# "$Zona \\, fuera \\, de \\, control$", bold = TRUE,
# italic = TRUE
# )
# ) +
# annotate(
# "text",
# x = 9.5, y = 81.5,
# label = latex2exp::TeX(
# "$Zona \\, fuera \\, de \\, control$", bold = TRUE,
# italic = TRUE
# )
# ) +
annotate(
"text",
x = 9.5, y = 112.5,
label = latex2exp::TeX(
"$Zona \\, A$", bold = TRUE,italic = TRUE
)
) +
annotate(
"text",
x = 9.5, y = 87.5,
label = latex2exp::TeX(
"$Zona \\, A$", bold = TRUE,italic = TRUE
)
) +
annotate(
"text",
x = 9.5, y = 107.5,
label = latex2exp::TeX(
"$Zona \\, B$", bold = TRUE,italic = TRUE
)
) +
annotate(
"text",
x = 9.5, y = 92.5,
label = latex2exp::TeX(
"$Zona \\, B$", bold = TRUE,italic = TRUE
)
) +
annotate(
"text",
x = 9.5, y = 102.5,
label = latex2exp::TeX(
"$Zona \\, C$", bold = TRUE,italic = TRUE
)
) +
annotate(
"text",
x = 9.5, y = 97.5,
label = latex2exp::TeX(
"$Zona \\, C$", bold = TRUE,italic = TRUE
)
) +
annotate(
"text",
x = 15 + 1, y = 100 - 3 * 5,
label = latex2exp::TeX(
"$\\mu_W - 3\\sigma_W$",
italic = TRUE
)
) +
annotate(
"text", x = 15 + 1.1, y = 100 + 3 * 5,
label = latex2exp::TeX(
"$\\mu_W + 3\\sigma_W$",
italic = TRUE
)
) +
annotate(
"text",
x = 15 + 0.5, y = 100,
label = latex2exp::TeX(
"$\\mu_W$", italic = TRUE
)
) +
annotate(
"text",
x = 15 + 1.1, y = 100 - 2 * 5,
label = latex2exp::TeX(
"$\\mu_W - 2\\sigma_W$",
italic = TRUE
)
) +
annotate(
"text", x = 15 + 1.1, y = 100 + 2 * 5,
label = latex2exp::TeX(
"$\\mu_W + 2\\sigma_W$",
italic = TRUE
)
) +
annotate(
"text",
x = 15 + 1, y = 100 - 5,
label = latex2exp::TeX(
"$\\mu_W - \\sigma_W$",
italic = TRUE
)
) +
annotate(
"text", x = 15 + 1, y = 100 + 5,
label = latex2exp::TeX(
"$\\mu_W + \\sigma_W$",
italic = TRUE
)
) +
labs(
x = latex2exp::TeX(
"Número de muestras o tiempo", bold = TRUE,
italic = TRUE
),
y = latex2exp::TeX(
"Característica de la calidad",
bold = TRUE, italic = TRUE
),
shape = "Fuera de control", color = "Fuera de control"
) +
scale_x_continuous(
breaks = seq(from = 1, to = 15, by = 1),
limits = c(1, 17)
) +
scale_y_continuous(
breaks = seq(
from = 100 - 3 * 5, to = 100 + 3 * 5, by = 5
),
limits = c(100 - 4 * 5, 100 + 4 * 5)
) +
theme_bw() +
theme(
legend.position = "bottom",
legend.title = element_text(face = "bold"),
legend.text = element_text(face = "bold"),
panel.grid = element_blank()
)
# criterio de decisión ii
criterio$criterio_2[c(3, 4, 5, 6, 7, 8, 10, 11, 12, 13, 14)] <- c(
menor_lsigma(n = 1, L = 2, mean = 100, sd = 5),
mayor_lsigma(n = 4, L = 2, mean = 100, sd = 5),
menor_lsigma(n = 1, L = 2, mean = 100, sd = 5),
mayor_lsigma(n = 1, L = -2, mean = 100, sd = 5),
menor_lsigma(n = 3, L = -2, mean = 100, sd = 5),
mayor_lsigma(n = 1, L = -2, mean = 100, sd = 5)
)
violacion <- factor(
c(
"No", "No", "No", "No", "Si", "Si", "Si", "Si", "No",
"No", "No", "No", "Si", "Si", "No"
)
)
ggplot(
data = criterio,
mapping = aes(x = subgrupo, y = criterio_2),
show.legend = FALSE
) +
geom_step(
mapping = aes(x = subgrupo, y = 100 - 3 * 5),
direction = "hv", color = "red", lty = "dashed"
) +
geom_step(
mapping = aes(x = subgrupo, y = 100),
direction = "hv", color = "blue"
) +
geom_step(
mapping = aes(x = subgrupo, y = 100 + 3 * 5),
direction = "hv", color = "red", lty = "dashed"
) +
geom_step(
mapping = aes(x = subgrupo, y = 100 + 2 * 5),
direction = "hv", color = "#000080", lty = "dashed"
) +
geom_step(
mapping = aes(x = subgrupo, y = 100 - 2 * 5),
direction = "hv", color = "#000080", lty = "dashed"
) +
geom_step(
mapping = aes(x = subgrupo, y = 100 + 5),
direction = "hv", color = "blue", lty = "dashed"
) +
geom_step(
mapping = aes(x = subgrupo, y = 100 - 5),
direction = "hv", color = "blue", lty = "dashed"
) +
geom_point(
mapping = aes(
x = subgrupo, y = criterio_2, color = violacion,
shape = violacion
)
) +
scale_color_manual(
values = c(
"No" = "blue", "Si" = "red", show.legend = FALSE
)
) +
scale_shape_manual(values = c(16, 8)) +
geom_line(
mapping = aes(x = subgrupo, y = criterio_2),
color = "black"
) +
pammtools::geom_stepribbon(
aes(ymin = 100 - 3 * 5, ymax = 100 + 3 * 5),
fill = "green", alpha = 0.2, direction = "hv"
) +
pammtools::geom_stepribbon(
aes(ymin = 100 - 2 * 5, ymax = 100 + 2 * 5),
fill = "#00FF00", alpha = 0.2, direction = "hv"
) +
pammtools::geom_stepribbon(
aes(ymin = 100 - 5, ymax = 100 + 5),
fill = "#00FFFF", alpha = 0.2, direction = "hv"
) +
pammtools::geom_stepribbon(
aes(ymin = 100 + 3 * 5, ymax = Inf),
fill = "#FF0000", alpha = 0.2, direction = "hv"
) +
pammtools::geom_stepribbon(
aes(ymin = 100 - 3 * 5, ymax = -Inf),
fill = "#FF0000", alpha = 0.2, direction = "hv"
) +
# annotate(
# "text",
# x = 9.5, y = 118.5,
# label = latex2exp::TeX(
# "$Zona \\, fuera \\, de \\, control$", bold = TRUE,
# italic = TRUE
# )
# ) +
# annotate(
# "text",
# x = 9.5, y = 81.5,
# label = latex2exp::TeX(
# "$Zona \\, fuera \\, de \\, control$", bold = TRUE,
# italic = TRUE
# )
# ) +
annotate(
"text",
x = 9.5, y = 112.5,
label = latex2exp::TeX(
"$Zona \\, A$", bold = TRUE,italic = TRUE
)
) +
annotate(
"text",
x = 9.5, y = 87.5,
label = latex2exp::TeX(
"$Zona \\, A$", bold = TRUE,italic = TRUE
)
) +
annotate(
"text",
x = 9.5, y = 107.5,
label = latex2exp::TeX(
"$Zona \\, B$", bold = TRUE,italic = TRUE
)
) +
annotate(
"text",
x = 9.5, y = 92.5,
label = latex2exp::TeX(
"$Zona \\, B$", bold = TRUE,italic = TRUE
)
) +
annotate(
"text",
x = 9.5, y = 102.5,
label = latex2exp::TeX(
"$Zona \\, C$", bold = TRUE,italic = TRUE
)
) +
annotate(
"text",
x = 9.5, y = 97.5,
label = latex2exp::TeX(
"$Zona \\, C$", bold = TRUE,italic = TRUE
)
) +
annotate(
"text",
x = 15 + 1, y = 100 - 3 * 5,
label = latex2exp::TeX(
"$\\mu_W - 3\\sigma_W$",
italic = TRUE
)
) +
annotate(
"text", x = 15 + 1.1, y = 100 + 3 * 5,
label = latex2exp::TeX(
"$\\mu_W + 3\\sigma_W$",
italic = TRUE
)
) +
annotate(
"text",
x = 15 + 0.5, y = 100,
label = latex2exp::TeX(
"$\\mu_W$", italic = TRUE
)
) +
annotate(
"text",
x = 15 + 1.1, y = 100 - 2 * 5,
label = latex2exp::TeX(
"$\\mu_W - 2\\sigma_W$",
italic = TRUE
)
) +
annotate(
"text", x = 15 + 1.1, y = 100 + 2 * 5,
label = latex2exp::TeX(
"$\\mu_W + 2\\sigma_W$",
italic = TRUE
)
) +
annotate(
"text",
x = 15 + 1, y = 100 - 5,
label = latex2exp::TeX(
"$\\mu_W - \\sigma_W$",
italic = TRUE
)
) +
annotate(
"text", x = 15 + 1, y = 100 + 5,
label = latex2exp::TeX(
"$\\mu_W + \\sigma_W$",
italic = TRUE
)
) +
labs(
x = latex2exp::TeX(
"Número de muestras o tiempo", bold = TRUE,
italic = TRUE
),
y = latex2exp::TeX(
"Característica de la calidad",
bold = TRUE, italic = TRUE
),
shape = "Fuera de control", color = "Fuera de control"
) +
scale_x_continuous(
breaks = seq(from = 1, to = 15, by = 1),
limits = c(1, 17)
) +
scale_y_continuous(
breaks = seq(
from = 100 - 3 * 5, to = 100 + 3 * 5, by = 5
),
limits = c(100 - 4 * 5, 100 + 4 * 5)
) +
theme_bw() +
theme(
legend.position = "bottom",
legend.title = element_text(face = "bold"),
legend.text = element_text(face = "bold"),
panel.grid = element_blank()
)
# criterio de decisión iii
criterio$criterio_3[c(2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15)] <- c(
menor_lsigma(n = 1, L = 1, mean = 100, sd = 5),
mayor_lsigma(n = 6, L = 1, mean = 100, sd = 5),
menor_lsigma(n = 1, L = 1, mean = 100, sd = 5),
mayor_lsigma(n = 1, L = -1, mean = 100, sd = 5),
menor_lsigma(n = 5, L = -1, mean = 100, sd = 5),
mayor_lsigma(n = 1, L = -1, mean = 100, sd = 5)
)
violacion <- factor(
c(
"No", "No", "No", "No", "No","Si", "Si", "Si", "Si",
"No", "No", "No", "No", "No", "Si"
)
)
ggplot(
data = criterio,
mapping = aes(x = subgrupo, y = criterio_3),
show.legend = FALSE
) +
geom_step(
mapping = aes(x = subgrupo, y = 100 - 3 * 5),
direction = "hv", color = "red", lty = "dashed"
) +
geom_step(
mapping = aes(x = subgrupo, y = 100),
direction = "hv", color = "blue"
) +
geom_step(
mapping = aes(x = subgrupo, y = 100 + 3 * 5),
direction = "hv", color = "red", lty = "dashed"
) +
geom_step(
mapping = aes(x = subgrupo, y = 100 + 2 * 5),
direction = "hv", color = "#000080", lty = "dashed"
) +
geom_step(
mapping = aes(x = subgrupo, y = 100 - 2 * 5),
direction = "hv", color = "#000080", lty = "dashed"
) +
geom_step(
mapping = aes(x = subgrupo, y = 100 + 5),
direction = "hv", color = "blue", lty = "dashed"
) +
geom_step(
mapping = aes(x = subgrupo, y = 100 - 5),
direction = "hv", color = "blue", lty = "dashed"
) +
geom_point(
mapping = aes(
x = subgrupo, y = criterio_3, color = violacion,
shape = violacion
)
) +
scale_color_manual(
values = c(
"No" = "blue", "Si" = "red", show.legend = FALSE
)
) +
scale_shape_manual(values = c(16, 8)) +
geom_line(
mapping = aes(x = subgrupo, y = criterio_3),
color = "black"
) +
pammtools::geom_stepribbon(
aes(ymin = 100 - 3 * 5, ymax = 100 + 3 * 5),
fill = "green", alpha = 0.2, direction = "hv"
) +
pammtools::geom_stepribbon(
aes(ymin = 100 - 2 * 5, ymax = 100 + 2 * 5),
fill = "#00FF00", alpha = 0.2, direction = "hv"
) +
pammtools::geom_stepribbon(
aes(ymin = 100 - 5, ymax = 100 + 5),
fill = "#00FFFF", alpha = 0.2, direction = "hv"
) +
pammtools::geom_stepribbon(
aes(ymin = 100 + 3 * 5, ymax = Inf),
fill = "#FF0000", alpha = 0.2, direction = "hv"
) +
pammtools::geom_stepribbon(
aes(ymin = 100 - 3 * 5, ymax = -Inf),
fill = "#FF0000", alpha = 0.2, direction = "hv"
) +
# annotate(
# "text",
# x = 9.5, y = 118.5,
# label = latex2exp::TeX(
# "$Zona \\, fuera \\, de \\, control$", bold = TRUE,
# italic = TRUE
# )
# ) +
# annotate(
# "text",
# x = 9.5, y = 81.5,
# label = latex2exp::TeX(
# "$Zona \\, fuera \\, de \\, control$", bold = TRUE,
# italic = TRUE
# )
# ) +
annotate(
"text",
x = 9.5, y = 112.5,
label = latex2exp::TeX(
"$Zona \\, A$", bold = TRUE,italic = TRUE
)
) +
annotate(
"text",
x = 9.5, y = 87.5,
label = latex2exp::TeX(
"$Zona \\, A$", bold = TRUE,italic = TRUE
)
) +
annotate(
"text",
x = 9.5, y = 107.5,
label = latex2exp::TeX(
"$Zona \\, B$", bold = TRUE,italic = TRUE
)
) +
annotate(
"text",
x = 9.5, y = 92.5,
label = latex2exp::TeX(
"$Zona \\, B$", bold = TRUE,italic = TRUE
)
) +
annotate(
"text",
x = 9.5, y = 102.5,
label = latex2exp::TeX(
"$Zona \\, C$", bold = TRUE,italic = TRUE
)
) +
annotate(
"text",
x = 9.5, y = 97.5,
label = latex2exp::TeX(
"$Zona \\, C$", bold = TRUE,italic = TRUE
)
) +
annotate(
"text",
x = 15 + 1, y = 100 - 3 * 5,
label = latex2exp::TeX(
"$\\mu_W - 3\\sigma_W$",
italic = TRUE
)
) +
annotate(
"text", x = 15 + 1.1, y = 100 + 3 * 5,
label = latex2exp::TeX(
"$\\mu_W + 3\\sigma_W$",
italic = TRUE
)
) +
annotate(
"text",
x = 15 + 0.5, y = 100,
label = latex2exp::TeX(
"$\\mu_W$", italic = TRUE
)
) +
annotate(
"text",
x = 15 + 1.1, y = 100 - 2 * 5,
label = latex2exp::TeX(
"$\\mu_W - 2\\sigma_W$",
italic = TRUE
)
) +
annotate(
"text", x = 15 + 1.1, y = 100 + 2 * 5,
label = latex2exp::TeX(
"$\\mu_W + 2\\sigma_W$",
italic = TRUE
)
) +
annotate(
"text",
x = 15 + 1, y = 100 - 5,
label = latex2exp::TeX(
"$\\mu_W - \\sigma_W$",
italic = TRUE
)
) +
annotate(
"text", x = 15 + 1, y = 100 + 5,
label = latex2exp::TeX(
"$\\mu_W + \\sigma_W$",
italic = TRUE
)
) +
labs(
x = latex2exp::TeX(
"Número de muestras o tiempo", bold = TRUE,
italic = TRUE
),
y = latex2exp::TeX(
"Característica de la calidad",
bold = TRUE, italic = TRUE
),
shape = "Fuera de control", color = "Fuera de control"
) +
scale_x_continuous(
breaks = seq(from = 1, to = 15, by = 1),
limits = c(1, 17)
) +
scale_y_continuous(
breaks = seq(
from = 100 - 3 * 5, to = 100 + 3 * 5, by = 5
),
limits = c(100 - 4 * 5, 100 + 4 * 5)
) +
theme_bw() +
theme(
legend.position = "bottom",
legend.title = element_text(face = "bold"),
legend.text = element_text(face = "bold"),
panel.grid = element_blank()
)
# criterio de decisión iv
criterio$criterio_4[6:15] <- c(
menor_lsigma(n = 1, L = 0, mean = 100, sd = 5),
mayor_lsigma(n = 9, L = 0, mean = 100, sd = 5)
)
violacion <- factor(
c(
"No", "No", "No", "No", "No","No", "No", "No", "No",
"No", "No", "No","No", "Si", "Si"
)
)
ggplot(
data = criterio,
mapping = aes(x = subgrupo, y = criterio_4),
show.legend = FALSE
) +
geom_step(
mapping = aes(x = subgrupo, y = 100 - 3 * 5),
direction = "hv", color = "red", lty = "dashed"
) +
geom_step(
mapping = aes(x = subgrupo, y = 100),
direction = "hv", color = "blue"
) +
geom_step(
mapping = aes(x = subgrupo, y = 100 + 3 * 5),
direction = "hv", color = "red", lty = "dashed"
) +
geom_step(
mapping = aes(x = subgrupo, y = 100 + 2 * 5),
direction = "hv", color = "#000080", lty = "dashed"
) +
geom_step(
mapping = aes(x = subgrupo, y = 100 - 2 * 5),
direction = "hv", color = "#000080", lty = "dashed"
) +
geom_step(
mapping = aes(x = subgrupo, y = 100 + 5),
direction = "hv", color = "blue", lty = "dashed"
) +
geom_step(
mapping = aes(x = subgrupo, y = 100 - 5),
direction = "hv", color = "blue", lty = "dashed"
) +
geom_point(
mapping = aes(
x = subgrupo, y = criterio_4, color = violacion,
shape = violacion
)
) +
scale_color_manual(
values = c(
"No" = "blue", "Si" = "red", show.legend = FALSE
)
) +
scale_shape_manual(values = c(16, 8)) +
geom_line(
mapping = aes(x = subgrupo, y = criterio_4),
color = "black"
) +
pammtools::geom_stepribbon(
aes(ymin = 100 - 3 * 5, ymax = 100 + 3 * 5),
fill = "green", alpha = 0.2, direction = "hv"
) +
pammtools::geom_stepribbon(
aes(ymin = 100 - 2 * 5, ymax = 100 + 2 * 5),
fill = "#00FF00", alpha = 0.2, direction = "hv"
) +
pammtools::geom_stepribbon(
aes(ymin = 100 - 5, ymax = 100 + 5),
fill = "#00FFFF", alpha = 0.2, direction = "hv"
) +
pammtools::geom_stepribbon(
aes(ymin = 100 + 3 * 5, ymax = Inf),
fill = "#FF0000", alpha = 0.2, direction = "hv"
) +
pammtools::geom_stepribbon(
aes(ymin = 100 - 3 * 5, ymax = -Inf),
fill = "#FF0000", alpha = 0.2, direction = "hv"
) +
# annotate(
# "text",
# x = 9.5, y = 118.5,
# label = latex2exp::TeX(
# "$Zona \\, fuera \\, de \\, control$", bold = TRUE,
# italic = TRUE
# )
# ) +
# annotate(
# "text",
# x = 9.5, y = 81.5,
# label = latex2exp::TeX(
# "$Zona \\, fuera \\, de \\, control$", bold = TRUE,
# italic = TRUE
# )
# ) +
annotate(
"text",
x = 9.5, y = 112.5,
label = latex2exp::TeX(
"$Zona \\, A$", bold = TRUE,italic = TRUE
)
) +
annotate(
"text",
x = 9.5, y = 87.5,
label = latex2exp::TeX(
"$Zona \\, A$", bold = TRUE,italic = TRUE
)
) +
annotate(
"text",
x = 9.5, y = 107.5,
label = latex2exp::TeX(
"$Zona \\, B$", bold = TRUE,italic = TRUE
)
) +
annotate(
"text",
x = 9.5, y = 92.5,
label = latex2exp::TeX(
"$Zona \\, B$", bold = TRUE,italic = TRUE
)
) +
annotate(
"text",
x = 9.5, y = 102.5,
label = latex2exp::TeX(
"$Zona \\, C$", bold = TRUE,italic = TRUE
)
) +
annotate(
"text",
x = 9.5, y = 97.5,
label = latex2exp::TeX(
"$Zona \\, C$", bold = TRUE,italic = TRUE
)
) +
annotate(
"text",
x = 15 + 1, y = 100 - 3 * 5,
label = latex2exp::TeX(
"$\\mu_W - 3\\sigma_W$",
italic = TRUE
)
) +
annotate(
"text", x = 15 + 1.1, y = 100 + 3 * 5,
label = latex2exp::TeX(
"$\\mu_W + 3\\sigma_W$",
italic = TRUE
)
) +
annotate(
"text",
x = 15 + 0.5, y = 100,
label = latex2exp::TeX(
"$\\mu_W$", italic = TRUE
)
) +
annotate(
"text",
x = 15 + 1.1, y = 100 - 2 * 5,
label = latex2exp::TeX(
"$\\mu_W - 2\\sigma_W$",
italic = TRUE
)
) +
annotate(
"text", x = 15 + 1.1, y = 100 + 2 * 5,
label = latex2exp::TeX(
"$\\mu_W + 2\\sigma_W$",
italic = TRUE
)
) +
annotate(
"text",
x = 15 + 1, y = 100 - 5,
label = latex2exp::TeX(
"$\\mu_W - \\sigma_W$",
italic = TRUE
)
) +
annotate(
"text", x = 15 + 1, y = 100 + 5,
label = latex2exp::TeX(
"$\\mu_W + \\sigma_W$",
italic = TRUE
)
) +
labs(
x = latex2exp::TeX(
"Número de muestras o tiempo", bold = TRUE,
italic = TRUE
),
y = latex2exp::TeX(
"Característica de la calidad",
bold = TRUE, italic = TRUE
),
shape = "Fuera de control", color = "Fuera de control"
) +
scale_x_continuous(
breaks = seq(from = 1, to = 15, by = 1),
limits = c(1, 17)
) +
scale_y_continuous(
breaks = seq(
from = 100 - 3 * 5, to = 100 + 3 * 5, by = 5
),
limits = c(100 - 4 * 5, 100 + 4 * 5)
) +
theme_bw() +
theme(
legend.position = "bottom",
legend.title = element_text(face = "bold"),
legend.text = element_text(face = "bold"),
panel.grid = element_blank()
)
# criterio de decisión v
criterio$criterio_5[c(2:7, 10:15)] <- c(
sort(criterio$criterio_5[1:7]),
sort(criterio$criterio_5[10:15], decreasing = TRUE)
)
violacion <- factor(
c(
"No", "No", "No", "No", "No", "No", "Si", "No", "No",
"No", "No", "No","No", "No", "Si"
)
)
ggplot(
data = criterio,
mapping = aes(x = subgrupo, y = criterio_5),
show.legend = FALSE
) +
geom_step(
mapping = aes(x = subgrupo, y = 100 - 3 * 5),
direction = "hv", color = "red", lty = "dashed"
) +
geom_step(
mapping = aes(x = subgrupo, y = 100),
direction = "hv", color = "blue"
) +
geom_step(
mapping = aes(x = subgrupo, y = 100 + 3 * 5),
direction = "hv", color = "red", lty = "dashed"
) +
geom_step(
mapping = aes(x = subgrupo, y = 100 + 2 * 5),
direction = "hv", color = "#000080", lty = "dashed"
) +
geom_step(
mapping = aes(x = subgrupo, y = 100 - 2 * 5),
direction = "hv", color = "#000080", lty = "dashed"
) +
geom_step(
mapping = aes(x = subgrupo, y = 100 + 5),
direction = "hv", color = "blue", lty = "dashed"
) +
geom_step(
mapping = aes(x = subgrupo, y = 100 - 5),
direction = "hv", color = "blue", lty = "dashed"
) +
geom_point(
mapping = aes(
x = subgrupo, y = criterio_5, color = violacion,
shape = violacion
)
) +
scale_color_manual(
values = c(
"No" = "blue", "Si" = "red", show.legend = FALSE
)
) +
scale_shape_manual(values = c(16, 8)) +
geom_line(
mapping = aes(x = subgrupo, y = criterio_5),
color = "black"
) +
pammtools::geom_stepribbon(
aes(ymin = 100 - 3 * 5, ymax = 100 + 3 * 5),
fill = "green", alpha = 0.2, direction = "hv"
) +
pammtools::geom_stepribbon(
aes(ymin = 100 - 2 * 5, ymax = 100 + 2 * 5),
fill = "#00FF00", alpha = 0.2, direction = "hv"
) +
pammtools::geom_stepribbon(
aes(ymin = 100 - 5, ymax = 100 + 5),
fill = "#00FFFF", alpha = 0.2, direction = "hv"
) +
pammtools::geom_stepribbon(
aes(ymin = 100 + 3 * 5, ymax = Inf),
fill = "#FF0000", alpha = 0.2, direction = "hv"
) +
pammtools::geom_stepribbon(
aes(ymin = 100 - 3 * 5, ymax = -Inf),
fill = "#FF0000", alpha = 0.2, direction = "hv"
) +
# annotate(
# "text",
# x = 9.5, y = 118.5,
# label = latex2exp::TeX(
# "$Zona \\, fuera \\, de \\, control$", bold = TRUE,
# italic = TRUE
# )
# ) +
# annotate(
# "text",
# x = 9.5, y = 81.5,
# label = latex2exp::TeX(
# "$Zona \\, fuera \\, de \\, control$", bold = TRUE,
# italic = TRUE
# )
# ) +
annotate(
"text",
x = 9.5, y = 112.5,
label = latex2exp::TeX(
"$Zona \\, A$", bold = TRUE,italic = TRUE
)
) +
annotate(
"text",
x = 9.5, y = 87.5,
label = latex2exp::TeX(
"$Zona \\, A$", bold = TRUE,italic = TRUE
)
) +
annotate(
"text",
x = 9.5, y = 107.5,
label = latex2exp::TeX(
"$Zona \\, B$", bold = TRUE,italic = TRUE
)
) +
annotate(
"text",
x = 9.5, y = 92.5,
label = latex2exp::TeX(
"$Zona \\, B$", bold = TRUE,italic = TRUE
)
) +
annotate(
"text",
x = 9.5, y = 102.5,
label = latex2exp::TeX(
"$Zona \\, C$", bold = TRUE,italic = TRUE
)
) +
annotate(
"text",
x = 9.5, y = 97.5,
label = latex2exp::TeX(
"$Zona \\, C$", bold = TRUE,italic = TRUE
)
) +
annotate(
"text",
x = 15 + 1, y = 100 - 3 * 5,
label = latex2exp::TeX(
"$\\mu_W - 3\\sigma_W$",
italic = TRUE
)
) +
annotate(
"text", x = 15 + 1.1, y = 100 + 3 * 5,
label = latex2exp::TeX(
"$\\mu_W + 3\\sigma_W$",
italic = TRUE
)
) +
annotate(
"text",
x = 15 + 0.5, y = 100,
label = latex2exp::TeX(
"$\\mu_W$", italic = TRUE
)
) +
annotate(
"text",
x = 15 + 1.1, y = 100 - 2 * 5,
label = latex2exp::TeX(
"$\\mu_W - 2\\sigma_W$",
italic = TRUE
)
) +
annotate(
"text", x = 15 + 1.1, y = 100 + 2 * 5,
label = latex2exp::TeX(
"$\\mu_W + 2\\sigma_W$",
italic = TRUE
)
) +
annotate(
"text",
x = 15 + 1, y = 100 - 5,
label = latex2exp::TeX(
"$\\mu_W - \\sigma_W$",
italic = TRUE
)
) +
annotate(
"text", x = 15 + 1, y = 100 + 5,
label = latex2exp::TeX(
"$\\mu_W + \\sigma_W$",
italic = TRUE
)
) +
labs(
x = latex2exp::TeX(
"Número de muestras o tiempo", bold = TRUE,
italic = TRUE
),
y = latex2exp::TeX(
"Característica de la calidad",
bold = TRUE, italic = TRUE
),
shape = "Fuera de control", color = "Fuera de control"
) +
scale_x_continuous(
breaks = seq(from = 1, to = 15, by = 1),
limits = c(1, 17)
) +
scale_y_continuous(
breaks = seq(
from = 100 - 3 * 5, to = 100 + 3 * 5, by = 5
),
limits = c(100 - 4 * 5, 100 + 4 * 5)
) +
theme_bw() +
theme(
legend.position = "bottom",
legend.title = element_text(face = "bold"),
legend.text = element_text(face = "bold"),
panel.grid = element_blank()
)
# criterio de decisión vi
criterio$criterio_6 <- c(
entre_lsigma(n = 15, L = 1, mean = 100, sd = 5)
)
violacion <- factor(
c(
"No", "No", "No", "No", "No", "No", "No", "No", "No",
"No", "No", "No","No", "No", "Si"
)
)
ggplot(
data = criterio,
mapping = aes(x = subgrupo, y = criterio_6),
show.legend = FALSE
) +
geom_step(
mapping = aes(x = subgrupo, y = 100 - 3 * 5),
direction = "hv", color = "red", lty = "dashed"
) +
geom_step(
mapping = aes(x = subgrupo, y = 100),
direction = "hv", color = "blue"
) +
geom_step(
mapping = aes(x = subgrupo, y = 100 + 3 * 5),
direction = "hv", color = "red", lty = "dashed"
) +
geom_step(
mapping = aes(x = subgrupo, y = 100 + 2 * 5),
direction = "hv", color = "#000080", lty = "dashed"
) +
geom_step(
mapping = aes(x = subgrupo, y = 100 - 2 * 5),
direction = "hv", color = "#000080", lty = "dashed"
) +
geom_step(
mapping = aes(x = subgrupo, y = 100 + 5),
direction = "hv", color = "blue", lty = "dashed"
) +
geom_step(
mapping = aes(x = subgrupo, y = 100 - 5),
direction = "hv", color = "blue", lty = "dashed"
) +
geom_point(
mapping = aes(
x = subgrupo, y = criterio_6, color = violacion,
shape = violacion
)
) +
scale_color_manual(
values = c(
"No" = "blue", "Si" = "red", show.legend = FALSE
)
) +
scale_shape_manual(values = c(16, 8)) +
geom_line(
mapping = aes(x = subgrupo, y = criterio_6),
color = "black"
) +
pammtools::geom_stepribbon(
aes(ymin = 100 - 3 * 5, ymax = 100 + 3 * 5),
fill = "green", alpha = 0.2, direction = "hv"
) +
pammtools::geom_stepribbon(
aes(ymin = 100 - 2 * 5, ymax = 100 + 2 * 5),
fill = "#00FF00", alpha = 0.2, direction = "hv"
) +
pammtools::geom_stepribbon(
aes(ymin = 100 - 5, ymax = 100 + 5),
fill = "#00FFFF", alpha = 0.2, direction = "hv"
) +
pammtools::geom_stepribbon(
aes(ymin = 100 + 3 * 5, ymax = Inf),
fill = "#FF0000", alpha = 0.2, direction = "hv"
) +
pammtools::geom_stepribbon(
aes(ymin = 100 - 3 * 5, ymax = -Inf),
fill = "#FF0000", alpha = 0.2, direction = "hv"
) +
# annotate(
# "text",
# x = 9.5, y = 118.5,
# label = latex2exp::TeX(
# "$Zona \\, fuera \\, de \\, control$", bold = TRUE,
# italic = TRUE
# )
# ) +
# annotate(
# "text",
# x = 9.5, y = 81.5,
# label = latex2exp::TeX(
# "$Zona \\, fuera \\, de \\, control$", bold = TRUE,
# italic = TRUE
# )
# ) +
annotate(
"text",
x = 9.5, y = 112.5,
label = latex2exp::TeX(
"$Zona \\, A$", bold = TRUE,italic = TRUE
)
) +
annotate(
"text",
x = 9.5, y = 87.5,
label = latex2exp::TeX(
"$Zona \\, A$", bold = TRUE,italic = TRUE
)
) +
annotate(
"text",
x = 9.5, y = 107.5,
label = latex2exp::TeX(
"$Zona \\, B$", bold = TRUE,italic = TRUE
)
) +
annotate(
"text",
x = 9.5, y = 92.5,
label = latex2exp::TeX(
"$Zona \\, B$", bold = TRUE,italic = TRUE
)
) +
annotate(
"text",
x = 9.5, y = 102.5,
label = latex2exp::TeX(
"$Zona \\, C$", bold = TRUE,italic = TRUE
)
) +
annotate(
"text",
x = 9.5, y = 97.5,
label = latex2exp::TeX(
"$Zona \\, C$", bold = TRUE,italic = TRUE
)
) +
annotate(
"text",
x = 15 + 1, y = 100 - 3 * 5,
label = latex2exp::TeX(
"$\\mu_W - 3\\sigma_W$",
italic = TRUE
)
) +
annotate(
"text", x = 15 + 1.1, y = 100 + 3 * 5,
label = latex2exp::TeX(
"$\\mu_W + 3\\sigma_W$",
italic = TRUE
)
) +
annotate(
"text",
x = 15 + 0.5, y = 100,
label = latex2exp::TeX(
"$\\mu_W$", italic = TRUE
)
) +
annotate(
"text",
x = 15 + 1.1, y = 100 - 2 * 5,
label = latex2exp::TeX(
"$\\mu_W - 2\\sigma_W$",
italic = TRUE
)
) +
annotate(
"text", x = 15 + 1.1, y = 100 + 2 * 5,
label = latex2exp::TeX(
"$\\mu_W + 2\\sigma_W$",
italic = TRUE
)
) +
annotate(
"text",
x = 15 + 1, y = 100 - 5,
label = latex2exp::TeX(
"$\\mu_W - \\sigma_W$",
italic = TRUE
)
) +
annotate(
"text", x = 15 + 1, y = 100 + 5,
label = latex2exp::TeX(
"$\\mu_W + \\sigma_W$",
italic = TRUE
)
) +
labs(
x = latex2exp::TeX(
"Número de muestras o tiempo", bold = TRUE,
italic = TRUE
),
y = latex2exp::TeX(
"Característica de la calidad",
bold = TRUE, italic = TRUE
),
shape = "Fuera de control", color = "Fuera de control"
) +
scale_x_continuous(
breaks = seq(from = 1, to = 15, by = 1),
limits = c(1, 17)
) +
scale_y_continuous(
breaks = seq(
from = 100 - 3 * 5, to = 100 + 3 * 5, by = 5
),
limits = c(100 - 4 * 5, 100 + 4 * 5)
) +
theme_bw() +
theme(
legend.position = "bottom",
legend.title = element_text(face = "bold"),
legend.text = element_text(face = "bold"),
panel.grid = element_blank()
)
# criterio de decisión vii
criterio$criterio_7 <- c(
mayor_lsigma(n = 1, L = 0, mean = 100, sd = 5),
menor_lsigma(n = 1, L = 0, mean = 100, sd = 5),
mayor_lsigma(n = 1, L = 1, mean = 100, sd = 5),
menor_lsigma(n = 1, L = -1, mean = 100, sd = 5),
mayor_lsigma(n = 1, L = 2, mean = 100, sd = 5),
menor_lsigma(n = 1, L = 1, mean = 100, sd = 5),
mayor_lsigma(n = 1, L = 2, mean = 100, sd = 5),
menor_lsigma(n = 1, L = 0, mean = 100, sd = 5),
mayor_lsigma(n = 1, L = 2, mean = 100, sd = 5),
menor_lsigma(n = 1, L = 1, mean = 100, sd = 5),
mayor_lsigma(n = 1, L = 1, mean = 100, sd = 5),
menor_lsigma(n = 1, L = -1, mean = 100, sd = 5),
mayor_lsigma(n = 1, L = 2, mean = 100, sd = 5),
menor_lsigma(n = 1, L = 0, mean = 100, sd = 5),
mayor_lsigma(n = 1, L = 0, mean = 100, sd = 5)
)
violacion <- factor(
c(
"No", "No", "No", "No", "No", "No", "No", "No", "No",
"No", "No", "No","No", "Si", "Si"
)
)
ggplot(
data = criterio,
mapping = aes(x = subgrupo, y = criterio_7),
show.legend = FALSE
) +
geom_step(
mapping = aes(x = subgrupo, y = 100 - 3 * 5),
direction = "hv", color = "red", lty = "dashed"
) +
geom_step(
mapping = aes(x = subgrupo, y = 100),
direction = "hv", color = "blue"
) +
geom_step(
mapping = aes(x = subgrupo, y = 100 + 3 * 5),
direction = "hv", color = "red", lty = "dashed"
) +
geom_step(
mapping = aes(x = subgrupo, y = 100 + 2 * 5),
direction = "hv", color = "#000080", lty = "dashed"
) +
geom_step(
mapping = aes(x = subgrupo, y = 100 - 2 * 5),
direction = "hv", color = "#000080", lty = "dashed"
) +
geom_step(
mapping = aes(x = subgrupo, y = 100 + 5),
direction = "hv", color = "blue", lty = "dashed"
) +
geom_step(
mapping = aes(x = subgrupo, y = 100 - 5),
direction = "hv", color = "blue", lty = "dashed"
) +
geom_point(
mapping = aes(
x = subgrupo, y = criterio_7, color = violacion,
shape = violacion
)
) +
scale_color_manual(
values = c(
"No" = "blue", "Si" = "red", show.legend = FALSE
)
) +
scale_shape_manual(values = c(16, 8)) +
geom_line(
mapping = aes(x = subgrupo, y = criterio_7),
color = "black"
) +
pammtools::geom_stepribbon(
aes(ymin = 100 - 3 * 5, ymax = 100 + 3 * 5),
fill = "green", alpha = 0.2, direction = "hv"
) +
pammtools::geom_stepribbon(
aes(ymin = 100 - 2 * 5, ymax = 100 + 2 * 5),
fill = "#00FF00", alpha = 0.2, direction = "hv"
) +
pammtools::geom_stepribbon(
aes(ymin = 100 - 5, ymax = 100 + 5),
fill = "#00FFFF", alpha = 0.2, direction = "hv"
) +
pammtools::geom_stepribbon(
aes(ymin = 100 + 3 * 5, ymax = Inf),
fill = "#FF0000", alpha = 0.2, direction = "hv"
) +
pammtools::geom_stepribbon(
aes(ymin = 100 - 3 * 5, ymax = -Inf),
fill = "#FF0000", alpha = 0.2, direction = "hv"
) +
# annotate(
# "text",
# x = 9.5, y = 118.5,
# label = latex2exp::TeX(
# "$Zona \\, fuera \\, de \\, control$", bold = TRUE,
# italic = TRUE
# )
# ) +
# annotate(
# "text",
# x = 9.5, y = 81.5,
# label = latex2exp::TeX(
# "$Zona \\, fuera \\, de \\, control$", bold = TRUE,
# italic = TRUE
# )
# ) +
annotate(
"text",
x = 9.5, y = 112.5,
label = latex2exp::TeX(
"$Zona \\, A$", bold = TRUE,italic = TRUE
)
) +
annotate(
"text",
x = 9.5, y = 87.5,
label = latex2exp::TeX(
"$Zona \\, A$", bold = TRUE,italic = TRUE
)
) +
annotate(
"text",
x = 9.5, y = 107.5,
label = latex2exp::TeX(
"$Zona \\, B$", bold = TRUE,italic = TRUE
)
) +
annotate(
"text",
x = 9.5, y = 92.5,
label = latex2exp::TeX(
"$Zona \\, B$", bold = TRUE,italic = TRUE
)
) +
annotate(
"text",
x = 9.5, y = 102.5,
label = latex2exp::TeX(
"$Zona \\, C$", bold = TRUE,italic = TRUE
)
) +
annotate(
"text",
x = 9.5, y = 97.5,
label = latex2exp::TeX(
"$Zona \\, C$", bold = TRUE,italic = TRUE
)
) +
annotate(
"text",
x = 15 + 1, y = 100 - 3 * 5,
label = latex2exp::TeX(
"$\\mu_W - 3\\sigma_W$",
italic = TRUE
)
) +
annotate(
"text", x = 15 + 1.1, y = 100 + 3 * 5,
label = latex2exp::TeX(
"$\\mu_W + 3\\sigma_W$",
italic = TRUE
)
) +
annotate(
"text",
x = 15 + 0.5, y = 100,
label = latex2exp::TeX(
"$\\mu_W$", italic = TRUE
)
) +
annotate(
"text",
x = 15 + 1.1, y = 100 - 2 * 5,
label = latex2exp::TeX(
"$\\mu_W - 2\\sigma_W$",
italic = TRUE
)
) +
annotate(
"text", x = 15 + 1.1, y = 100 + 2 * 5,
label = latex2exp::TeX(
"$\\mu_W + 2\\sigma_W$",
italic = TRUE
)
) +
annotate(
"text",
x = 15 + 1, y = 100 - 5,
label = latex2exp::TeX(
"$\\mu_W - \\sigma_W$",
italic = TRUE
)
) +
annotate(
"text", x = 15 + 1, y = 100 + 5,
label = latex2exp::TeX(
"$\\mu_W + \\sigma_W$",
italic = TRUE
)
) +
labs(
x = latex2exp::TeX(
"Número de muestras o tiempo", bold = TRUE,
italic = TRUE
),
y = latex2exp::TeX(
"Característica de la calidad",
bold = TRUE, italic = TRUE
),
shape = "Fuera de control", color = "Fuera de control"
) +
scale_x_continuous(
breaks = seq(from = 1, to = 15, by = 1),
limits = c(1, 17)
) +
scale_y_continuous(
breaks = seq(
from = 100 - 3 * 5, to = 100 + 3 * 5, by = 5
),
limits = c(100 - 4 * 5, 100 + 4 * 5)
) +
theme_bw() +
theme(
legend.position = "bottom",
legend.title = element_text(face = "bold"),
legend.text = element_text(face = "bold"),
panel.grid = element_blank()
)
# criterio de decisión viii
criterio$criterio_8[7:15] <- fuera_lsigma(
n = 9, L = 1, mean = 100, sd = 5
)
violacion <- factor(
c(
"No", "No", "No", "No", "No", "No", "No", "No", "No",
"No", "No", "No","No", "Si", "Si"
)
)
ggplot(
data = criterio,
mapping = aes(x = subgrupo, y = criterio_8),
show.legend = FALSE
) +
geom_step(
mapping = aes(x = subgrupo, y = 100 - 3 * 5),
direction = "hv", color = "red", lty = "dashed"
) +
geom_step(
mapping = aes(x = subgrupo, y = 100),
direction = "hv", color = "blue"
) +
geom_step(
mapping = aes(x = subgrupo, y = 100 + 3 * 5),
direction = "hv", color = "red", lty = "dashed"
) +
geom_step(
mapping = aes(x = subgrupo, y = 100 + 2 * 5),
direction = "hv", color = "#000080", lty = "dashed"
) +
geom_step(
mapping = aes(x = subgrupo, y = 100 - 2 * 5),
direction = "hv", color = "#000080", lty = "dashed"
) +
geom_step(
mapping = aes(x = subgrupo, y = 100 + 5),
direction = "hv", color = "blue", lty = "dashed"
) +
geom_step(
mapping = aes(x = subgrupo, y = 100 - 5),
direction = "hv", color = "blue", lty = "dashed"
) +
geom_point(
mapping = aes(
x = subgrupo, y = criterio_8, color = violacion,
shape = violacion
)
) +
scale_color_manual(
values = c(
"No" = "blue", "Si" = "red", show.legend = FALSE
)
) +
scale_shape_manual(values = c(16, 8)) +
geom_line(
mapping = aes(x = subgrupo, y = criterio_8),
color = "black"
) +
pammtools::geom_stepribbon(
aes(ymin = 100 - 3 * 5, ymax = 100 + 3 * 5),
fill = "green", alpha = 0.2, direction = "hv"
) +
pammtools::geom_stepribbon(
aes(ymin = 100 - 2 * 5, ymax = 100 + 2 * 5),
fill = "#00FF00", alpha = 0.2, direction = "hv"
) +
pammtools::geom_stepribbon(
aes(ymin = 100 - 5, ymax = 100 + 5),
fill = "#00FFFF", alpha = 0.2, direction = "hv"
) +
pammtools::geom_stepribbon(
aes(ymin = 100 + 3 * 5, ymax = Inf),
fill = "#FF0000", alpha = 0.2, direction = "hv"
) +
pammtools::geom_stepribbon(
aes(ymin = 100 - 3 * 5, ymax = -Inf),
fill = "#FF0000", alpha = 0.2, direction = "hv"
) +
# annotate(
# "text",
# x = 9.5, y = 118.5,
# label = latex2exp::TeX(
# "$Zona \\, fuera \\, de \\, control$", bold = TRUE,
# italic = TRUE
# )
# ) +
# annotate(
# "text",
# x = 9.5, y = 81.5,
# label = latex2exp::TeX(
# "$Zona \\, fuera \\, de \\, control$", bold = TRUE,
# italic = TRUE
# )
# ) +
annotate(
"text",
x = 9.5, y = 112.5,
label = latex2exp::TeX(
"$Zona \\, A$", bold = TRUE,italic = TRUE
)
) +
annotate(
"text",
x = 9.5, y = 87.5,
label = latex2exp::TeX(
"$Zona \\, A$", bold = TRUE,italic = TRUE
)
) +
annotate(
"text",
x = 9.5, y = 107.5,
label = latex2exp::TeX(
"$Zona \\, B$", bold = TRUE,italic = TRUE
)
) +
annotate(
"text",
x = 9.5, y = 92.5,
label = latex2exp::TeX(
"$Zona \\, B$", bold = TRUE,italic = TRUE
)
) +
annotate(
"text",
x = 9.5, y = 102.5,
label = latex2exp::TeX(
"$Zona \\, C$", bold = TRUE,italic = TRUE
)
) +
annotate(
"text",
x = 9.5, y = 97.5,
label = latex2exp::TeX(
"$Zona \\, C$", bold = TRUE,italic = TRUE
)
) +
annotate(
"text",
x = 15 + 1, y = 100 - 3 * 5,
label = latex2exp::TeX(
"$\\mu_W - 3\\sigma_W$",
italic = TRUE
)
) +
annotate(
"text", x = 15 + 1.1, y = 100 + 3 * 5,
label = latex2exp::TeX(
"$\\mu_W + 3\\sigma_W$",
italic = TRUE
)
) +
annotate(
"text",
x = 15 + 0.5, y = 100,
label = latex2exp::TeX(
"$\\mu_W$", italic = TRUE
)
) +
annotate(
"text",
x = 15 + 1.1, y = 100 - 2 * 5,
label = latex2exp::TeX(
"$\\mu_W - 2\\sigma_W$",
italic = TRUE
)
) +
annotate(
"text", x = 15 + 1.1, y = 100 + 2 * 5,
label = latex2exp::TeX(
"$\\mu_W + 2\\sigma_W$",
italic = TRUE
)
) +
annotate(
"text",
x = 15 + 1, y = 100 - 5,
label = latex2exp::TeX(
"$\\mu_W - \\sigma_W$",
italic = TRUE
)
) +
annotate(
"text", x = 15 + 1, y = 100 + 5,
label = latex2exp::TeX(
"$\\mu_W + \\sigma_W$",
italic = TRUE
)
) +
labs(
x = latex2exp::TeX(
"Número de muestras o tiempo", bold = TRUE,
italic = TRUE
),
y = latex2exp::TeX(
"Característica de la calidad",
bold = TRUE, italic = TRUE
),
shape = "Fuera de control", color = "Fuera de control"
) +
scale_x_continuous(
breaks = seq(from = 1, to = 15, by = 1),
limits = c(1, 17)
) +
scale_y_continuous(
breaks = seq(
from = 100 - 3 * 5, to = 100 + 3 * 5, by = 5
),
limits = c(100 - 4 * 5, 100 + 4 * 5)
) +
theme_bw() +
theme(
legend.position = "bottom",
legend.title = element_text(face = "bold"),
legend.text = element_text(face = "bold"),
panel.grid = element_blank()
)
# criterio de decisión ix
criterio$criterio_9[c(3, 6, 9, 12, 15)] <- mayor_lsigma(
n = 5, L = 2, mean = 100, sd = 5
)
violacion <- factor(
c(
"No", "No", "Si", "No", "No", "Si", "No", "No", "Si",
"No", "No", "Si","No", "No", "Si"
)
)
ggplot(
data = criterio,
mapping = aes(x = subgrupo, y = criterio_9),
show.legend = FALSE
) +
geom_step(
mapping = aes(x = subgrupo, y = 100 - 3 * 5),
direction = "hv", color = "red", lty = "dashed"
) +
geom_step(
mapping = aes(x = subgrupo, y = 100),
direction = "hv", color = "blue"
) +
geom_step(
mapping = aes(x = subgrupo, y = 100 + 3 * 5),
direction = "hv", color = "red", lty = "dashed"
) +
geom_step(
mapping = aes(x = subgrupo, y = 100 + 2 * 5),
direction = "hv", color = "#000080", lty = "dashed"
) +
geom_step(
mapping = aes(x = subgrupo, y = 100 - 2 * 5),
direction = "hv", color = "#000080", lty = "dashed"
) +
geom_step(
mapping = aes(x = subgrupo, y = 100 + 5),
direction = "hv", color = "blue", lty = "dashed"
) +
geom_step(
mapping = aes(x = subgrupo, y = 100 - 5),
direction = "hv", color = "blue", lty = "dashed"
) +
geom_point(
mapping = aes(
x = subgrupo, y = criterio_9, color = violacion,
shape = violacion
)
) +
scale_color_manual(
values = c(
"No" = "blue", "Si" = "red", show.legend = FALSE
)
) +
scale_shape_manual(values = c(16, 8)) +
geom_line(
mapping = aes(x = subgrupo, y = criterio_9),
color = "black"
) +
pammtools::geom_stepribbon(
aes(ymin = 100 - 3 * 5, ymax = 100 + 3 * 5),
fill = "green", alpha = 0.2, direction = "hv"
) +
pammtools::geom_stepribbon(
aes(ymin = 100 - 2 * 5, ymax = 100 + 2 * 5),
fill = "#00FF00", alpha = 0.2, direction = "hv"
) +
pammtools::geom_stepribbon(
aes(ymin = 100 - 5, ymax = 100 + 5),
fill = "#00FFFF", alpha = 0.2, direction = "hv"
) +
pammtools::geom_stepribbon(
aes(ymin = 100 + 3 * 5, ymax = Inf),
fill = "#FF0000", alpha = 0.2, direction = "hv"
) +
pammtools::geom_stepribbon(
aes(ymin = 100 - 3 * 5, ymax = -Inf),
fill = "#FF0000", alpha = 0.2, direction = "hv"
) +
# annotate(
# "text",
# x = 9.5, y = 118.5,
# label = latex2exp::TeX(
# "$Zona \\, fuera \\, de \\, control$", bold = TRUE,
# italic = TRUE
# )
# ) +
# annotate(
# "text",
# x = 9.5, y = 81.5,
# label = latex2exp::TeX(
# "$Zona \\, fuera \\, de \\, control$", bold = TRUE,
# italic = TRUE
# )
# ) +
annotate(
"text",
x = 9.5, y = 112.5,
label = latex2exp::TeX(
"$Zona \\, A$", bold = TRUE,italic = TRUE
)
) +
annotate(
"text",
x = 9.5, y = 87.5,
label = latex2exp::TeX(
"$Zona \\, A$", bold = TRUE,italic = TRUE
)
) +
annotate(
"text",
x = 9.5, y = 107.5,
label = latex2exp::TeX(
"$Zona \\, B$", bold = TRUE,italic = TRUE
)
) +
annotate(
"text",
x = 9.5, y = 92.5,
label = latex2exp::TeX(
"$Zona \\, B$", bold = TRUE,italic = TRUE
)
) +
annotate(
"text",
x = 9.5, y = 102.5,
label = latex2exp::TeX(
"$Zona \\, C$", bold = TRUE,italic = TRUE
)
) +
annotate(
"text",
x = 9.5, y = 97.5,
label = latex2exp::TeX(
"$Zona \\, C$", bold = TRUE,italic = TRUE
)
) +
annotate(
"text",
x = 15 + 1, y = 100 - 3 * 5,
label = latex2exp::TeX(
"$\\mu_W - 3\\sigma_W$",
italic = TRUE
)
) +
annotate(
"text", x = 15 + 1.1, y = 100 + 3 * 5,
label = latex2exp::TeX(
"$\\mu_W + 3\\sigma_W$",
italic = TRUE
)
) +
annotate(
"text",
x = 15 + 0.5, y = 100,
label = latex2exp::TeX(
"$\\mu_W$", italic = TRUE
)
) +
annotate(
"text",
x = 15 + 1.1, y = 100 - 2 * 5,
label = latex2exp::TeX(
"$\\mu_W - 2\\sigma_W$",
italic = TRUE
)
) +
annotate(
"text", x = 15 + 1.1, y = 100 + 2 * 5,
label = latex2exp::TeX(
"$\\mu_W + 2\\sigma_W$",
italic = TRUE
)
) +
annotate(
"text",
x = 15 + 1, y = 100 - 5,
label = latex2exp::TeX(
"$\\mu_W - \\sigma_W$",
italic = TRUE
)
) +
annotate(
"text", x = 15 + 1, y = 100 + 5,
label = latex2exp::TeX(
"$\\mu_W + \\sigma_W$",
italic = TRUE
)
) +
labs(
x = latex2exp::TeX(
"Número de muestras o tiempo", bold = TRUE,
italic = TRUE
),
y = latex2exp::TeX(
"Característica de la calidad",
bold = TRUE, italic = TRUE
),
shape = "Fuera de control", color = "Fuera de control"
) +
scale_x_continuous(
breaks = seq(from = 1, to = 15, by = 1),
limits = c(1, 17)
) +
scale_y_continuous(
breaks = seq(
from = 100 - 3 * 5, to = 100 + 3 * 5, by = 5
),
limits = c(100 - 4 * 5, 100 + 4 * 5)
) +
theme_bw() +
theme(
legend.position = "bottom",
legend.title = element_text(face = "bold"),
legend.text = element_text(face = "bold"),
panel.grid = element_blank()
)
# criterio de decisión x
criterio$criterio_10[c(3, 4, 5, 12, 13, 14)] <- c(
114.5, 114.8, 114.6, 89.7, 89.3, 88.9
)
violacion <- factor(
c(
"No", "No", "Si", "Si", "Si", "No", "No", "No", "No",
"No", "No", "Si", "Si", "Si", "No"
)
)
ggplot(
data = criterio,
mapping = aes(x = subgrupo, y = criterio_10),
show.legend = FALSE
) +
geom_step(
mapping = aes(x = subgrupo, y = 100 - 3 * 5),
direction = "hv", color = "red", lty = "dashed"
) +
geom_step(
mapping = aes(x = subgrupo, y = 100),
direction = "hv", color = "blue"
) +
geom_step(
mapping = aes(x = subgrupo, y = 100 + 3 * 5),
direction = "hv", color = "red", lty = "dashed"
) +
geom_step(
mapping = aes(x = subgrupo, y = 100 + 2 * 5),
direction = "hv", color = "#000080", lty = "dashed"
) +
geom_step(
mapping = aes(x = subgrupo, y = 100 - 2 * 5),
direction = "hv", color = "#000080", lty = "dashed"
) +
geom_step(
mapping = aes(x = subgrupo, y = 100 + 5),
direction = "hv", color = "blue", lty = "dashed"
) +
geom_step(
mapping = aes(x = subgrupo, y = 100 - 5),
direction = "hv", color = "blue", lty = "dashed"
) +
geom_point(
mapping = aes(
x = subgrupo, y = criterio_10, color = violacion,
shape = violacion
)
) +
scale_color_manual(
values = c(
"No" = "blue", "Si" = "red", show.legend = FALSE
)
) +
scale_shape_manual(values = c(16, 8)) +
geom_line(
mapping = aes(x = subgrupo, y = criterio_10),
color = "black"
) +
pammtools::geom_stepribbon(
aes(ymin = 100 - 3 * 5, ymax = 100 + 3 * 5),
fill = "green", alpha = 0.2, direction = "hv"
) +
pammtools::geom_stepribbon(
aes(ymin = 100 - 2 * 5, ymax = 100 + 2 * 5),
fill = "#00FF00", alpha = 0.2, direction = "hv"
) +
pammtools::geom_stepribbon(
aes(ymin = 100 - 5, ymax = 100 + 5),
fill = "#00FFFF", alpha = 0.2, direction = "hv"
) +
pammtools::geom_stepribbon(
aes(ymin = 100 + 3 * 5, ymax = Inf),
fill = "#FF0000", alpha = 0.2, direction = "hv"
) +
pammtools::geom_stepribbon(
aes(ymin = 100 - 3 * 5, ymax = -Inf),
fill = "#FF0000", alpha = 0.2, direction = "hv"
) +
# annotate(
# "text",
# x = 9.5, y = 118.5,
# label = latex2exp::TeX(
# "$Zona \\, fuera \\, de \\, control$", bold = TRUE,
# italic = TRUE
# )
# ) +
# annotate(
# "text",
# x = 9.5, y = 81.5,
# label = latex2exp::TeX(
# "$Zona \\, fuera \\, de \\, control$", bold = TRUE,
# italic = TRUE
# )
# ) +
annotate(
"text",
x = 9.5, y = 112.5,
label = latex2exp::TeX(
"$Zona \\, A$", bold = TRUE,italic = TRUE
)
) +
annotate(
"text",
x = 9.5, y = 87.5,
label = latex2exp::TeX(
"$Zona \\, A$", bold = TRUE,italic = TRUE
)
) +
annotate(
"text",
x = 9.5, y = 107.5,
label = latex2exp::TeX(
"$Zona \\, B$", bold = TRUE,italic = TRUE
)
) +
annotate(
"text",
x = 9.5, y = 92.5,
label = latex2exp::TeX(
"$Zona \\, B$", bold = TRUE,italic = TRUE
)
) +
annotate(
"text",
x = 9.5, y = 102.5,
label = latex2exp::TeX(
"$Zona \\, C$", bold = TRUE,italic = TRUE
)
) +
annotate(
"text",
x = 9.5, y = 97.5,
label = latex2exp::TeX(
"$Zona \\, C$", bold = TRUE,italic = TRUE
)
) +
annotate(
"text",
x = 15 + 1, y = 100 - 3 * 5,
label = latex2exp::TeX(
"$\\mu_W - 3\\sigma_W$",
italic = TRUE
)
) +
annotate(
"text", x = 15 + 1.1, y = 100 + 3 * 5,
label = latex2exp::TeX(
"$\\mu_W + 3\\sigma_W$",
italic = TRUE
)
) +
annotate(
"text",
x = 15 + 0.5, y = 100,
label = latex2exp::TeX(
"$\\mu_W$", italic = TRUE
)
) +
annotate(
"text",
x = 15 + 1.1, y = 100 - 2 * 5,
label = latex2exp::TeX(
"$\\mu_W - 2\\sigma_W$",
italic = TRUE
)
) +
annotate(
"text", x = 15 + 1.1, y = 100 + 2 * 5,
label = latex2exp::TeX(
"$\\mu_W + 2\\sigma_W$",
italic = TRUE
)
) +
annotate(
"text",
x = 15 + 1, y = 100 - 5,
label = latex2exp::TeX(
"$\\mu_W - \\sigma_W$",
italic = TRUE
)
) +
annotate(
"text", x = 15 + 1, y = 100 + 5,
label = latex2exp::TeX(
"$\\mu_W + \\sigma_W$",
italic = TRUE
)
) +
labs(
x = latex2exp::TeX(
"Número de muestras o tiempo", bold = TRUE,
italic = TRUE
),
y = latex2exp::TeX(
"Característica de la calidad",
bold = TRUE, italic = TRUE
),
shape = "Fuera de control", color = "Fuera de control"
) +
scale_x_continuous(
breaks = seq(from = 1, to = 15, by = 1),
limits = c(1, 17)
) +
scale_y_continuous(
breaks = seq(
from = 100 - 3 * 5, to = 100 + 3 * 5, by = 5
),
limits = c(100 - 4 * 5, 100 + 4 * 5)
) +
theme_bw() +
theme(
legend.position = "bottom",
legend.title = element_text(face = "bold"),
legend.text = element_text(face = "bold"),
panel.grid = element_blank()
)
```