Skip to main content
Statistics LibreTexts

5.1.3a: The Additive Model

  • Page ID
    33638
  • \( \newcommand{\vecs}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} } \) \( \newcommand{\vecd}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash {#1}}} \)\(\newcommand{\id}{\mathrm{id}}\) \( \newcommand{\Span}{\mathrm{span}}\) \( \newcommand{\kernel}{\mathrm{null}\,}\) \( \newcommand{\range}{\mathrm{range}\,}\) \( \newcommand{\RealPart}{\mathrm{Re}}\) \( \newcommand{\ImaginaryPart}{\mathrm{Im}}\) \( \newcommand{\Argument}{\mathrm{Arg}}\) \( \newcommand{\norm}[1]{\| #1 \|}\) \( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\) \( \newcommand{\Span}{\mathrm{span}}\) \(\newcommand{\id}{\mathrm{id}}\) \( \newcommand{\Span}{\mathrm{span}}\) \( \newcommand{\kernel}{\mathrm{null}\,}\) \( \newcommand{\range}{\mathrm{range}\,}\) \( \newcommand{\RealPart}{\mathrm{Re}}\) \( \newcommand{\ImaginaryPart}{\mathrm{Im}}\) \( \newcommand{\Argument}{\mathrm{Arg}}\) \( \newcommand{\norm}[1]{\| #1 \|}\) \( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\) \( \newcommand{\Span}{\mathrm{span}}\)\(\newcommand{\AA}{\unicode[.8,0]{x212B}}\)

    • Load the glucose in blood serum data.
    • Obtain the ANOVA table with interaction.
    • Obtain the ANOVA table without interaction.
    • Obtain estimators and CIs for means for each treatment level.
    • Obtain Tukey’s multiple comparisons CIs and grouping.

    1. Load the glucose in blood serum data by using the following commands:

    setwd("~/path-to-folder/")
    glucose_data <- read.table("glucose_data.txt",header=T)
    attach(glucose_data)
    

    2. Obtain the ANOVA table with interaction by using the following commands:

    anova<-aov(glucose ~ factor(method) + factor(doping) + factor(method)*factor(doping),data=glucose_data)
    summary(anova)
    Df Sum Sq Mean Sq   F value   Pr(>F)    
    factor(method)                 1    264     264    98.347 3.92e-07 ***
    factor(doping)                 2  57026   28513 10632.526  < 2e-16 ***
    factor(method):factor(doping)  2     14       7     2.577    0.117    
    Residuals                     12     32       3                       
    ---
    Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
    

    Here we can see that the interaction term is not significant, and we can drop it from the model. Also, notice that I have defined method and doping as factors since they have numeric values.

    3. Obtain the ANOVA table without interaction by using the following commands:

    anova1<-aov(glucose ~ factor(method) + factor(doping),data=glucose_data)
    summary(anova1)
    Df Sum Sq Mean Sq F value   Pr(>F)    
    factor(method)  1    264     264   80.27 3.58e-07 ***
    factor(doping)  2  57026   28513 8677.63  < 2e-16 ***
    Residuals      14     46       3                     
    ---
    Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
    

    The Error SS is now 46.001, which is the sum of the interaction SS and the error SS of the model with the interaction. The df values were also added the same way.

    4. Obtain estimators and CIs for means for each treatment level by using the following commands:

    library(lsmeans)
    lsmeans(anova1,"method")
    method lsmean    SE df lower.CL upper.CL
    1    123 0.604 14      122      125
    2    116 0.604 14      114      117
    Results are averaged over the levels of: doping
    Confidence level used: 0.95
    lsmeans(anova1,"doping")
    doping lsmean   SE df lower.CL upper.CL
    1   43.7 0.74 14     42.1     45.3
    2  136.8 0.74 14    135.2    138.4
    3  178.3 0.74 14    176.7    179.9
    Results are averaged over the levels of: method
    Confidence level used: 0.95
    

    5. Obtain Tukey’s multiple comparisons CIs and grouping by using the following commands:

    tukey_multiple_comparisons<-TukeyHSD(anova1,conf.level=0.95,ordered=TRUE)
    tukey_multiple_comparisons
    Tukey multiple comparisons of means
    95% family-wise confidence level
    factor levels have been ordered
    Fit: aov(formula = glucose ~ factor(method) + factor(doping), data = glucose_data)
    $`factor(method)`
    diff      lwr      upr p adj
    1-2 7.655556 5.822828 9.488283 4e-07
    $`factor(doping)`
    diff       lwr       upr p adj
    2-1  93.10000  90.36089  95.83911     0
    3-1 134.61667 131.87755 137.35578     0
    3-2  41.51667  38.77755  44.25578     0
    tukey_grouping<-multcompLetters4(anova1,tukey_multiple_comparisons)
    print(tukey_grouping)
    $`factor(method)`
    1   2
    "a" "b"
    $`factor(doping)`
    3   2   1
    "a" "b" "c"
    detach(glucose_data)
    

    This page titled 5.1.3a: The Additive Model is shared under a CC BY-NC 4.0 license and was authored, remixed, and/or curated by Penn State's Department of Statistics.

    • Was this article helpful?