| Type: | Package | 
| Title: | Experimental Design and Analysis for Tree Improvement | 
| Version: | 1.1.0 | 
| Maintainer: | Muhammad Yaseen <myaseen208@gmail.com> | 
| Description: | Provides data sets and R Codes for E.R. Williams, C.E. Harwood and A.C. Matheson (2023). Experimental Design and Analysis for Tree Improvement, CSIRO Publishing. | 
| Depends: | R (≥ 4.1.0) | 
| Imports: | car, dae, dplyr, emmeans, ggplot2, lmerTest, magrittr, predictmeans, stats, supernova | 
| License: | GPL-3 | 
| URL: | https://github.com/MYaseen208/eda4treeR https://CRAN.R-project.org/package=eda4treeR https://myaseen208.com/eda4treeR/ https://myaseen208.com/EDATR/ | 
| BugReports: | https://github.com/myaseen208/eda4treeR/issues | 
| LazyData: | TRUE | 
| RoxygenNote: | 7.3.2 | 
| Encoding: | UTF-8 | 
| Suggests: | testthat | 
| Note: | 1. Asian Development Bank (ADB), Islamabad, Pakistan. 2. Benazir Income Support Programme (BISP), Islamabad, Pakistan. 3. Department of Mathematics and Statistics, University of Agriculture Faisalabad, Pakistan. | 
| NeedsCompilation: | no | 
| Packaged: | 2024-09-13 21:21:45 UTC; myaseen208 | 
| Author: | Muhammad Yaseen | 
| Repository: | CRAN | 
| Date/Publication: | 2024-09-13 21:50:02 UTC | 
Data for Example 2.1 from Experimental Design and Analysis for Tree Improvement
Description
Exam2.1 is used to compare two seed lots by using single factor ANOVA.
Usage
data(DataExam2.1)
Format
A data.frame with 16 rows and 2 variables.
- seedlot
- Two Seedlots Seed Orchad (SO) and routin plantation (P) 
- dbh
- Diameter at breast height 
Author(s)
- Muhammad Yaseen (myaseen208@gmail.com) 
- Sami Ullah (samiullahuos@gmail.com) 
References
- E.R. Williams, C.E. Harwood and A.C. Matheson (2023). Experimental Design and Analysis for Tree Improvement. CSIRO Publishing (https://www.publish.csiro.au/book/3145/). 
See Also
Examples
data(DataExam2.1)
Data for Example 2.2 from Experimental Design and Analysis for Tree Improvement
Description
Exam2.2 is used to compare two seed lots by using ANOVA under RCB Design.
Usage
data(DataExam2.2)
Format
A data.frame with 16 rows and 2 variables.
- repl
- repl 
- block
- block 
- Seedlot
- Two Seedlots Seed Orchad (SO) and routin plantation (P) 
- dbh
- Diameter at breast height 
Author(s)
- Muhammad Yaseen (myaseen208@gmail.com) 
- Sami Ullah (samiullahuos@gmail.com) 
References
- E.R. Williams, C.E. Harwood and A.C. Matheson (2023). Experimental Design and Analysis for Tree Improvement. CSIRO Publishing (https://www.publish.csiro.au/book/3145/). 
See Also
Examples
data(DataExam2.2)
Data for Example 3.1 from Experimental Design and Analysis for Tree Improvement
Description
Exam3.1 is part of data from Australian Centre for Agricultural Research (ACIAR) in Queensland, Australia (Experiment 309).
Usage
data(DataExam3.1)
Format
A data.frame with 80 rows and 6 variables.
- repl
- Replication number of different Seedlots 
- PlotNo
- Plot No of differnt Trees 
- seedlot
- Seed Lot number 
- TreeNo
- Tree number of Seedlots 
- ht
- Height in meter 
- dgl
- Diameter at ground level 
Author(s)
- Muhammad Yaseen (myaseen208@gmail.com) 
- Sami Ullah (samiullahuos@gmail.com) 
References
- E.R. Williams, C.E. Harwood and A.C. Matheson (2023). Experimental Design and Analysis for Tree Improvement. CSIRO Publishing (https://www.publish.csiro.au/book/3145/). 
See Also
Examples
data(DataExam3.1)
Data for Example 3.1.1 from Experimental Design and Analysis for Tree Improvement
Description
Exam3.1.1 is part of data from Australian Centre for Agricultural Research (ACIAR) in Queensland, Australia (Experiment 309).
Usage
data(DataExam3.1.1)
Format
A data.frame with 10 rows and 6 variables.
- repl
- Replication number of different Seedlots 
- PlotNo
- Plot No of differnt Trees 
- seedlot
- Seed Lot number 
- TreeNo
- Tree number of Seedlots 
- ht
- Height in meter 
- Var
- Var 
- TreeCount
- TreeCount 
Author(s)
- Muhammad Yaseen (myaseen208@gmail.com) 
- Sami Ullah (samiullahuos@gmail.com) 
References
- E.R. Williams, C.E. Harwood and A.C. Matheson (2023). Experimental Design and Analysis for Tree Improvement. CSIRO Publishing (https://www.publish.csiro.au/book/3145/). 
See Also
Examples
data(DataExam3.1.1)
Data for Example 4.3 from Experimental Design and Analysis for Tree Improvement
Description
Exam4.3 presents the germination count data for 4 Pre-Treatments and 6 Seedlots.
Usage
data(DataExam4.3)
Format
A data.frame with 72 rows and 8 variables.
- rep
- Replication number of Treatment 
- row
- Row number of different Seedlots 
- column
- Column number of differnt Trees 
- seedlot
- Seed lot number 
- treat
- Treatment types 
- count
- Number of germinated seeds out of 25 
- percent
- Germination Percentage 
- contcomp
- Control or Trated Plot 
Author(s)
- Muhammad Yaseen (myaseen208@gmail.com) 
- Sami Ullah (samiullahuos@gmail.com) 
References
- E.R. Williams, C.E. Harwood and A.C. Matheson (2023). Experimental Design and Analysis for Tree Improvement. CSIRO Publishing (https://www.publish.csiro.au/book/3145/). 
See Also
Examples
data(DataExam4.3)
Data for Example 4.3.1 from Experimental Design and Analysis for Tree Improvement
Description
Exam4.3.1 presents the germination count data for 4 Pre-Treatments and 6 Seedlots.
Usage
data(DataExam4.3.1)
Format
A data.frame with 72 rows and 8 variables.
- Row
- Row number of different Seedlots 
- Column
- Column number of differnt Trees 
- Replication
- Replication number of Treatment 
- Contcomp
- Control or Trated Plot 
- Pretreatment
- Treatment types 
- SeedLot
- Seed lot number 
- GerminationCount
- Number of germinated seeds out of 25 
- Percent
- Germination Percentage 
Author(s)
- Muhammad Yaseen (myaseen208@gmail.com) 
- Sami Ullah (samiullahuos@gmail.com) 
References
- E.R. Williams, C.E. Harwood and A.C. Matheson (2023). Experimental Design and Analysis for Tree Improvement. CSIRO Publishing (https://www.publish.csiro.au/book/3145/). 
See Also
Examples
data(DataExam4.3.1)
Data for Example 4.4 from Experimental Design and Analysis for Tree Improvement
Description
Exam4.4 presents the height means for 4 seedlots under factorial arrangement for two levels of Fertilizer and two levels of Irrigation.
Usage
data(DataExam4.4)
Format
A data.frame with 32 rows and 5 variables.
- repl
- Replication number 
- irrig
- Irrigation type 
- fert
- Fertilizer type 
- seedlot
- Seed Lot number 
- height
- Height of the plants 
Author(s)
- Muhammad Yaseen (myaseen208@gmail.com) 
- Sami Ullah (samiullahuos@gmail.com) 
References
- E.R. Williams, C.E. Harwood and A.C. Matheson (2023). Experimental Design and Analysis for Tree Improvement. CSIRO Publishing (https://www.publish.csiro.au/book/3145/). 
See Also
Examples
data(DataExam4.4)
Data for Example 5.1 from Experimental Design and Analysis for Tree Improvement
Description
Exam5.1 presents the height of 27 seedlots from 4 sites.
Usage
data(DataExam5.1)
Format
A data.frame with 108 rows and 4 variables.
- site
- Sites for the experiment 
- seedlot
- Seed lot number 
- ht
- Height of the plants 
- sitemean
- Mean Height of Each Site 
Author(s)
- Muhammad Yaseen (myaseen208@gmail.com) 
- Sami Ullah (samiullahuos@gmail.com) 
References
- E.R. Williams, C.E. Harwood and A.C. Matheson (2023). Experimental Design and Analysis for Tree Improvement. CSIRO Publishing (https://www.publish.csiro.au/book/3145/). 
See Also
Examples
data(DataExam5.1)
Data for Example 5.2 from Experimental Design and Analysis for Tree Improvement
Description
Exam5.2 presents the height of 37 seedlots from 6 sites.
Usage
data(DataExam5.2)
Format
A data.frame with 108 rows and 4 variables.
- site
- Sites for the experiment 
- seedlot
- Seed lot number 
- ht
- Height of the plants 
- sitemean
- Mean Height of Each Site 
Author(s)
- Muhammad Yaseen (myaseen208@gmail.com) 
- Sami Ullah (samiullahuos@gmail.com) 
References
- E.R. Williams, C.E. Harwood and A.C. Matheson (2023). Experimental Design and Analysis for Tree Improvement. CSIRO Publishing (https://www.publish.csiro.au/book/3145/). 
See Also
Examples
data(DataExam5.2)
Data for Example 6.2 from Experimental Design and Analysis for Tree Improvement
Description
Exam 6.2 Dbh mean, Dbh varince and number of trees per plot from 3 provinces("PNG","Sabah","Queensland") with 4 replicationsof 48 families.
Usage
data(DataExam6.2)
Format
A data.frame with 192 rows and 7 variables.
- Replication
- Replication number of different Families 
- Plot.number
- Plot number of differnt Trees 
- Family
- Family Numuber 
- Province
- Province of family 
- Dbh.mean
- Average Diameter at breast height of trees within plot 
- Dbh.variance
- Variance of Diameter at breast height of trees within plot 
- Dbh.count
- Number of trees within plot 
Author(s)
- Muhammad Yaseen (myaseen208@gmail.com) 
- Sami Ullah (samiullahuos@gmail.com) 
References
- E.R. Williams, C.E. Harwood and A.C. Matheson (2023). Experimental Design and Analysis for Tree Improvement. CSIRO Publishing (https://www.publish.csiro.au/book/3145/). 
Examples
data(DataExam6.2)
Data for Example 8.1 from Experimental Design and Analysis for Tree Improvement
Description
Exam8.1 presents the Diameter at breast height (Dbh) of 60 SeedLots under layout of row column design with 6 rows and 10 columns in 18 countries and 59 provinces of 18 selected countries.
Usage
data(DataExam8.1)
Format
A data.frame with 236 rows and 8 variables.
- repl
- There are 4 replication for the design 
- row
- Experiment is conducted under 6 rows 
\
- col
- Experiment is conducted under 4 columns 
- inoc
- Seedling were inoculated for 2 different time periods half for one week and half for seven weeks 
- prov
- provenance 
- Country
- Data for different seedlots was collected from 18 countries 
- Dbh
- Diameter at breast height 
- Country.1
- Recoded Country lables 
Author(s)
- Muhammad Yaseen (myaseen208@gmail.com) 
- Sami Ullah (samiullahuos@gmail.com) 
References
- E.R. Williams, C.E. Harwood and A.C. Matheson (2023). Experimental Design and Analysis for Tree Improvement. CSIRO Publishing (https://www.publish.csiro.au/book/3145/). 
See Also
Examples
data(DataExam8.1)
Data for Example 8.2 from Experimental Design and Analysis for Tree Improvement
Description
Exam8.2 presents the Diameter at breast height (Dbh) of 60 SeedLots under layout of row column design with 6 rows and 10 columns in 18 countries and 59 provinces of 18 selected countries.
Usage
data(DataExam8.2)
Format
A data.frame with 236 rows and 8 variables.
- repl
- There are 4 replication for the design 
- row
- Experiment is conducted under 6 rows 
\
- column
- Experiment is conducted under 4 columns 
- clonenum
- Clonenum 
- contcompf
- Contcompf 
- standard
- Standard 
- clone
- Clone 
- dbh
- dbhmean 
- dbhvar
- dbhvariance 
- ht
- htmean 
- htvar
- htvariance 
- count
- count 
- contcompv
- Contcompv 
Author(s)
- Muhammad Yaseen (myaseen208@gmail.com) 
- Sami Ullah (samiullahuos@gmail.com) 
References
- E.R. Williams, C.E. Harwood and A.C. Matheson (2023). Experimental Design and Analysis for Tree Improvement. CSIRO Publishing (https://www.publish.csiro.au/book/3145/). 
See Also
Examples
data(DataExam8.2)
Example 2.1 from Experimental Design and Analysis for Tree Improvement
Description
Exam2.1 is used to compare two seed lots by using single factor ANOVA.
Author(s)
- Muhammad Yaseen (myaseen208@gmail.com) 
- Sami Ullah (samiullahuos@gmail.com) 
References
- E.R. Williams, C.E. Harwood and A.C. Matheson (2023). Experimental Design and Analysis for Tree Improvement. CSIRO Publishing (https://www.publish.csiro.au/book/3145/). 
See Also
Examples
library(car)
library(dae)
library(dplyr)
library(emmeans)
library(ggplot2)
library(lmerTest)
library(magrittr)
library(predictmeans)
data(DataExam2.1)
# Pg. 22
fmtab2.3  <- lm(formula = dbh ~ seedlot, data = DataExam2.1)
# Pg. 23
anova(fmtab2.3)
# Pg. 23
emmeans(object = fmtab2.3, specs = ~ seedlot)
emmip(object = fmtab2.3, formula = ~ seedlot) +
  theme_classic()
Example 2.2 from Experimental Design and Analysis for Tree Improvement
Description
Exam2.2 is used to compare two seed lots by using ANOVA under RCB Design.
Author(s)
- Muhammad Yaseen (myaseen208@gmail.com) 
- Sami Ullah (samiullahuos@gmail.com) 
References
- E.R. Williams, C.E. Harwood and A.C. Matheson (2023). Experimental Design and Analysis for Tree Improvement. CSIRO Publishing (https://www.publish.csiro.au/book/3145/). 
See Also
Examples
library(car)
library(dae)
library(dplyr)
library(emmeans)
library(ggplot2)
library(lmerTest)
library(magrittr)
library(predictmeans)
data(DataExam2.2)
# Pg. 24
fmtab2.5 <-
          lm(
             formula  = dbh ~ block + seedlot
           , data     = DataExam2.2
           )
# Pg. 26
anova(fmtab2.5)
# Pg. 26
emmeans(object = fmtab2.5, specs = ~ seedlot)
emmip(object = fmtab2.5, formula = ~ seedlot) +
  theme_classic()
Data for Example 3.1 from Experimental Design and Analysis for Tree Improvement
Description
Exam3.1 is part of data from Australian Centre for Agricultural Research (ACIAR) in Queensland, Australia (Experiment 309).
Author(s)
- Muhammad Yaseen (myaseen208@gmail.com) 
- Sami Ullah (samiullahuos@gmail.com) 
References
- E.R. Williams, C.E. Harwood and A.C. Matheson (2023). Experimental Design and Analysis for Tree Improvement. CSIRO Publishing (https://www.publish.csiro.au/book/3145/). 
See Also
Examples
library(car)
library(dae)
library(dplyr)
library(emmeans)
library(ggplot2)
library(lmerTest)
library(magrittr)
library(predictmeans)
library(supernova)
data(DataExam3.1)
# Pg. 28
fmtab3.3 <-
          lm(
              formula = ht ~ repl*seedlot
            , data    = DataExam3.1
            )
fmtab3.3ANOVA1 <-
  anova(fmtab3.3) %>%
  mutate(
  "F value" =
         c(
           anova(fmtab3.3)[1:2, 3]/anova(fmtab3.3)[3, 3]
         , anova(fmtab3.3)[3, 4]
         , NA
         )
          )
 # Pg. 33 (Table 3.3)
fmtab3.3ANOVA1 %>%
  mutate(
  "Pr(>F)"  =
       c(
         NA
       , pf(
            q   = fmtab3.3ANOVA1[2, 4]
          , df1 = fmtab3.3ANOVA1[2, 1]
          , df2 = fmtab3.3ANOVA1[3, 1], lower.tail = FALSE
          )
       , NA
       , NA
       )
       )
 # Pg. 33  (Table 3.3)
 emmeans(object  = fmtab3.3, specs = ~ seedlot)
 # Pg. 34  (Figure 3.2)
 ggplot(
    mapping = aes(
                  x = fitted.values(fmtab3.3)
                , y = residuals(fmtab3.3)
                )
                ) +
 geom_point(size = 2) +
 labs(
    x = "Fitted Values"
  , y = "Residual"
   ) +
 theme_classic()
# Pg. 33 (Table 3.4)
DataExam3.1m <- DataExam3.1
DataExam3.1m[c(28, 51, 76), 5] <- NA
DataExam3.1m[c(28, 51, 76), 6] <- NA
fmtab3.4 <-
          lm(
              formula   = ht ~ repl*seedlot
            , data      = DataExam3.1m
            )
fmtab3.4ANOVA1 <-
  anova(fmtab3.4) %>%
  mutate(
      "F value" =
            c(
               anova(fmtab3.4)[1:2, 3]/anova(fmtab3.4)[3, 3]
             , anova(fmtab3.4)[3, 4]
             , NA
             )
             )
# Pg. 33 (Table 3.4)
fmtab3.4ANOVA1 %>%
  mutate(
  "Pr(>F)"  =
       c(
         NA
       , pf(
            q   = fmtab3.4ANOVA1[2, 4]
          , df1 = fmtab3.4ANOVA1[2, 1]
          , df2 = fmtab3.4ANOVA1[3, 1], lower.tail = FALSE
          )
       , NA
       , NA
       )
       )
 # Pg. 33  (Table 3.4)
 emmeans(object  = fmtab3.4, specs = ~ seedlot)
Example 3.1.1 from Experimental Design and Analysis for Tree Improvement
Description
Exam3.1.1 is part of data from Australian Centre for Agricultural Research (ACIAR) in Queensland, Australia (Experiment 309).
Author(s)
- Muhammad Yaseen (myaseen208@gmail.com) 
- Sami Ullah (samiullahuos@gmail.com) 
References
- E.R. Williams, C.E. Harwood and A.C. Matheson (2023). Experimental Design and Analysis for Tree Improvement. CSIRO Publishing (https://www.publish.csiro.au/book/3145/). 
See Also
Examples
library(car)
library(dae)
library(dplyr)
library(emmeans)
library(ggplot2)
library(lmerTest)
library(magrittr)
library(predictmeans)
data(DataExam3.1.1)
# Pg. 36
fm3.8 <-
      lm(
         formula = ht ~ repl + seedlot
       , data    = DataExam3.1.1
       )
# Pg. 40
anova(fm3.8)
# Pg. 40
emmeans(object = fm3.8, specs  = ~seedlot)
emmip(object = fm3.8, formula  = ~seedlot) +
 theme_classic()
Example 4.3 from Experimental Design and Analysis for Tree Improvement
Description
Exam4.3 presents the germination count data for 4 Pre-Treatments and 6 Seedlots.
Author(s)
- Muhammad Yaseen (myaseen208@gmail.com) 
- Sami Ullah (samiullahuos@gmail.com) 
References
- E.R. Williams, C.E. Harwood and A.C. Matheson (2023). Experimental Design and Analysis for Tree Improvement. CSIRO Publishing (https://www.publish.csiro.au/book/3145/). 
See Also
Examples
library(car)
library(dae)
library(dplyr)
library(emmeans)
library(ggplot2)
library(lmerTest)
library(magrittr)
library(predictmeans)
data(DataExam4.3)
 # Pg. 50
 fm4.2    <-
   aov(
       formula =
       percent ~ repl + contcomp + seedlot +
                 treat/contcomp + contcomp/seedlot +
                 treat/contcomp/seedlot
      , data   = DataExam4.3
     )
 # Pg. 54
 anova(fm4.2)
 # Pg. 54
 model.tables(x = fm4.2, type = "means")
 emmeans(object = fm4.2, specs = ~ contcomp)
 emmeans(object = fm4.2, specs = ~ seedlot)
 emmeans(object = fm4.2, specs = ~ contcomp + treat)
 emmeans(object = fm4.2, specs = ~ contcomp + seedlot)
 emmeans(object = fm4.2, specs = ~ contcomp + treat + seedlot)
 DataExam4.3 %>%
   dplyr::group_by(treat, contcomp, seedlot) %>%
   dplyr::summarize(Mean = mean(percent))
   RESFIT <-
          data.frame(
           residualvalue = residuals(fm4.2)
         , fittedvalue   = fitted.values(fm4.2)
         )
   ggplot(mapping = aes(
                         x = fitted.values(fm4.2)
                       , y = residuals(fm4.2))) +
   geom_point(size = 2) +
   labs(
       x = "Fitted Values"
     , y = "Residuals"
     ) +
     theme_classic()
Example 4.3.1 from Experimental Design and Analysis for Tree Improvement
Description
Exam4.3.1 presents the germination count data for 4 Pre-Treatments and 6 Seedlots.
Author(s)
- Muhammad Yaseen (myaseen208@gmail.com) 
- Sami Ullah (samiullahuos@gmail.com) 
References
- E.R. Williams, C.E. Harwood and A.C. Matheson (2023). Experimental Design and Analysis for Tree Improvement. CSIRO Publishing (https://www.publish.csiro.au/book/3145/). 
See Also
Examples
library(car)
library(dae)
library(dplyr)
library(emmeans)
library(ggplot2)
library(lmerTest)
library(magrittr)
library(predictmeans)
data(DataExam4.3)
# Pg. 57
fm4.4    <-
  aov(
      formula = percent ~ repl + treat*seedlot
    , data    = DataExam4.3 %>%
                 filter(treat != "control")
     )
 # Pg. 57
 anova(fm4.4)
 model.tables(x = fm4.4, type = "means", se = TRUE)
 emmeans(object = fm4.4, specs = ~ treat)
 emmeans(object = fm4.4, specs = ~ seedlot)
 emmeans(object = fm4.4, specs = ~ treat * seedlot)
Example 4.4 from Experimental Design and Analysis for Tree Improvement
Description
Exam4.4 presents the height means for 4 seedlots under factorial arrangement for two levels of Fertilizer and two levels of Irrigation.
Author(s)
- Muhammad Yaseen (myaseen208@gmail.com) 
- Sami Ullah (samiullahuos@gmail.com) 
References
- E.R. Williams, C.E. Harwood and A.C. Matheson (2023). Experimental Design and Analysis for Tree Improvement. CSIRO Publishing (https://www.publish.csiro.au/book/3145/). 
See Also
Examples
library(car)
library(dae)
library(dplyr)
library(emmeans)
library(ggplot2)
library(lmerTest)
library(magrittr)
library(predictmeans)
data(DataExam4.4)
# Pg. 58
fm4.6    <-
  aov(
      formula = height ~ repl + irrig*fert*seedlot +
                         Error(repl/irrig:fert)
    , data    = DataExam4.4
    )
# Pg. 61
 summary(fm4.6)
# Pg. 61
model.tables(x = fm4.6, type = "means")
# Pg. 61
emmeans(object = fm4.6, specs = ~ irrig)
emmip(object = fm4.6, formula  = ~ irrig) +
    theme_classic()
Example 5.1 from Experimental Design and Analysis for Tree Improvement
Description
Exam5.1 presents the height of 27 seedlots from 4 sites.
Author(s)
- Muhammad Yaseen (myaseen208@gmail.com) 
- Sami Ullah (samiullahuos@gmail.com) 
References
- E.R. Williams, C.E. Harwood and A.C. Matheson (2023). Experimental Design and Analysis for Tree Improvement. CSIRO Publishing (https://www.publish.csiro.au/book/3145/). 
See Also
Examples
library(car)
library(dae)
library(dplyr)
library(emmeans)
library(ggplot2)
library(lmerTest)
library(magrittr)
library(predictmeans)
data(DataExam5.1)
# Pg.68
fm5.4 <-
      lm(
          formula = ht ~ site*seedlot
        , data    = DataExam5.1
        )
# Pg. 73
anova(fm5.4)
# Pg. 73
emmeans(object = fm5.4, specs = ~ site)
emmeans(object = fm5.4, specs = ~ seedlot)
ANOVAfm5.4 <- anova(fm5.4)
ANOVAfm5.4[4, 1:3] <- c(208, 208*1040, 1040)
ANOVAfm5.4[3, 4]   <- ANOVAfm5.4[3, 3]/ANOVAfm5.4[4, 3]
ANOVAfm5.4[3, 5]   <-
           pf(
              q        = ANOVAfm5.4[3, 4]
          , df1        = ANOVAfm5.4[3, 1]
          , df2        = ANOVAfm5.4[4, 1]
          , lower.tail = FALSE
          )
# Pg. 73
ANOVAfm5.4
# Pg. 80
DataExam5.1 %>%
  filter(seedlot %in% c("13653", "13871")) %>%
  ggplot(
    data = .
  , mapping = aes(
                  x     = sitemean
                , y     = ht
                , color = seedlot
                , shape = seedlot
                )
  ) +
  geom_point() +
  geom_smooth(
     method    = lm
   , se        = FALSE
   , fullrange = TRUE
   ) +
  theme_classic() +
  labs(
      x = "SiteMean"
    , y = "SeedLot Mean"
    )
Tab5.10 <-
  DataExam5.1 %>%
  summarise(Mean = mean(ht), .by = seedlot) %>%
  left_join(
     DataExam5.1 %>%
     nest_by(seedlot) %>%
     mutate(fm1 = list(lm(ht ~ sitemean, data = data))) %>%
     summarise(Slope = coef(fm1)[2])
  , by = "seedlot"
     )
# Pg. 81
Tab5.10
ggplot(data = Tab5.10, mapping = aes(x = Mean, y = Slope)) +
 geom_point(size = 2) +
 theme_bw() +
 labs(
     x = "SeedLot Mean"
   , y = "Regression Coefficient"
   )
DevSS1 <-
  DataExam5.1 %>%
  nest_by(seedlot) %>%
  mutate(fm1 = list(lm(ht ~ sitemean, data = data))) %>%
  summarise(SSE = anova(fm1)[2, 2]) %>%
  ungroup() %>%
  summarise(Dev = sum(SSE)) %>%
  as.numeric()
ANOVAfm5.4[2, 2]
length(levels(DataExam5.1$SeedLot))
ANOVAfm5.4.1 <-
  rbind(
   ANOVAfm5.4[1:3, ]
  , c(
      ANOVAfm5.4[2, 1]
    , ANOVAfm5.4[3, 2] - DevSS1
    , (ANOVAfm5.4[3, 2] - DevSS1)/ANOVAfm5.4[2, 1]
    , NA
    , NA
    )
  , c(
      ANOVAfm5.4[3, 1]-ANOVAfm5.4[2, 1]
    , DevSS1
    , DevSS1/(ANOVAfm5.4[3, 1]-ANOVAfm5.4[2, 1])
    , DevSS1/(ANOVAfm5.4[3, 1]-ANOVAfm5.4[2, 1])/ANOVAfm5.4[4, 3]
    , pf(
            q = DevSS1/(ANOVAfm5.4[3, 1]-ANOVAfm5.4[2, 1])/ANOVAfm5.4[4, 3]
        , df1 = ANOVAfm5.4[3, 1]-ANOVAfm5.4[2, 1]
        , df2 = ANOVAfm5.4[4, 1]
        , lower.tail = FALSE
        )
    )
  , ANOVAfm5.4[4, ]
  )
rownames(ANOVAfm5.4.1) <-
  c(
    "Site"
  , "seedlot"
  , "site:seedlot"
  , "  regressions"
  , "  deviations"
  , "Residuals"
  )
# Pg. 82
ANOVAfm5.4.1
Example 5.2 from Experimental Design and Analysis for Tree Improvement
Description
Exam5.2 presents the height of 37 seedlots from 6 sites.
Author(s)
- Muhammad Yaseen (myaseen208@gmail.com) 
- Sami Ullah (samiullahuos@gmail.com) 
References
- E.R. Williams, C.E. Harwood and A.C. Matheson (2023). Experimental Design and Analysis for Tree Improvement. CSIRO Publishing (https://www.publish.csiro.au/book/3145/). 
See Also
Examples
library(car)
library(dae)
library(dplyr)
library(emmeans)
library(ggplot2)
library(lmerTest)
library(magrittr)
library(predictmeans)
data(DataExam5.2)
# Pg. 75
fm5.7 <-
 lm(
     formula = ht ~ site*seedlot
   , data    = DataExam5.2
   )
# Pg. 77
anova(fm5.7)
fm5.9 <-
 lm(
     formula = ht ~ site*seedlot
   , data    = DataExam5.2
   )
# Pg. 77
anova(fm5.9)
ANOVAfm5.9 <- anova(fm5.9)
ANOVAfm5.9[4, 1:3] <- c(384, 384*964, 964)
ANOVAfm5.9[3, 4]   <- ANOVAfm5.9[3, 3]/ANOVAfm5.9[4, 3]
ANOVAfm5.9[3, 5]   <-
    pf(
        q = ANOVAfm5.9[3, 4]
    , df1 = ANOVAfm5.9[3, 1]
    , df2 = ANOVAfm5.9[4, 1]
    , lower.tail = FALSE
    )
# Pg. 77
ANOVAfm5.9
Tab5.14 <-
  DataExam5.2 %>%
  summarise(
       Mean = round(mean(ht, na.rm = TRUE), 0)
     , .by  = seedlot
     ) %>%
   left_join(
      DataExam5.2 %>%
      nest_by(seedlot) %>%
      mutate(fm2 = list(lm(ht ~ sitemean, data = data))) %>%
      summarise(Slope = round(coef(fm2)[2], 2))
    , by = "seedlot"
     ) %>%
  as.data.frame()
# Pg. 81
Tab5.14
DevSS2 <-
  DataExam5.2 %>%
  nest_by(seedlot) %>%
  mutate(fm2 = list(lm(ht ~ sitemean, data = data))) %>%
  summarise(SSE = anova(fm2)[2, 2]) %>%
  ungroup() %>%
  summarise(Dev = sum(SSE)) %>%
  as.numeric()
ANOVAfm5.9.1 <-
  rbind(
     ANOVAfm5.9[1:3, ]
   , c(
        ANOVAfm5.9[2, 1]
      , ANOVAfm5.9[3, 2] - DevSS2
      , (ANOVAfm5.9[3, 2] - DevSS2)/ANOVAfm5.9[2, 1]
      , NA
      , NA
      )
   , c(
        ANOVAfm5.9[3, 1]-ANOVAfm5.9[2, 1]
      , DevSS2
      , DevSS2/(ANOVAfm5.9[3, 1]-ANOVAfm5.9[2, 1])
      , DevSS2/(ANOVAfm5.9[3, 1]-ANOVAfm5.9[2, 1])/ANOVAfm5.9[4, 3]
      , pf(
              q = DevSS2/(ANOVAfm5.9[3, 1]-ANOVAfm5.9[2, 1])/ANOVAfm5.9[4, 3]
          , df1 = ANOVAfm5.9[3, 1]-ANOVAfm5.9[2, 1]
          , df2 = ANOVAfm5.9[4, 1]
          , lower.tail = FALSE
          )
      )
   , ANOVAfm5.9[4, ]
  )
rownames(ANOVAfm5.9.1) <-
  c(
     "site"
   , "seedlot"
   , "site:seedlot"
   , "  regressions"
   , "  deviations"
   , "Residuals"
   )
# Pg. 82
ANOVAfm5.9.1
Code <-
 c(
   "a","a","a","a","b","b","b","b"
 , "c","d","d","d","d","e","f","g"
 , "h","h","i","i","j","k","l","m"
 ,"n","n","n","o","p","p","q","r"
 , "s","t","t","u","v"
 )
Tab5.14$Code <- Code
ggplot(
   data = Tab5.14
 , mapping = aes(x = Mean, y = Slope)
 ) +
 geom_point(size = 2) +
 geom_text(
    mapping = aes(label = Code)
  , hjust   = -0.5
  , vjust   = -0.5
 ) +
 theme_bw() +
 labs(
     x = "SeedLot Mean"
   , y = "Regression Coefficient"
   )
Example 6.2 from Experimental Design and Analysis for Tree Improvement
Description
Exam 6.2 Dbh mean, Dbh varince and number of trees per plot from 3 provinces("PNG","Sabah","Queensland") with 4 replications of 48 families.
Author(s)
- Muhammad Yaseen (myaseen208@gmail.com) 
- Sami Ullah (samiullahuos@gmail.com) 
References
- E.R. Williams, C.E. Harwood and A.C. Matheson (2023). Experimental Design and Analysis for Tree Improvement. CSIRO Publishing (https://www.publish.csiro.au/book/3145/). 
See Also
Examples
library(car)
library(dae)
library(dplyr)
library(emmeans)
library(ggplot2)
library(lmerTest)
library(magrittr)
library(predictmeans)
data(DataExam6.2)
DataExam6.2.1 <-
    DataExam6.2 %>%
    filter(Province == "PNG")
# Pg. 94
fm6.3 <-
     lm(
          formula = Dbh.mean ~ Replication + Family
        , data    = DataExam6.2.1
       )
b    <- anova(fm6.3)
HM      <- function(x){length(x)/sum(1/x)}
w       <- HM(DataExam6.2.1$Dbh.count)
S2      <- b[["Mean Sq"]][length(b[["Mean Sq"]])]
Sigma2t <- mean(DataExam6.2.1$Dbh.variance)
sigma2m <- S2-(Sigma2t/w)
fm6.3.1 <-
  lmer(
      formula = Dbh.mean ~ 1 + Replication + (1|Family)
    , data    = DataExam6.2.1
    , REML    = TRUE
    )
# Pg. 104
# summary(fm6.3.1)
varcomp(fm6.3.1)
sigma2f <- 0.2584
h2 <- (sigma2f/(0.3))/(Sigma2t + sigma2m + sigma2f)
cbind(hmean = w, Sigma2t, sigma2m, sigma2f, h2)
fm6.4 <-
  lm(
      formula = Dbh.mean ~ Replication+Family
     , data   = DataExam6.2
     )
b    <- anova(fm6.4)
HM      <- function(x){length(x)/sum(1/x)}
w       <- HM(DataExam6.2$Dbh.count)
S2      <- b[["Mean Sq"]][length(b[["Mean Sq"]])]
Sigma2t <- mean(DataExam6.2$Dbh.variance)
sigma2m <- S2-(Sigma2t/w)
fm6.4.1 <-
 lmer(
   formula = Dbh.mean ~ 1 + Replication + Province + (1|Family)
 , data    = DataExam6.2
 , REML    = TRUE
    )
# Pg. 107
varcomp(fm6.4.1)
sigma2f <- 0.3514
h2 <- (sigma2f/(0.3))/(Sigma2t+sigma2m+sigma2f)
cbind(hmean = w, Sigma2t, sigma2m, sigma2f, h2)
fm6.7.1 <-
 lmer(
   formula = Dbh.mean ~ 1+Replication+(1|Family)
 , data    = DataExam6.2.1
 , REML = TRUE
 )
# Pg. 116
varcomp(fm6.7.1)
sigma2f[1] <- 0.2584
fm6.7.2<-
 lmer(
   formula = Ht.mean ~ 1 + Replication + (1|Family)
 , data    = DataExam6.2.1
 , REML    = TRUE
   )
# Pg. 116
varcomp(fm6.7.2)
sigma2f[2] <- 0.2711
fm6.7.3 <-
 lmer(
   formula = Sum.means ~ 1 + Replication + (1|Family)
 , data    = DataExam6.2.1
 , REML    = TRUE
 , control = lmerControl()
 )
# Pg. 116
varcomp(fm6.7.3)
sigma2f[3] <- 0.873
sigma2xy   <- 0.5*(sigma2f[3]-sigma2f[1]-sigma2f[2])
GenCorr <- sigma2xy/sqrt(sigma2f[1]*sigma2f[2])
cbind(
     S2x = sigma2f[1]
   , S2y = sigma2f[2]
   , S2.x.plus.y = sigma2f[3]
   , GenCorr
   )
Example 8.1 from Experimental Design and Analysis for Tree Improvement
Description
Exam8.1 presents the Diameter at breast height (Dbh) of 60 SeedLots under layout of row column design with 6 rows and 10 columns in 18 countries and 59 provinces of 18 selected countries.
Author(s)
- Muhammad Yaseen (myaseen208@gmail.com) 
- Sami Ullah (samiullahuos@gmail.com) 
References
- E.R. Williams, C.E. Harwood and A.C. Matheson (2023). Experimental Design and Analysis for Tree Improvement. CSIRO Publishing (https://www.publish.csiro.au/book/3145/). 
See Also
Examples
library(car)
library(dae)
library(dplyr)
library(emmeans)
library(ggplot2)
library(lmerTest)
library(magrittr)
library(predictmeans)
data(DataExam8.1)
# Pg. 141
fm8.4 <-
  aov(
    formula = dbh ~ inoc + Error(repl/inoc) +
                    inoc*country*prov
  , data    = DataExam8.1
     )
# Pg. 150
summary(fm8.4)
# Pg. 150
model.tables(x = fm8.4, type = "means")
RESFit <-
    data.frame(
      fittedvalue   = fitted.aovlist(fm8.4)
    , residualvalue = proj(fm8.4)$Within[,"Residuals"]
    )
ggplot(
   data    =  RESFit
 , mapping = aes(x = fittedvalue, y = residualvalue)
 ) +
geom_point(size = 2) +
labs(
   x = "Residuals vs Fitted Values"
 , y = ""
 ) +
theme_bw()
# Pg. 153
fm8.6 <-
 aov(
   formula = terms(
                   dbh ~ inoc + repl + col +
                         repl:row + repl:col +
                         prov + inoc:prov
                   , keep.order = TRUE
                   )
 , data   = DataExam8.1
 )
summary(fm8.6)
Example 8.1.1 from Experimental Design and Analysis for Tree Improvement
Description
Exam8.1.1 presents the Mixed Effects Analysis of Diameter at breast height (Dbh) of 60 SeedLots under layout of row column design with 6 rows and 10 columns in 18 countries and 59 provinces of 18 selected countries given in Example 8.1.
Author(s)
- Muhammad Yaseen (myaseen208@gmail.com) 
- Sami Ullah (samiullahuos@gmail.com) 
References
- E.R. Williams, C.E. Harwood and A.C. Matheson (2023). Experimental Design and Analysis for Tree Improvement. CSIRO Publishing (https://www.publish.csiro.au/book/3145/). 
See Also
Examples
library(car)
library(dae)
library(dplyr)
library(emmeans)
library(ggplot2)
library(lmerTest)
library(magrittr)
library(predictmeans)
data(DataExam8.1)
# Pg. 155
fm8.8 <-
 lmerTest::lmer(
     formula = dbh ~ 1 + repl + col + prov +
                     (1|repl:row) + (1|repl:col)
   , data   = DataExam8.1
   , REML   = TRUE
   )
# Pg. 157
## Not run: 
varcomp(fm8.8)
## End(Not run)
anova(fm8.8)
anova(fm8.8, ddf = "Kenward-Roger")
predictmeans(model = fm8.8, modelterm = "repl")
predictmeans(model = fm8.8, modelterm = "col")
predictmeans(model = fm8.8, modelterm = "prov")
 # Pg. 161
  RCB1 <-
        aov(dbh ~ prov + repl, data = DataExam8.1)
  RCB  <-
        emmeans(RCB1,  specs = "prov") %>%
        as_tibble()
  Mixed <-
          emmeans(fm8.8, specs = "prov") %>%
          as_tibble()
  table8.9 <-
      left_join(
         x      = RCB
       , y      = Mixed
       , by     = "prov"
       , suffix = c(".RCBD", ".Mixed")
       )
  print(table8.9)
Example 8.1.2 from Experimental Design & Analysis for Tree Improvement
Description
Exam8.1.2 presents the Analysis of Nested Seedlot Structure of Diameter at breast height (Dbh) of 60 SeedLots under layout of row column design with 6 rows and 10 columns in 18 countries and 59 provinces of 18 selected countries given in Example 8.1.
Author(s)
- Muhammad Yaseen (myaseen208@gmail.com) 
- Sami Ullah (samiullahuos@gmail.com) 
References
- E.R. Williams, C.E. Harwood and A.C. Matheson (2023). Experimental Design and Analysis for Tree Improvement. CSIRO Publishing (https://www.publish.csiro.au/book/3145/). 
See Also
Examples
library(car)
library(dae)
library(dplyr)
library(emmeans)
library(ggplot2)
library(lmerTest)
library(magrittr)
library(predictmeans)
data(DataExam8.1)
# Pg. 167
fm8.11 <-
  aov(
       formula = dbh ~ country + country:prov
     , data    = DataExam8.1
      )
  b <- anova(fm8.11)
  Res <- length(b[["Sum Sq"]])
  df  <- 119
  MSS <- 0.1951
  b[["Df"]][Res] <- df
  b[["Sum Sq"]][Res] <- MSS*df
  b[["Mean Sq"]][Res] <- b[["Sum Sq"]][Res]/b[["Df"]][Res]
  b[["F value"]][1:Res-1] <-
            b[["Mean Sq"]][1:Res-1]/b[["Mean Sq"]][Res]
  b[["Pr(>F)"]][Res-1] <-
     df(
       b[["F value"]][Res-1]
     , b[["Df"]][Res-1]
     , b[["Df"]][Res]
     )
  b
 emmeans(fm8.11, specs = "country")
Example 8.2 from Experimental Design and Analysis for Tree Improvement
Description
Exam8.2 presents the Diameter at breast height (Dbh) of 60 SeedLots under layout of row column design with 6 rows and 10 columns in 18 countries and 59 provinces of 18 selected countries.
Author(s)
- Muhammad Yaseen (myaseen208@gmail.com) 
- Sami Ullah (samiullahuos@gmail.com) 
References
- E.R. Williams, C.E. Harwood and A.C. Matheson (2023). Experimental Design and Analysis for Tree Improvement. CSIRO Publishing (https://www.publish.csiro.au/book/3145/). 
See Also
Examples
library(car)
library(dae)
library(dplyr)
library(emmeans)
library(ggplot2)
library(lmerTest)
library(magrittr)
library(predictmeans)
data(DataExam8.2)
# Pg.
fm8.2  <-
  lmerTest::lmer(
    formula = dbh ~ repl + column +
                    contcompf + contcompf:standard +
                    (1|repl:row) + (1|repl:column) +
                    (1|contcompv:clone)
  , data    = DataExam8.2
    )
## Not run: 
varcomp(fm8.2)
## End(Not run)
anova(fm8.2)
Anova(fm8.2, type = "II", test.statistic = "Chisq")
predictmeans(model = fm8.2, modelterm = "repl")
predictmeans(model = fm8.2, modelterm = "column")
emmeans(object = fm8.2, specs = ~contcompf|standard)