This function performs a hypothesis test for lack of fit in a simple regression model.

anova_table_lm(mod)

Arguments

mod

A lm object.

Value

anova_table_lm function returns the anova table.

Examples

# Ejemplo RLS datos soldadura
file <- "https://raw.githubusercontent.com/fhernanb/datos/master/propelente"
datos <- read.table(file=file, header=TRUE)

mod1 <- lm(Resistencia ~ Edad, data=datos)

anova_table_lm(mod1)
#> Anova Table
#>             Sum Sq Df Mean Sq F value    Pr(>F)    
#> Regression 1527483  1 1527483  165.38 1.643e-10 ***
#> Residuals   166255 18    9236                      
#> Total      1693738 19                              
#> ---
#> Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1


# Ejemplo 9.4 de Montgomery (1996)
datos <- structure(list(nivel_hidro = c(0.99, 1.02, 1.15, 1.29, 1.46, 
                                        1.36, 0.87, 1.23, 1.55, 1.4, 
                                        1.19, 1.15, 0.98, 1.01, 1.11, 1.2, 
                                        1.26, 1.32, 1.43, 0.95), 
                        pureza = c(90.01, 89.05, 91.43, 93.74,
                                   96.73, 94.45, 87.59, 91.77, 
                                   99.42, 93.65, 93.54, 92.52, 90.56,
                                   89.54, 89.85, 90.39, 93.25, 93.41, 
                                   94.98, 87.33)), 
                   class = "data.frame", row.names = c(NA, -20L))

mod2 <- lm(pureza ~ nivel_hidro, data=datos)
anova_table_lm(mod2)
#> Anova Table
#>            Sum Sq Df Mean Sq F value    Pr(>F)    
#> Regression 152.13  1 152.127  128.86 1.227e-09 ***
#> Residuals   21.25 18   1.181                      
#> Total      173.38 19                              
#> ---
#> Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1


# Ejemplo 10-4 de Montgomery (1996)
tiempo <- c(9.95, 24.45, 31.75, 35.00, 25.02, 16.86, 14.38, 
            9.60, 24.35, 27.50, 17.08, 37.00, 41.95, 11.66, 
            21.65, 17.89, 69.00, 10.30, 34.93, 46.59, 44.88, 
            54.12, 56.23, 22.13, 21.15)

cantidad <- c(2, 8, 11, 10, 8, 4, 2, 2, 9, 8, 4, 11, 12, 2, 4, 
              4, 20, 1, 10, 15, 15, 16, 17, 6, 5)

distancia <- c(50, 110, 120, 550, 295, 200, 375, 52, 100, 
               300, 412, 400, 500, 360, 205, 400, 600, 585, 
               540, 250, 290, 510, 590, 100, 400)

datos <- data.frame(tiempo, cantidad, distancia)

mod3 <- lm(tiempo ~ cantidad + distancia, data=datos)

anova_table_lm(mod3)
#> Anova Table
#>            Sum Sq Df Mean Sq F value    Pr(>F)    
#> Regression   5969  2 2984.49  570.71 < 2.2e-16 ***
#> Residuals     115 22    5.23                      
#> Total        6084 24                              
#> ---
#> Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1