Skip to content

can model_parameters.aov return type 3 SSs? #230

@mattansb

Description

@mattansb

Currently gives type 1 SSs 😨

mtcars$am_f <- factor(mtcars$am)
mtcars$cyl_f <- factor(mtcars$cyl)

model <- aov(mpg ~ am_f * cyl_f, data = mtcars)

parameters::model_parameters(model)
#> Parameter  | Sum_Squares | df | Mean_Square |     F |      p
#> ------------------------------------------------------------
#> am_f       |      405.15 |  1 |      405.15 | 44.06 | < .001
#> cyl_f      |      456.40 |  2 |      228.20 | 24.82 | < .001
#> am_f:cyl_f |       25.44 |  2 |       12.72 |  1.38 | 0.269 
#> Residuals  |      239.06 | 26 |        9.19 |       |
anova(model)
#> Analysis of Variance Table
#> 
#> Response: mpg
#>            Df Sum Sq Mean Sq F value    Pr(>F)    
#> am_f        1 405.15  405.15 44.0641 4.847e-07 ***
#> cyl_f       2 456.40  228.20 24.8190 9.355e-07 ***
#> am_f:cyl_f  2  25.44   12.72  1.3832    0.2686    
#> Residuals  26 239.06    9.19                      
#> ---
#> Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
car::Anova(model, type = 2)
#> Anova Table (Type II tests)
#> 
#> Response: mpg
#>            Sum Sq Df F value    Pr(>F)    
#> am_f        36.77  1  3.9988   0.05608 .  
#> cyl_f      456.40  2 24.8190 9.355e-07 ***
#> am_f:cyl_f  25.44  2  1.3832   0.26861    
#> Residuals  239.06 26                      
#> ---
#> Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
car::Anova(model, type = 3)
#> Anova Table (Type III tests)
#> 
#> Response: mpg
#>              Sum Sq Df  F value    Pr(>F)    
#> (Intercept) 1573.23  1 171.1040 6.057e-13 ***
#> am_f          58.43  1   6.3549 0.0181761 *  
#> cyl_f        167.71  2   9.1200 0.0009978 ***
#> am_f:cyl_f    25.44  2   1.3832 0.2686140    
#> Residuals    239.06 26                       
#> ---
#> Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Created on 2020-04-02 by the reprex package (v0.3.0)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions