La profundidad de corte y la velocidad de alimentación afectan el acabdo de un metal.
La velocidad de corte y la alimentación interactúan afectando el acabo del metal.
# Tabla de datos (stacked)
profundidad <- as.factor(c(.15,.15,.15,.18,.18,.18,.21,.21,.21,.24,.24,.24,
.15,.15,.15,.18,.18,.18,.21,.21,.21,.24,.24,.24,
.15,.15,.15,.18,.18,.18,.21,.21,.21,.24,.24,.24))
velocidad <- as.factor(c(rep(.2,12),rep(.25,12),rep(.3,12)))
acabado <- c(74,64,60,79,68,73,82,88,92,99,104,96,
92,86,88,98,104,88,99,108,95,104,110,99,
99,98,102,104,99,95,108,110,99,114,111,107)
metal <- data.frame(profundidad,velocidad, acabado)
metal
m1 <- lm(acabado~profundidad,metal)
m2 <- lm(acabado~velocidad,metal)
anova (m1)
Analysis of Variance Table
Response: acabado
Df Sum Sq Mean Sq F value Pr(>F)
profundidad 3 2125.1 708.37 5.1437 0.005134 **
Residuals 32 4406.9 137.72
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
anova (m2)
Analysis of Variance Table
Response: acabado
Df Sum Sq Mean Sq F value Pr(>F)
velocidad 2 3160.5 1580.25 15.467 1.823e-05 ***
Residuals 33 3371.5 102.17
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
m3 <- lm(acabado~profundidad:velocidad+profundidad+velocidad,metal)
anova (m3)
Analysis of Variance Table
Response: acabado
Df Sum Sq Mean Sq F value Pr(>F)
profundidad 3 2125.11 708.37 24.6628 1.652e-07 ***
velocidad 2 3160.50 1580.25 55.0184 1.086e-09 ***
profundidad:velocidad 6 557.06 92.84 3.2324 0.01797 *
Residuals 24 689.33 28.72
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
m4 <- lm(acabado~profundidad+velocidad,metal)
anova (m4) #Anova tipo I
Analysis of Variance Table
Response: acabado
Df Sum Sq Mean Sq F value Pr(>F)
profundidad 3 2125.1 708.37 17.050 1.192e-06 ***
velocidad 2 3160.5 1580.25 38.036 5.927e-09 ***
Residuals 30 1246.4 41.55
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
summary (m4)
Call:
lm(formula = acabado ~ profundidad + velocidad, data = metal)
Residuals:
Min 1Q Median 3Q Max
-12.0278 -4.1736 0.2917 4.1597 11.8611
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 72.028 2.631 27.372 < 2e-16 ***
profundidad0.18 5.000 3.039 1.646 0.11030
profundidad0.21 13.111 3.039 4.315 0.00016 ***
profundidad0.24 20.111 3.039 6.619 2.51e-07 ***
velocidad0.25 16.000 2.631 6.080 1.11e-06 ***
velocidad0.3 22.250 2.631 8.456 1.95e-09 ***
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Residual standard error: 6.446 on 30 degrees of freedom
Multiple R-squared: 0.8092, Adjusted R-squared: 0.7774
F-statistic: 25.44 on 5 and 30 DF, p-value: 5.933e-10
library (car)
Anova(m4, type="II")
Anova Table (Type II tests)
Response: acabado
Sum Sq Df F value Pr(>F)
profundidad 2125.1 3 17.050 1.192e-06 ***
velocidad 3160.5 2 38.036 5.927e-09 ***
Residuals 1246.4 30
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Anova(m4, type="III")
Anova Table (Type III tests)
Response: acabado
Sum Sq Df F value Pr(>F)
(Intercept) 31128.0 1 749.237 < 2.2e-16 ***
profundidad 2125.1 3 17.050 1.192e-06 ***
velocidad 3160.5 2 38.036 5.927e-09 ***
Residuals 1246.4 30
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
library (effects) #Graficar intervalos descriptivos
plot (allEffects(m4))
allEffects(m4)
model: acabado ~ profundidad + velocidad
profundidad effect
profundidad
0.15 0.18 0.21 0.24
84.77778 89.77778 97.88889 104.88889
velocidad effect
velocidad
0.2 0.25 0.3
81.58333 97.58333 103.83333
# Verificar la normalidad de los residuos con el algoritmo de Shapiro
plot(m4,2)
shapiro.test(residuals(m4))
Shapiro-Wilk normality test
data: residuals(m4)
W = 0.98043, p-value = 0.7598
Resumen de estadísticos descriptivos para la profundidad
library(dplyr)
group_by(metal, profundidad) %>%
summarise(
count = n(),
mean = mean(acabado, na.rm = TRUE),
sd = sd(acabado, na.rm = TRUE)
)
Ejercicio 1. Calcula los estadísticos descriptivos del velocidadilizante.
library(dplyr)
group_by(metal, velocidad) %>%
summarise(
count = n(),
mean = mean(acabado, na.rm = TRUE),
sd = sd(acabado, na.rm = TRUE)
)
Verificar el supuesto de homogeneidad de las varianzas.
bartlett.test(acabado~velocidad,metal)
Bartlett test of homogeneity of variances
data: acabado by velocidad
Bartlett's K-squared = 8.3141, df = 2, p-value = 0.01565
bartlett.test(acabado~profundidad,metal)
Bartlett test of homogeneity of variances
data: acabado by profundidad
Bartlett's K-squared = 6.544, df = 3, p-value = 0.08794