Skip to content

Factor names in skeleton ANOVA for strip-plot design #162

@michaelhm-daf

Description

@michaelhm-daf

Hi,

Thanks for incorporating the functionality to produce skeleton ANOVA's for strip-plot designs.

I would like to generate a strip-plot design such that the factor names appear in the output of the skeleton ANOVA table. This works nicely for a split-plot design

splitPlot <- design(type="split", 
                            treatments = c("Var1","Var2","Var3"), 
                            sub_treatments= c("Herb1","Herb2","Herb3","Herb4"),
                            reps = 3, nrows = 3, ncols = 12, 
                            brows = 3, bcols = 4,, 
                            fac.names=list(
                              "Variety" = c("Var1","Var2","Var3"),
                              "Herbicide" = c("Herb1","Herb2","Herb3","Herb4")),
                            quiet=TRUE)

splitPlot$satab

Which nicely outputs

Source of Variation                          df
==================================================
Block stratum                                2
--------------------------------------------------
Whole plot stratum
         Variety                             2
Whole plot Residual                          4
==================================================
Subplot stratum
         Herbicide                           3
         Variety:Herbicide                   6
         Subplot Residual                   18
==================================================
Total                                       35

When I use the same design parameters to generate the skeleton ANOVA for a strip-plot design,

stripPlot <- design(type="strip", 
                            treatments = c("Var1","Var2","Var3"), 
                            sub_treatments= c("Herb1","Herb2","Herb3","Herb4"),
                            
                            reps = 3, nrows = 3, ncols = 12, 
                            brows = 3, bcols = 4,, 
                            fac.names=list(
                              "Variety" = c("Var1","Var2","Var3"),
                              "Herbicide" = c("Herb1","Herb2","Herb3","Herb4")),
                            quiet=TRUE)

I get the following error:

Error: Expected strip plot design book to contain 'treatments' and 'sub_treatments' columns.

I wrote a function to make the skeleton ANOVA output from a strip-plot design look nicer.

format_satab_strip <- function(anova_structure) {
  sources <- anova_structure$sources
  df <- anova_structure$df
  names <- anova_structure$names
  
  # Determine width based on df magnitude
  width1 <- ifelse(df[1] > 9, 44, 45)
  width2 <- ifelse(df[2] > 9, 35, 36)
  width3 <- ifelse(df[3] > 9, 44, 45)
  width4 <- ifelse(df[4] > 9, 35, 36)
  width5 <- ifelse(df[5] > 9, 44, 45)
  width6 <- ifelse(df[6] > 9, 35, 36)
  width7 <- ifelse(df[7] > 9, 44, 45)
  width8 <- ifelse(df[8] > 9, 44, 45)
  
  output <- c(
    paste0(format("Source of Variation", width = 45), "df", "\n"),
    "==================================================\n",
    paste0(format(sources[1], width = width1), df[1], "\n"),
    "--------------------------------------------------\n",
    "Row strip stratum\n",
    paste0(format(" ", width = 9), format(sources[2], width = width2), df[2], "\n"),
    paste0(format(sources[3], width = width3), df[3], "\n"),
    "==================================================\n",
    "Column strip stratum\n",
    paste0(format(" ", width = 9), format(sources[4], width = width4), df[4], "\n"),
    paste0(format(sources[5], width = width5), df[5], "\n"),
    "==================================================\n",
    "Observational unit stratum\n",
    paste0(format(" ", width = 9), format(sources[6], width = width6), df[6], "\n"),
    paste0(format(sources[7], width = width7), df[7], "\n"),
    "==================================================\n",
    paste0(format("Total", width = width8), df[8], "\n")
  )
  
  class(output) <- c("satab", class(output))
  return(output)
}

Which outputs the following for a strip-plot design

stripPlot <- design(type="strip", 
                    treatments = c("Var1","Var2","Var3"), 
                    sub_treatments= c("Herb1","Herb2","Herb3","Herb4"),
                    
                    reps = 3, nrows = 3, ncols = 12, 
                    brows = 3, bcols = 4)
Source of Variation                          df
==================================================
Block stratum                                2
--------------------------------------------------
Row strip stratum
         treatments                          2
treatments Residual                          4
==================================================
Column strip stratum
         sub_treatments                      3
sub_treatments Residual                      6
==================================================
Observational unit stratum
         treatments:sub_treatments           6
Interaction Residual                        12
==================================================
Total                                       35

But does not include the factor names in the skeleton ANOVA. When attempting to include fac.names, I still get the same error message as above.

Error: Expected strip plot design book to contain 'treatments' and 'sub_treatments' columns.

Would it be possible to fix this when you have time?

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions